Browse Source

Fix tests on mac

master
Julian Ospald 4 years ago
parent
commit
92cc84377d
No known key found for this signature in database GPG Key ID: 511B62C09D50CD28
6 changed files with 12 additions and 7 deletions
  1. +1
    -0
      hpath-directory/src/System/Posix/RawFilePath/Directory.hs
  2. +5
    -1
      hpath-directory/test/Main.hs
  3. +1
    -1
      hpath-directory/test/System/Posix/RawFilePath/Directory/CopyDirRecursiveCollectFailuresSpec.hs
  4. +3
    -3
      hpath-directory/test/System/Posix/RawFilePath/Directory/CopyDirRecursiveOverwriteSpec.hs
  5. +1
    -1
      hpath-directory/test/System/Posix/RawFilePath/Directory/CopyDirRecursiveSpec.hs
  6. +1
    -1
      hpath-directory/test/System/Posix/RawFilePath/Directory/DeleteFileSpec.hs

+ 1
- 0
hpath-directory/src/System/Posix/RawFilePath/Directory.hs View File

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


+ 5
- 1
hpath-directory/test/Main.hs 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


+ 1
- 1
hpath-directory/test/System/Posix/RawFilePath/Directory/CopyDirRecursiveCollectFailuresSpec.hs 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")


+ 3
- 3
hpath-directory/test/System/Posix/RawFilePath/Directory/CopyDirRecursiveOverwriteSpec.hs 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")


+ 1
- 1
hpath-directory/test/System/Posix/RawFilePath/Directory/CopyDirRecursiveSpec.hs 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")


+ 1
- 1
hpath-directory/test/System/Posix/RawFilePath/Directory/DeleteFileSpec.hs 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"


Loading…
Cancel
Save