test: Fix some test cases that assumed git's default branch name

git is making that configurable, and configuring it globally would break
the test suite in a few places.

No other part of git-annex assumes any branch name. Renamed a few
placeholders to make that clearer.

This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
Joey Hess 2020-06-23 16:40:41 -04:00
parent a364effc02
commit b651d3ede0
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 22 additions and 12 deletions

View file

@ -293,7 +293,7 @@ prop_view_roundtrips f metadata visible = or
, all hasfields (viewedFiles view viewedFileFromReference f metadata) , all hasfields (viewedFiles view viewedFileFromReference f metadata)
] ]
where where
view = View (Git.Ref "master") $ view = View (Git.Ref "foo") $
map (\(mf, mv) -> ViewComponent mf (FilterValues $ S.filter (not . B.null . fromMetaValue) mv) visible) map (\(mf, mv) -> ViewComponent mf (FilterValues $ S.filter (not . B.null . fromMetaValue) mv) visible)
(fromMetaData metadata) (fromMetaData metadata)
visiblefields = sort (map viewField $ filter viewVisible (viewComponents view)) visiblefields = sort (map viewField $ filter viewVisible (viewComponents view))

View file

@ -9,6 +9,7 @@ git-annex (8.20200618) UNRELEASED; urgency=medium
* testremote: Fix over-allocation of resources and bad caching, * testremote: Fix over-allocation of resources and bad caching,
including starting up a large number of external special remote processes. including starting up a large number of external special remote processes.
(Regression introduced in version 8.20200501) (Regression introduced in version 8.20200501)
* test: Fix some test cases that assumed git's default branch name.
-- Joey Hess <id@joeyh.name> Thu, 18 Jun 2020 12:21:14 -0400 -- Joey Hess <id@joeyh.name> Thu, 18 Jun 2020 12:21:14 -0400

29
Test.hs
View file

