summaryrefslogtreecommitdiff
path: root/test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-26 20:21:24 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-26 20:26:25 -0400
commitdbdcb67f791502f4f6cc26917c1252b998efa482 (patch)
treeb390a515f4298301b755d853812b1eb013cc990b /test.hs
parent948691e89322e88ed2f83bfee4a18dcbdd2f696e (diff)
fix test suite when run by root
Diffstat (limited to 'test.hs')
-rw-r--r--test.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/test.hs b/test.hs
index 2cb0415ab..4e0eb3fb2 100644
--- a/test.hs
+++ b/test.hs
@@ -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