make this test more robust to changes in the testsuite driver
authorSimon Marlow <marlowsd@gmail.com>
Wed, 12 Nov 2008 12:21:18 +0000 (12:21 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 12 Nov 2008 12:21:18 +0000 (12:21 +0000)
tests/getDirContents001.hs
tests/getDirContents001.stdout
tests/getDirContents001.stdout-i386-unknown-mingw32 [deleted file]

index 9f35351..d09b645 100644 (file)
@@ -1,13 +1,18 @@
-import System.Directory (getDirectoryContents)
-import Data.List (sort, isPrefixOf, isSuffixOf)
+import System.Directory
+import Control.Exception
+import System.FilePath
+import Data.List
+
+dir = "getDirContents001.dir"
 
 main = do
-    names <- getDirectoryContents "."
-    putStrLn (unlines (sort (filter ok names)))
+    try cleanup :: IO (Either IOException ())
+    bracket (createDirectory dir) (const cleanup) $ \_ -> do
+      getDirectoryContents dir >>= print . sort
+      mapM_ (\s -> writeFile (dir </> ('f':show s)) (show s)) [1..100]
+      getDirectoryContents dir >>= print . sort
 
-ok name = "getDirContents" `isPrefixOf` name 
-         && not ("bak" `isSuffixOf` name)
-         && not ("prof" `isSuffixOf` name)
-         && not ("hp" `isSuffixOf` name)
-          && not ("ps" `isSuffixOf` name)
-          && not ("aux" `isSuffixOf` name)
+cleanup = do
+   files <- getDirectoryContents dir
+   mapM_ (removeFile . (dir </>)) (filter (not . ("." `isPrefixOf`)) files)
+   removeDirectory dir
index 87a875c..fd68c28 100644 (file)
@@ -1,10 +1,2 @@
-getDirContents001
-getDirContents001.comp.stderr
-getDirContents001.hi
-getDirContents001.hs
-getDirContents001.o
-getDirContents001.run.stderr
-getDirContents001.run.stdout
-getDirContents001.stdout
-getDirContents001.stdout-i386-unknown-mingw32
-
+[".",".."]
+[".","..","f1","f10","f100","f11","f12","f13","f14","f15","f16","f17","f18","f19","f2","f20","f21","f22","f23","f24","f25","f26","f27","f28","f29","f3","f30","f31","f32","f33","f34","f35","f36","f37","f38","f39","f4","f40","f41","f42","f43","f44","f45","f46","f47","f48","f49","f5","f50","f51","f52","f53","f54","f55","f56","f57","f58","f59","f6","f60","f61","f62","f63","f64","f65","f66","f67","f68","f69","f7","f70","f71","f72","f73","f74","f75","f76","f77","f78","f79","f8","f80","f81","f82","f83","f84","f85","f86","f87","f88","f89","f9","f90","f91","f92","f93","f94","f95","f96","f97","f98","f99"]
diff --git a/tests/getDirContents001.stdout-i386-unknown-mingw32 b/tests/getDirContents001.stdout-i386-unknown-mingw32
deleted file mode 100644 (file)
index 89deae1..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-getDirContents001.comp.stderr\r
-getDirContents001.exe\r
-getDirContents001.hi\r
-getDirContents001.hs\r
-getDirContents001.o\r
-getDirContents001.run.stderr\r
-getDirContents001.run.stdout\r
-getDirContents001.stdout\r
-getDirContents001.stdout-i386-unknown-mingw32\r
-\r