[commit: packages/directory] master: Migrate test: RemoveDirectoryRecursive001 (a42860d)
git at git.haskell.org
git at git.haskell.org
Fri Dec 18 09:51:46 UTC 2015
Repository : ssh://git@git.haskell.org/directory
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/a42860dcb3acd039a2c23948bd44d577a5a689b9/directory
>---------------------------------------------------------------
commit a42860dcb3acd039a2c23948bd44d577a5a689b9
Author: Phil Ruffwind <rf at rufflewind.com>
Date: Fri Jun 5 03:11:10 2015 -0400
Migrate test: RemoveDirectoryRecursive001
Note that we need to add unix/Win32 as a dependency for the tests due to
TestUtils. Not sure what should be done with TestUtils yet.
>---------------------------------------------------------------
a42860dcb3acd039a2c23948bd44d577a5a689b9
directory.cabal | 4 ++
tests/Main.hs | 2 +
...ursive001.hs => RemoveDirectoryRecursive001.hs} | 78 +++++++++++-----------
tests/TestUtils.hs | 1 -
tests/all.T | 1 -
tests/removeDirectoryRecursive001.stdout | 19 ------
6 files changed, 44 insertions(+), 61 deletions(-)
diff --git a/directory.cabal b/directory.cabal
index 18bc23a..568e18e 100644
--- a/directory.cabal
+++ b/directory.cabal
@@ -93,6 +93,10 @@ test-suite test
main-is: Main.hs
type: exitcode-stdio-1.0
build-depends: base, directory, filepath, time
+ if os(windows)
+ build-depends: Win32
+ else
+ build-depends: unix
test-suite test2
default-language: Haskell2010
diff --git a/tests/Main.hs b/tests/Main.hs
index d4e0a4d..5ce8480 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -13,6 +13,7 @@ import qualified GetDirContents001
import qualified GetDirContents002
import qualified GetHomeDirectory001
import qualified GetPermissions001
+import qualified RemoveDirectoryRecursive001
import qualified RenameFile001
import qualified T8482
@@ -31,5 +32,6 @@ main = T.testMain $ \ _t -> do
T.isolatedRun _t "GetDirContents002" GetDirContents002.main
T.isolatedRun _t "GetHomeDirectory001" GetHomeDirectory001.main
T.isolatedRun _t "GetPermissions001" GetPermissions001.main
+ T.isolatedRun _t "RemoveDirectoryRecursive001" RemoveDirectoryRecursive001.main
T.isolatedRun _t "RenameFile001" RenameFile001.main
T.isolatedRun _t "T8482" T8482.main
diff --git a/tests/removeDirectoryRecursive001.hs b/tests/RemoveDirectoryRecursive001.hs
similarity index 50%
rename from tests/removeDirectoryRecursive001.hs
rename to tests/RemoveDirectoryRecursive001.hs
index fbd38e7..c5b57df 100644
--- a/tests/removeDirectoryRecursive001.hs
+++ b/tests/RemoveDirectoryRecursive001.hs
@@ -1,22 +1,14 @@
{-# LANGUAGE CPP #-}
-module Main (main) where
-import Data.List (sort)
+module RemoveDirectoryRecursive001 where
+#include "util.inl"
import System.Directory
+import Data.List (sort)
import System.FilePath ((</>), normalise)
import System.IO.Error (catchIOError)
import TestUtils
-testName :: String
-testName = "removeDirectoryRecursive001"
-
-tmpD :: String
-tmpD = testName ++ ".tmp"
-
-tmp :: String -> String
-tmp s = tmpD </> normalise s
-
-main :: IO ()
-main = do
+main :: TestEnv -> IO ()
+main _t = do
------------------------------------------------------------
-- clean up junk from previous invocations
@@ -44,13 +36,16 @@ main = do
------------------------------------------------------------
-- tests
- getDirectoryContents tmpD >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "a") >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "b") >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "c") >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "d") >>= putStrLn . unwords . sort
-
- putStrLn ""
+ T(expectEq) () [".", "..", "a", "b", "c", "d"] . sort =<<
+ getDirectoryContents tmpD
+ T(expectEq) () [".", "..", "t", "x", "y", "z"] . sort =<<
+ getDirectoryContents (tmp "a")
+ T(expectEq) () [".", "..", "g"] . sort =<<
+ getDirectoryContents (tmp "b")
+ T(expectEq) () [".", "..", "h"] . sort =<<
+ getDirectoryContents (tmp "c")
+ T(expectEq) () [".", "..", "t", "x", "y", "z"] . sort =<<
+ getDirectoryContents (tmp "d")
removeDirectoryRecursive (tmp "d")
`catchIOError` \ _ -> removeFile (tmp "d")
@@ -58,36 +53,39 @@ main = do
`catchIOError` \ _ -> removeDirectory (tmp "d")
#endif
- getDirectoryContents tmpD >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "a") >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "b") >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "c") >>= putStrLn . unwords . sort
-
- putStrLn ""
+ T(expectEq) () [".", "..", "a", "b", "c"] . sort =<<
+ getDirectoryContents tmpD
+ T(expectEq) () [".", "..", "t", "x", "y", "z"] . sort =<<
+ getDirectoryContents (tmp "a")
+ T(expectEq) () [".", "..", "g"] . sort =<<
+ getDirectoryContents (tmp "b")
+ T(expectEq) () [".", "..", "h"] . sort =<<
+ getDirectoryContents (tmp "c")
removeDirectoryRecursive (tmp "c")
`catchIOError` \ _ -> do
modifyPermissions (tmp "c") (\ p -> p { writable = True })
removeDirectoryRecursive (tmp "c")
- getDirectoryContents tmpD >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "a") >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "b") >>= putStrLn . unwords . sort
-
- putStrLn ""
+ T(expectEq) () [".", "..", "a", "b"] . sort =<<
+ getDirectoryContents tmpD
+ T(expectEq) () [".", "..", "t", "x", "y", "z"] . sort =<<
+ getDirectoryContents (tmp "a")
+ T(expectEq) () [".", "..", "g"] . sort =<<
+ getDirectoryContents (tmp "b")
removeDirectoryRecursive (tmp "b")
- getDirectoryContents tmpD >>= putStrLn . unwords . sort
- getDirectoryContents (tmp "a") >>= putStrLn . unwords . sort
-
- putStrLn ""
+ T(expectEq) () [".", "..", "a"] . sort =<<
+ getDirectoryContents tmpD
+ T(expectEq) () [".", "..", "t", "x", "y", "z"] . sort =<<
+ getDirectoryContents (tmp "a")
removeDirectoryRecursive (tmp "a")
- getDirectoryContents tmpD >>= putStrLn . unwords . sort
+ T(expectEq) () [".", ".."] . sort =<<
+ getDirectoryContents tmpD
- ------------------------------------------------------------
- -- clean up
-
- removeDirectoryRecursive tmpD
+ where testName = "removeDirectoryRecursive001"
+ tmpD = testName ++ ".tmp"
+ tmp s = tmpD </> normalise s
diff --git a/tests/TestUtils.hs b/tests/TestUtils.hs
index a6faea0..795fa09 100644
--- a/tests/TestUtils.hs
+++ b/tests/TestUtils.hs
@@ -12,7 +12,6 @@ import System.IO.Error (ioeSetLocation, modifyIOError)
import Foreign (Ptr)
import Foreign.C (CUChar(..), CULong(..), CWchar(..), withCWString)
import System.FilePath (takeDirectory)
-import System.IO (hPutStrLn, stderr)
import System.IO.Error (catchIOError, ioeSetErrorString, isPermissionError,
mkIOError, permissionErrorType)
import System.Win32.Types (failWith, getLastError)
diff --git a/tests/all.T b/tests/all.T
index 13d6ce9..e69de29 100644
--- a/tests/all.T
+++ b/tests/all.T
@@ -1 +0,0 @@
-test('removeDirectoryRecursive001', normal, compile_and_run, [''])
diff --git a/tests/removeDirectoryRecursive001.stdout b/tests/removeDirectoryRecursive001.stdout
deleted file mode 100644
index 0967014..0000000
--- a/tests/removeDirectoryRecursive001.stdout
+++ /dev/null
@@ -1,19 +0,0 @@
-. .. a b c d
-. .. t x y z
-. .. g
-. .. h
-. .. t x y z
-
-. .. a b c
-. .. t x y z
-. .. g
-. .. h
-
-. .. a b
-. .. t x y z
-. .. g
-
-. .. a
-. .. t x y z
-
-. ..
More information about the ghc-commits
mailing list