From 34c7bf896f19b182cf6fa104e057f1df9df1254a Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 11 Nov 2011 16:18:48 +0000 Subject: 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. --- tests/fileStatus.hs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'tests/fileStatus.hs') 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 ()) -- cgit v1.2.3