From c2e76f8fd9eea037d7d261e034e7a2d1dd0562c0 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 12 Nov 2008 12:21:18 +0000 Subject: [PATCH] make this test more robust to changes in the testsuite driver --- tests/getDirContents001.hs | 25 ++++++++++++-------- tests/getDirContents001.stdout | 12 ++-------- .../getDirContents001.stdout-i386-unknown-mingw32 | 10 -------- 3 files changed, 17 insertions(+), 30 deletions(-) delete mode 100644 tests/getDirContents001.stdout-i386-unknown-mingw32 diff --git a/tests/getDirContents001.hs b/tests/getDirContents001.hs index 9f35351..d09b645 100644 --- a/tests/getDirContents001.hs +++ b/tests/getDirContents001.hs @@ -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 diff --git a/tests/getDirContents001.stdout b/tests/getDirContents001.stdout index 87a875c..fd68c28 100644 --- a/tests/getDirContents001.stdout +++ b/tests/getDirContents001.stdout @@ -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 index 89deae1..0000000 --- a/tests/getDirContents001.stdout-i386-unknown-mingw32 +++ /dev/null @@ -1,10 +0,0 @@ -getDirContents001.comp.stderr -getDirContents001.exe -getDirContents001.hi -getDirContents001.hs -getDirContents001.o -getDirContents001.run.stderr -getDirContents001.run.stdout -getDirContents001.stdout -getDirContents001.stdout-i386-unknown-mingw32 - -- 1.7.10.4