@ -37,6 +37,7 @@ import qualified Git.Types
import qualified Git.Ref import qualified Git.Ref
import qualified Git.LsTree import qualified Git.LsTree
import qualified Git.FilePath import qualified Git.FilePath
import qualified Git.Branch
import qualified Annex.Locations import qualified Annex.Locations
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
import qualified Types.GitConfig import qualified Types.GitConfig
@ -1502,6 +1503,8 @@ test_adjusted_branch_subtree_regression =
withtmpclonerepo $ \r -> whenM (adjustedbranchsupported r) $ do withtmpclonerepo $ \r -> whenM (adjustedbranchsupported r) $ do
indir r $ do indir r $ do
disconnectOrigin disconnectOrigin
origbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base)
<$> annexeval (Annex.inRepo Git.Branch.current)
git_annex "upgrade" [] @? "upgrade failed" git_annex "upgrade" [] @? "upgrade failed"
git_annex "adjust" ["--unlock", "--force"] @? "adjust failed" git_annex "adjust" ["--unlock", "--force"] @? "adjust failed"
createDirectoryIfMissing True "a/b/c" createDirectoryIfMissing True "a/b/c"
@ -1512,7 +1515,7 @@ test_adjusted_branch_subtree_regression =
writecontent "a/b/x/y" "foo" writecontent "a/b/x/y" "foo"
git_annex "add" ["a/b/x"] @? "add a/b/x failed" git_annex "add" ["a/b/x"] @? "add a/b/x failed"
git_annex "sync" [] @? "sync failed" git_annex "sync" [] @? "sync failed"
boolSystem "git" [Param "checkout", Param "master"] @? "git checkout master failed" boolSystem "git" [Param "checkout", Param origbranch] @? "git checkout failed"
doesFileExist "a/b/x/y" @? ("a/b/x/y missing from master after adjusted branch sync") doesFileExist "a/b/x/y" @? ("a/b/x/y missing from master after adjusted branch sync")
{- Set up repos as remotes of each other. -} {- Set up repos as remotes of each other. -}
@ -1771,19 +1774,21 @@ test_export_import = intmpclonerepo $ do
-- is in sync with the adjusted branch, which it may not be -- is in sync with the adjusted branch, which it may not be
-- depending on how the repository was set up. -- depending on how the repository was set up.
commitchanges commitchanges
git_annex "export" ["master", "--to", "foo"] @? "export to dir failed" currbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base)
<$> annexeval (Annex.inRepo Git.Branch.current)
git_annex "export" [currbranch, "--to", "foo"] @? "export to dir failed"
dircontains annexedfile (content annexedfile) dircontains annexedfile (content annexedfile)
writedir "import" (content "import") writedir "import" (content "import")
git_annex "import" ["master", "--from", "foo"] @? "import from dir failed" git_annex "import" [currbranch, "--from", "foo"] @? "import from dir failed"
git_annex "merge" ["foo/master"] @? "git annex merge foo/master failed" git_annex "merge" ["foo/" ++ currbranch] @? "git annex merge failed"
annexed_present_imported "import" annexed_present_imported "import"
nukeFile "import" nukeFile "import"
writecontent "import" (content "newimport1") writecontent "import" (content "newimport1")
git_annex "add" ["import"] @? "add of import failed" git_annex "add" ["import"] @? "add of import failed"
commitchanges commitchanges
git_annex "export" ["master", "--to", "foo"] @? "export modified file to dir failed" git_annex "export" [currbranch, "--to", "foo"] @? "export modified file to dir failed"
dircontains "import" (content "newimport1") dircontains "import" (content "newimport1")
-- verify that export refuses to overwrite modified file -- verify that export refuses to overwrite modified file
@ -1792,17 +1797,17 @@ test_export_import = intmpclonerepo $ do
writecontent "import" (content "newimport3") writecontent "import" (content "newimport3")
git_annex "add" ["import"] @? "add of import failed" git_annex "add" ["import"] @? "add of import failed"
commitchanges commitchanges
git_annex_shouldfail "export" ["master", "--to", "foo"] @? "export failed to fail in conflict" git_annex_shouldfail "export" [currbranch, "--to", "foo"] @? "export failed to fail in conflict"
dircontains "import" (content "newimport2") dircontains "import" (content "newimport2")
-- resolving import conflict -- resolving import conflict
git_annex "import" ["master", "--from", "foo"] @? "import from dir failed" git_annex "import" [currbranch, "--from", "foo"] @? "import from dir failed"
not <$> boolSystem "git" [Param "merge", Param "foo/master", Param "-mmerge"] @? "git merge of conflict failed to exit nonzero" not <$> boolSystem "git" [Param "merge", Param "foo/master", Param "-mmerge"] @? "git merge of conflict failed to exit nonzero"
nukeFile "import" nukeFile "import"
writecontent "import" (content "newimport3") writecontent "import" (content "newimport3")
git_annex "add" ["import"] @? "add of import failed" git_annex "add" ["import"] @? "add of import failed"
commitchanges commitchanges
git_annex "export" ["master", "--to", "foo"] @? "export failed after import conflict" git_annex "export" [currbranch, "--to", "foo"] @? "export failed after import conflict"
dircontains "import" (content "newimport3") dircontains "import" (content "newimport3")
where where
dircontains f v = dircontains f v =
@ -1850,11 +1855,15 @@ test_export_import_subdir = intmpclonerepo $ do
subannexedfile = "subdir" </> annexedfile subannexedfile = "subdir" </> annexedfile
testexport = do testexport = do
git_annex "export" ["master:"++subdir, "--to", "foo"] @? "export of subdir failed" currbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base)
<$> annexeval (Annex.inRepo Git.Branch.current)
git_annex "export" [currbranch++":"++subdir, "--to", "foo"] @? "export of subdir failed"
dircontains annexedfile (content annexedfile) dircontains annexedfile (content annexedfile)
testimport = do testimport = do
git_annex "import" ["master:"++subdir, "--from", "foo"] @? "import of subdir failed" currbranch <- maybe "foo" (Git.Types.fromRef . Git.Ref.base)
<$> annexeval (Annex.inRepo Git.Branch.current)
git_annex "import" [currbranch++":"++subdir, "--from", "foo"] @? "import of subdir failed"
git_annex "merge" ["foo/master"] @? "git annex merge foo/master failed" git_annex "merge" ["foo/master"] @? "git annex merge foo/master failed"
-- Make sure that import did not import the file to the top -- Make sure that import did not import the file to the top

View file

@ -25,7 +25,7 @@ data View = View
deriving (Eq, Read, Show) deriving (Eq, Read, Show)
instance Arbitrary View where instance Arbitrary View where
arbitrary = View (Git.Ref "master") arbitrary = View (Git.Ref "foo")
<$> resize 10 (listOf arbitrary) <$> resize 10 (listOf arbitrary)
data ViewComponent = ViewComponent data ViewComponent = ViewComponent