2016-05-02 17:08:46 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
import Test.Hspec
|
|
|
|
|
2016-05-03 11:27:10 +00:00
|
|
|
import FileSystem.FileOperations.CopyDirRecursiveSpec
|
2016-05-08 16:48:17 +00:00
|
|
|
import FileSystem.FileOperations.CopyDirRecursiveOverwriteSpec
|
2016-05-08 10:48:03 +00:00
|
|
|
import FileSystem.FileOperations.CopyFileOverwriteSpec
|
2016-05-03 11:27:10 +00:00
|
|
|
import FileSystem.FileOperations.CopyFileSpec
|
|
|
|
import FileSystem.FileOperations.CreateDirSpec
|
|
|
|
import FileSystem.FileOperations.CreateRegularFileSpec
|
|
|
|
import FileSystem.FileOperations.DeleteDirRecursiveSpec
|
|
|
|
import FileSystem.FileOperations.DeleteDirSpec
|
|
|
|
import FileSystem.FileOperations.DeleteFileSpec
|
|
|
|
import FileSystem.FileOperations.GetDirsFilesSpec
|
|
|
|
import FileSystem.FileOperations.GetFileTypeSpec
|
|
|
|
import FileSystem.FileOperations.MoveFileSpec
|
|
|
|
import FileSystem.FileOperations.RecreateSymlinkSpec
|
|
|
|
import FileSystem.FileOperations.RenameFileSpec
|
2016-05-03 11:13:07 +00:00
|
|
|
import Utils
|
2016-05-02 17:08:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- TODO: chardev, blockdev, namedpipe, socket
|
|
|
|
|
|
|
|
|
|
|
|
main :: IO ()
|
2016-05-02 17:50:38 +00:00
|
|
|
main = hspec $ before_ fixPermissions $ after_ revertPermissions $ do
|
2016-05-02 17:18:15 +00:00
|
|
|
let tests = [copyFileSpec
|
2016-05-08 10:48:03 +00:00
|
|
|
,copyFileOverwriteSpec
|
|
|
|
,copyDirRecursiveSpec
|
2016-05-08 16:48:17 +00:00
|
|
|
,copyDirRecursiveOverwriteSpec
|
2016-05-08 10:48:03 +00:00
|
|
|
,createDirSpec
|
|
|
|
,createRegularFileSpec
|
|
|
|
,renameFileSpec
|
|
|
|
,moveFileSpec
|
|
|
|
,recreateSymlinkSpec
|
|
|
|
,deleteFileSpec
|
|
|
|
,deleteDirSpec
|
|
|
|
,deleteDirRecursiveSpec
|
2016-05-02 17:18:15 +00:00
|
|
|
]
|
|
|
|
|
2016-05-02 20:13:19 +00:00
|
|
|
-- run all stateful tests twice to catch missing cleanups or state skew
|
2016-05-02 17:18:15 +00:00
|
|
|
sequence_ tests
|
|
|
|
sequence_ tests
|
|
|
|
|
2016-05-02 20:52:10 +00:00
|
|
|
-- stateless tests
|
|
|
|
getFileTypeSpec
|
|
|
|
getDirsFilesSpec
|
|
|
|
|
2016-05-02 17:30:00 +00:00
|
|
|
where
|
2016-05-03 11:27:10 +00:00
|
|
|
noWriteDirs = ["test/FileSystem/FileOperations/copyFileSpec/outputDirNoWrite"
|
2016-05-08 10:48:03 +00:00
|
|
|
,"test/FileSystem/FileOperations/copyFileOverwriteSpec/outputDirNoWrite"
|
2016-05-03 11:27:10 +00:00
|
|
|
,"test/FileSystem/FileOperations/copyDirRecursiveSpec/noWritePerm"
|
2016-05-08 16:48:17 +00:00
|
|
|
,"test/FileSystem/FileOperations/copyDirRecursiveOverwriteSpec/noWritePerm"
|
2016-05-03 11:27:10 +00:00
|
|
|
,"test/FileSystem/FileOperations/createDirSpec/noWritePerms"
|
|
|
|
,"test/FileSystem/FileOperations/createRegularFileSpec/noWritePerms"
|
|
|
|
,"test/FileSystem/FileOperations/renameFileSpec/noWritePerm"
|
|
|
|
,"test/FileSystem/FileOperations/moveFileSpec/noWritePerm"
|
|
|
|
,"test/FileSystem/FileOperations/recreateSymlinkSpec/noWritePerm"
|
2016-05-02 17:50:38 +00:00
|
|
|
]
|
2016-05-03 11:27:10 +00:00
|
|
|
noPermsDirs = ["test/FileSystem/FileOperations/copyFileSpec/noPerms"
|
2016-05-08 10:48:03 +00:00
|
|
|
,"test/FileSystem/FileOperations/copyFileOverwriteSpec/noPerms"
|
2016-05-03 11:27:10 +00:00
|
|
|
,"test/FileSystem/FileOperations/copyDirRecursiveSpec/noPerms"
|
2016-05-08 16:48:17 +00:00
|
|
|
,"test/FileSystem/FileOperations/copyDirRecursiveOverwriteSpec/noPerms"
|
2016-05-03 11:27:10 +00:00
|
|
|
,"test/FileSystem/FileOperations/createDirSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/createRegularFileSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/renameFileSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/moveFileSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/recreateSymlinkSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/getFileTypeSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/getDirsFilesSpec/noPerms"
|
|
|
|
,"test/FileSystem/FileOperations/deleteFileSpec/noPerms"
|
2016-05-02 17:50:38 +00:00
|
|
|
]
|
2016-05-02 17:30:00 +00:00
|
|
|
fixPermissions = do
|
2016-05-02 17:50:38 +00:00
|
|
|
sequence_ $ fmap noWritableDirPerms noWriteDirs
|
|
|
|
sequence_ $ fmap noPerms noPermsDirs
|
|
|
|
revertPermissions = do
|
|
|
|
sequence_ $ fmap normalDirPerms noWriteDirs
|
|
|
|
sequence_ $ fmap normalDirPerms noPermsDirs
|
2016-05-02 17:08:46 +00:00
|
|
|
|