test: Add pass using adjusted unlocked branch

On second thought, the extra time running the test suite is worth it.
It will be gained back once we finally get rid of direct mode.

There are two failing tests, same two that have been failing on windows
(though the failure does not look identical). So this should also spare me
the Windows VM while fixing.
This commit is contained in:
Joey Hess 2019-08-09 11:06:54 -04:00
parent 69a5b5a27f
commit b90ee6dc52
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 34 additions and 16 deletions

View file

@ -19,6 +19,7 @@ git-annex (7.20190731) UNRELEASED; urgency=medium
different version, error out rather than silently not changing the
version.
* Fix some test suite failures on Windows.
* test: Add pass using adjusted unlocked branch.
-- Joey Hess <id@joeyh.name> Thu, 01 Aug 2019 00:11:56 -0400

35
Test.hs
View file

@ -147,7 +147,8 @@ tests crippledfilesystem opts = testGroup "Tests" $ properties :
map (\(d, te) -> withTestMode te initTests (unitTests d)) testmodes
where
testmodes = catMaybes
[ Just ("v7 unlocked", (testMode opts (RepoVersion 7)) { unlockedFiles = True })
[ Just ("v7 adjusted unlocked branch", (testMode opts (RepoVersion 7)) { adjustedUnlockedBranch = True })
, Just ("v7 unlocked", (testMode opts (RepoVersion 7)) { unlockedFiles = True })
, unlesscrippled ("v5", testMode opts (RepoVersion 5))
, unlesscrippled ("v7 locked", testMode opts (RepoVersion 7))
, Just ("v5 direct", (testMode opts (RepoVersion 5)) { forceDirect = True })
@ -388,11 +389,17 @@ test_import = intmpclonerepo $ Utility.Tmp.Dir.withTmpDir "importtest" $ \import
return (importdir </> subdir, importdir </> importf, importf)
annexed_present_imported f = ifM (annexeval Config.crippledFileSystem)
( annexed_present_unlocked f
, annexed_present_locked f
, ifM (adjustedUnlockedBranch <$> getTestMode)
( annexed_present_unlocked f
, annexed_present_locked f
)
)
annexed_notpresent_imported f = ifM (annexeval Config.crippledFileSystem)
( annexed_notpresent_unlocked f
, annexed_notpresent_locked f
, ifM (adjustedUnlockedBranch <$> getTestMode)
( annexed_notpresent_unlocked f
, annexed_notpresent_locked f
)
)
test_reinject :: Assertion
@ -602,7 +609,7 @@ test_lock :: Assertion
test_lock = intmpclonerepoInDirect $ do
annexed_notpresent annexedfile
unlessM (annexeval Annex.Version.versionSupportsUnlockedPointers) $
ifM (unlockedFiles <$> getTestMode)
ifM (hasUnlockedFiles <$> getTestMode)
( git_annex_shouldfail "lock" [annexedfile] @? "lock failed to fail with not present file"
, git_annex_shouldfail "unlock" [annexedfile] @? "unlock failed to fail with not present file"
)
@ -708,7 +715,7 @@ test_partial_commit = intmpclonerepoInDirect $ do
)
test_fix :: Assertion
test_fix = intmpclonerepoInDirect $ unlessM (unlockedFiles <$> getTestMode) $ do
test_fix = intmpclonerepoInDirect $ unlessM (hasUnlockedFiles <$> getTestMode) $ do
annexed_notpresent annexedfile
git_annex "fix" [annexedfile] @? "fix of not present failed"
annexed_notpresent annexedfile
@ -779,7 +786,7 @@ test_fsck_basic = intmpclonerepo $ do
git_annex "get" [f] @? "get of file failed"
Utility.FileMode.allowWrite f
writecontent f (changedcontent f)
ifM (annexeval Config.isDirect <||> unlockedFiles <$> getTestMode)
ifM (annexeval Config.isDirect <||> hasUnlockedFiles <$> getTestMode)
( git_annex "fsck" [] @? "fsck failed on unlocked file with changed file content"
, git_annex_shouldfail "fsck" [] @? "fsck failed to fail with corrupted file content"
)
@ -860,7 +867,7 @@ test_migrate' usegitattributes = intmpclonerepoInDirect $ do
checkbackend sha1annexedfile backendSHA256
test_unused :: Assertion
-- This test is broken in direct mode
-- This test is broken in direct mode.
test_unused = intmpclonerepoInDirect $ do
checkunused [] "in new clone"
git_annex "get" [annexedfile] @? "get of file failed"
@ -870,13 +877,15 @@ test_unused = intmpclonerepoInDirect $ do
checkunused [] "after get"
boolSystem "git" [Param "rm", Param "-fq", File annexedfile] @? "git rm failed"
checkunused [] "after rm"
boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "foo"] @? "git commit failed"
-- commit the rm, and when on an adjusted branch, sync it back to
-- the master branch
git_annex "sync" ["--no-push", "--no-pull"] @? "git-annex sync failed"
checkunused [] "after commit"
-- unused checks origin/master; once it's gone it is really unused
boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "git remote rm origin failed"
checkunused [annexedfilekey] "after origin branches are gone"
boolSystem "git" [Param "rm", Param "-fq", File sha1annexedfile] @? "git rm failed"
boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "foo"] @? "git commit failed"
git_annex "sync" ["--no-push", "--no-pull"] @? "git-annex sync failed"
checkunused [annexedfilekey, sha1annexedfilekey] "after rm sha1annexedfile"
-- good opportunity to test dropkey also
@ -894,7 +903,7 @@ test_unused = intmpclonerepoInDirect $ do
-- This is only relevant when using locked files; if the file is
-- unlocked, the work tree file has the content, and there's no way
-- to associate it with the key.
unlessM (unlockedFiles <$> getTestMode) $ do
unlessM (hasUnlockedFiles <$> getTestMode) $ do
writecontent "unusedfile" "unusedcontent"
git_annex "add" ["unusedfile"] @? "add of unusedfile failed"
unusedfilekey <- getKey backendSHA256E "unusedfile"
@ -926,7 +935,7 @@ test_unused = intmpclonerepoInDirect $ do
-- When an unlocked file is modified, git diff will cause git-annex
-- to add its content to the repository. Make sure that's not
-- found as unused.
whenM (unlockedFiles <$> getTestMode) $ do
whenM (hasUnlockedFiles <$> getTestMode) $ do
let f = "unlockedfile"
writecontent f "unlockedcontent1"
boolSystem "git" [Param "add", File "unlockedfile"] @? "git add failed"
@ -1386,7 +1395,7 @@ test_uncommitted_conflict_resolution = do
- lost track of whether a file was a symlink.
-}
test_conflict_resolution_symlink_bit :: Assertion
test_conflict_resolution_symlink_bit = unlessM (unlockedFiles <$> getTestMode) $
test_conflict_resolution_symlink_bit = unlessM (hasUnlockedFiles <$> getTestMode) $
withtmpclonerepo $ \r1 ->
withtmpclonerepo $ \r2 ->
withtmpclonerepo $ \r3 -> do
@ -1719,7 +1728,7 @@ test_add_subdirs = intmpclonerepo $ do
{- Regression test for Windows bug where symlinks were not
- calculated correctly for files in subdirs. -}
unlessM (unlockedFiles <$> getTestMode) $ do
unlessM (hasUnlockedFiles <$> getTestMode) $ do
git_annex "sync" [] @? "sync failed"
l <- annexeval $ Utility.FileSystemEncoding.decodeBL
<$> Annex.CatFile.catObject (Git.Types.Ref "HEAD:dir/foo")

