Fix tests on mac

This commit is contained in:
Julian Ospald 2020-04-14 17:16:21 +02:00
parent 74d686547e
commit 92cc84377d
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
6 changed files with 12 additions and 8 deletions

View File

@ -564,7 +564,7 @@ easyCopy from to cm rm = do
--
-- Throws:
--
-- - `InappropriateType` for wrong file type (directory)
-- - `InappropriateType` or `PermissionDenied` for wrong file type (directory)
-- - `NoSuchThing` if the file does not exist
-- - `PermissionDenied` if the directory cannot be read
--

View File

@ -8,6 +8,9 @@ import Test.Hspec.Formatters
import qualified Spec
import Utils
import System.Posix.Temp.ByteString (mkdtemp)
import System.Posix.Env.ByteString (getEnvDefault)
import System.Posix.FilePath ((</>))
import "hpath-directory" System.Posix.RawFilePath.Directory
-- TODO: chardev, blockdev, namedpipe, socket
@ -15,7 +18,8 @@ import System.Posix.Temp.ByteString (mkdtemp)
main :: IO ()
main = do
tmpBase <- mkdtemp "/tmp/"
tmpdir <- getEnvDefault "TMPDIR" "/tmp" >>= canonicalizePath
tmpBase <- mkdtemp (tmpdir </> "hpath-directory")
writeIORef baseTmpDir (Just (tmpBase `BS.append` "/"))
putStrLn $ ("Temporary test directory at: " ++ show tmpBase)
hspecWith

View File

@ -125,7 +125,7 @@ spec = beforeAll_ (upTmpDir >> setupFiles) $ afterAll_ cleanupFiles $
"outputDir"
Strict
CollectFailures
(system $ "diff -r --no-dereference "
(system $ "diff -r "
++ toString tmpDir' ++ "inputDir" ++ " "
++ toString tmpDir' ++ "outputDir"
++ " >/dev/null")

View File

@ -104,7 +104,7 @@ spec = beforeAll_ (upTmpDir >> setupFiles) $ afterAll_ cleanupFiles $
"outputDir"
Overwrite
FailEarly
(system $ "diff -r --no-dereference "
(system $ "diff -r "
++ toString tmpDir' ++ "inputDir" ++ " "
++ toString tmpDir' ++ "outputDir"
++ " >/dev/null")
@ -113,7 +113,7 @@ spec = beforeAll_ (upTmpDir >> setupFiles) $ afterAll_ cleanupFiles $
it "copyDirRecursive (Overwrite, FailEarly), destination dir already exists" $ do
tmpDir' <- getRawTmpDir
(system $ "diff -r --no-dereference "
(system $ "diff -r "
++ toString tmpDir' ++ "inputDir" ++ " "
++ toString tmpDir' ++ "alreadyExistsD"
++ " >/dev/null")
@ -122,7 +122,7 @@ spec = beforeAll_ (upTmpDir >> setupFiles) $ afterAll_ cleanupFiles $
"alreadyExistsD"
Overwrite
FailEarly
(system $ "diff -r --no-dereference "
(system $ "diff -r "
++ toString tmpDir' ++ "inputDir" ++ " "
++ toString tmpDir' ++ "alreadyExistsD"
++ " >/dev/null")

View File

@ -89,7 +89,7 @@ spec = beforeAll_ (upTmpDir >> setupFiles) $ afterAll_ cleanupFiles $
"outputDir"
Strict
FailEarly
(system $ "diff -r --no-dereference "
(system $ "diff -r "
++ toString tmpDir' ++ "inputDir" ++ " "
++ toString tmpDir' ++ "outputDir"
++ " >/dev/null")

View File

@ -70,7 +70,7 @@ spec = beforeAll_ (upTmpDir >> setupFiles) $ afterAll_ cleanupFiles $
it "deleteFile, wrong file type (directory)" $
deleteFile' "dir"
`shouldThrow`
(\e -> ioeGetErrorType e == InappropriateType)
(\e -> ioeGetErrorType e == InappropriateType || ioeGetErrorType e == PermissionDenied)
it "deleteFile, file does not exist" $
deleteFile' "doesNotExist"