diff options
author | Joey Hess <joey@kitenet.net> | 2011-04-26 20:21:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-04-26 20:26:25 -0400 |
commit | dbdcb67f791502f4f6cc26917c1252b998efa482 (patch) | |
tree | b390a515f4298301b755d853812b1eb013cc990b /test.hs | |
parent | 948691e89322e88ed2f83bfee4a18dcbdd2f696e (diff) |
fix test suite when run by root
Diffstat (limited to 'test.hs')
-rw-r--r-- | test.hs | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -577,10 +577,14 @@ checkcontent f = do checkunwritable :: FilePath -> Assertion checkunwritable f = do - r <- try $ writeFile f $ content f - case r of - Left _ -> return () -- expected permission error - Right _ -> assertFailure $ "was able to modify annexed file's " ++ f ++ " content" + -- Look at permissions bits rather than trying to write or using + -- fileAccess because if run as root, any file can be modified + -- despite permissions. + s <- getFileStatus f + let mode = fileMode s + if (mode == mode `unionFileModes` ownerWriteMode) + then assertFailure $ "able to modify annexed file's " ++ f ++ " content" + else return () checkwritable :: FilePath -> Assertion checkwritable f = do @@ -640,7 +644,7 @@ runchecks (a:as) f = do annexed_notpresent :: FilePath -> Assertion annexed_notpresent = runchecks - [checklink, checkdangling, checkunwritable, notinlocationlog] + [checklink, checkdangling, notinlocationlog] annexed_present :: FilePath -> Assertion annexed_present = runchecks |