TESTS: less side effects plz

This commit is contained in:
2016-06-05 14:33:53 +02:00
parent 5d1c5cc2ce
commit bc348c7dd5
21 changed files with 262 additions and 54 deletions

View File

@@ -19,8 +19,17 @@ import System.Exit
import System.Process
import Utils
import Data.ByteString.UTF8 (toString)
import Data.IORef
(
readIORef
)
upTmpDir :: IO ()
upTmpDir = do
setTmpDir "CopyFileSpec"
createTmpDir
setupFiles :: IO ()
setupFiles = do
createRegularFile' "inputFile"
@@ -51,7 +60,7 @@ cleanupFiles = do
spec :: Spec
spec = before_ setupFiles $ after_ cleanupFiles $
spec = beforeAll_ upTmpDir $ before_ setupFiles $ after_ cleanupFiles $
describe "HPath.IO.copyFile" $ do
-- successes --
@@ -62,11 +71,12 @@ spec = before_ setupFiles $ after_ cleanupFiles $
removeFileIfExists "outputFile"
it "copyFile (Strict), and compare" $ do
tmpDir' <- getRawTmpDir
copyFile' "inputFile"
"outputFile"
Strict
(system $ "cmp -s " ++ toString tmpDir ++ "inputFile" ++ " "
++ toString tmpDir ++ "outputFile")
(system $ "cmp -s " ++ toString tmpDir' ++ "inputFile" ++ " "
++ toString tmpDir' ++ "outputFile")
`shouldReturn` ExitSuccess
removeFileIfExists "outputFile"