View file

@ -1,6 +1,6 @@
{- git-annex test suite framework
-
- Copyright 2010-2017 Joey Hess <id@joeyh.name>
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -374,7 +374,7 @@ runchecks (a:as) f = do
runchecks as f
annexed_notpresent :: FilePath -> Assertion
annexed_notpresent f = ifM (unlockedFiles <$> getTestMode)
annexed_notpresent f = ifM (hasUnlockedFiles <$> getTestMode)
( annexed_notpresent_unlocked f
, annexed_notpresent_locked f
)
@ -386,7 +386,7 @@ annexed_notpresent_unlocked :: FilePath -> Assertion
annexed_notpresent_unlocked = runchecks [checkregularfile, checkispointerfile, notinlocationlog]
annexed_present :: FilePath -> Assertion
annexed_present f = ifM (unlockedFiles <$> getTestMode)
annexed_present f = ifM (hasUnlockedFiles <$> getTestMode)
( annexed_present_unlocked f
, annexed_present_locked f
)
@ -413,6 +413,7 @@ add_annex f = ifM (unlockedFiles <$> getTestMode)
data TestMode = TestMode
{ forceDirect :: Bool
, unlockedFiles :: Bool
, adjustedUnlockedBranch :: Bool
, annexVersion :: Types.RepoVersion.RepoVersion
, keepFailures :: Bool
} deriving (Read, Show)
@ -421,10 +422,14 @@ testMode :: TestOptions -> Types.RepoVersion.RepoVersion -> TestMode
testMode opts v = TestMode
{ forceDirect = False
, unlockedFiles = False
, adjustedUnlockedBranch = False
, annexVersion = v
, keepFailures = keepFailuresOption opts
}
hasUnlockedFiles :: TestMode -> Bool
hasUnlockedFiles m = unlockedFiles m || adjustedUnlockedBranch m
withTestMode :: TestMode -> TestTree -> TestTree -> TestTree
withTestMode testmode inittests = withResource prepare release . const
where
@ -477,6 +482,9 @@ setupTestMode = do
testmode <- getTestMode
when (forceDirect testmode) $
git_annex "direct" ["-q"] @? "git annex direct failed"
when (adjustedUnlockedBranch testmode) $ do
boolSystem "git" [Param "commit", Param "--allow-empty", Param "-m", Param "empty"] @? "git commit failed"
git_annex "adjust" ["--unlock"] @? "git annex adjust failed"
changeToTmpDir :: FilePath -> IO ()
changeToTmpDir t = do