add test for #1652
authorSimon Marlow <simonmar@microsoft.com>
Thu, 18 Oct 2007 13:06:23 +0000 (13:06 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 18 Oct 2007 13:06:23 +0000 (13:06 +0000)
tests/all.T
tests/copyFile002.hs [new file with mode: 0644]
tests/copyFile002.stdout [new file with mode: 0644]

index 1c34882..633a8d8 100644 (file)
@@ -9,3 +9,4 @@ test('getDirContents001', omit_ways(['ghci']), compile_and_run, ['-fno-gen-manif
 test('getPermissions001', omit_ways(['ghci']), compile_and_run, ['-cpp'])
 
 test('copyFile001',  normal, compile_and_run, [''])
+test('copyFile002',  normal, compile_and_run, [''])
diff --git a/tests/copyFile002.hs b/tests/copyFile002.hs
new file mode 100644 (file)
index 0000000..332d762
--- /dev/null
@@ -0,0 +1,28 @@
+
+module Main (main) where
+
+import Control.Exception
+import Data.List
+import System.Directory
+import System.IO
+
+-- like copyFile001, but moves a file in the current directory
+-- See bug #1652
+main :: IO ()
+main = do d <- getCurrentDirectory
+          flip finally (setCurrentDirectory d) $ do
+          setCurrentDirectory "copyFile"
+          try $ removeFile to
+          cs_before <- getDirectoryContents "."
+          putStrLn "Before:"
+          print $ sort cs_before
+          copyFile from to
+          cs_before <- getDirectoryContents "."
+          putStrLn "After:"
+          print $ sort cs_before
+          readFile to >>= print
+
+from, to :: FilePath
+from = "source"
+to   = "target"
+
diff --git a/tests/copyFile002.stdout b/tests/copyFile002.stdout
new file mode 100644 (file)
index 0000000..6b17d94
--- /dev/null
@@ -0,0 +1,5 @@
+Before:
+[".","..","source"]
+After:
+[".","..","source","target"]
+"This is the data"