make this test more robust to changes in the testsuite driver
[haskell-directory.git] / tests / getDirContents001.hs
1 import System.Directory
2 import Control.Exception
3 import System.FilePath
4 import Data.List
5
6 dir = "getDirContents001.dir"
7
8 main = do
9     try cleanup :: IO (Either IOException ())
10     bracket (createDirectory dir) (const cleanup) $ \_ -> do
11       getDirectoryContents dir >>= print . sort
12       mapM_ (\s -> writeFile (dir </> ('f':show s)) (show s)) [1..100]
13       getDirectoryContents dir >>= print . sort
14
15 cleanup = do
16    files <- getDirectoryContents dir
17    mapM_ (removeFile . (dir </>)) (filter (not . ("." `isPrefixOf`)) files)
18    removeDirectory dir