aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/fileStatus.hs
diff options
context:
space:
mode:
authorGravatar Simon Marlow <marlowsd@gmail.com>2011-11-11 16:18:48 +0000
committerGravatar Simon Marlow <marlowsd@gmail.com>2011-11-22 12:36:48 +0000
commit34c7bf896f19b182cf6fa104e057f1df9df1254a (patch)
treeabdb8264ae52c62263fc0fb4b395906a64acb104 /tests/fileStatus.hs
parentc213ae2ec6d9c71266aebc8e5b2326a9625fba7a (diff)
Provide a raw ByteString version of FilePath and environment APIs
The new module System.Posix.ByteString provides exactly the same API as System.Posix, except that: - There is a new type: RawFilePath = ByteString - All functions mentioning FilePath in the System.Posix API use RawFilePath in the System.Posix.ByteString API - RawFilePaths are not subject to Unicode locale encoding and decoding, unlike FilePaths. They are the exact bytes passed to and returned from the underlying POSIX API. - Similarly for functions that deal in environment strings (System.Posix.Env): these use untranslated ByteStrings in System.Posix.Environment - There is a new function System.Posix.ByteString.getArgs :: [ByteString] returning the raw untranslated arguments as passed to exec() when the program was started.
Diffstat (limited to 'tests/fileStatus.hs')
-rw-r--r--tests/fileStatus.hs25
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/fileStatus.hs b/tests/fileStatus.hs
index a393d72..e1d1661 100644
--- a/tests/fileStatus.hs
+++ b/tests/fileStatus.hs
@@ -14,9 +14,14 @@ main = do
testSymlink fs ds
cleanup
+regular = "regular"
+dir = "dir"
+link_regular = "link-regular"
+link_dir = "link-dir"
+
testRegular = do
- createFile "regular" ownerReadMode
- (fs, _) <- getStatus "regular"
+ createFile regular ownerReadMode
+ (fs, _) <- getStatus regular
let expected = (False,False,False,True,False,False,False)
actual = snd (statusElements fs)
when (actual /= expected) $
@@ -24,8 +29,8 @@ testRegular = do
return fs
testDir = do
- createDirectory "dir" ownerReadMode
- (ds, _) <- getStatus "dir"
+ createDirectory dir ownerReadMode
+ (ds, _) <- getStatus dir
let expected = (False,False,False,False,True,False,False)
actual = snd (statusElements ds)
when (actual /= expected) $
@@ -33,10 +38,10 @@ testDir = do
return ds
testSymlink fs ds = do
- createSymbolicLink "regular" "link-regular"
- createSymbolicLink "dir" "link-dir"
- (fs', ls) <- getStatus "link-regular"
- (ds', lds) <- getStatus "link-dir"
+ createSymbolicLink regular link_regular
+ createSymbolicLink dir link_dir
+ (fs', ls) <- getStatus link_regular
+ (ds', lds) <- getStatus link_dir
let expected = (False,False,False,False,False,True,False)
actualF = snd (statusElements ls)
@@ -55,9 +60,9 @@ testSymlink fs ds = do
fail "status for a directory does not match when it's accessed via a symlink"
cleanup = do
- ignoreIOExceptions $ removeDirectory "dir"
+ ignoreIOExceptions $ removeDirectory dir
mapM_ (ignoreIOExceptions . removeLink)
- ["regular", "link-regular", "link-dir"]
+ [regular, link_regular, link_dir]
ignoreIOExceptions io = io `E.catch`
((\_ -> return ()) :: IOException -> IO ())