From cc7db6f058f69a1a0f08221f46d2d12d3d3764bf Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 11 Jan 2011 19:34:28 -0400 Subject: [PATCH] test fsck --- test.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test.hs b/test.hs index 7e56fd65c1..0c6e018842 100644 --- a/test.hs +++ b/test.hs @@ -30,6 +30,7 @@ import qualified GitAnnex import qualified LocationLog import qualified UUID import qualified Remotes +import qualified Core main :: IO () main = do @@ -68,6 +69,7 @@ toplevels = TestLabel "toplevel" $ TestList , test_edit , test_fix , test_trust + , test_fsck ] test_init :: Test @@ -268,6 +270,20 @@ test_trust = "git-annex trust/untrust" ~: intmpclonerepo $ do return $ elem u uuids assertEqual "trust value" expected istrusted +test_fsck :: Test +test_fsck = "git-annex fsck" ~: intmpclonerepo $ do + git_annex "fsck" ["-q"] @? "fsck failed" + Utility.boolSystem "git" ["config", "annex.numcopies", "2"] @? "git config failed" + r <- git_annex "fsck" ["-q"] + not r @? "fsck failed to fail with numcopies unsatisfied" + Utility.boolSystem "git" ["config", "annex.numcopies", "1"] @? "git config failed" + + git_annex "get" ["-q", annexedfile] @? "get of file failed" + Core.allowWrite annexedfile + writeFile annexedfile (changedcontent annexedfile) + r <- git_annex "fsck" ["-q"] + not r @? "fsck failed to fail with corrupted file content" + -- This is equivilant to running git-annex, but it's all run in-process -- so test coverage collection works. git_annex :: String -> [String] -> IO Bool