From 8e9713b76942e2a5bd562974b52383ad2b17f55a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Mar 2019 16:49:33 -0400 Subject: [PATCH] add export+import test case --- Test.hs | 51 ++++++++++++++++++++++++++++++++++++++- doc/todo/import_tree.mdwn | 6 ++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Test.hs b/Test.hs index 25849d2b93..82c555ffc7 100644 --- a/Test.hs +++ b/Test.hs @@ -1,6 +1,6 @@ {- git-annex test suite - - - Copyright 2010-2018 Joey Hess + - Copyright 2010-2019 Joey Hess - - Licensed under the GNU GPL version 3 or higher. -} @@ -207,6 +207,7 @@ unitTests :: String -> TestTree unitTests note = testGroup ("Unit Tests " ++ note) [ testCase "add dup" test_add_dup , testCase "add extras" test_add_extras + , testCase "export_import" test_export_import , testCase "shared clone" test_shared_clone , testCase "log" test_log , testCase "import" test_import @@ -1725,3 +1726,51 @@ test_addurl = intmpclonerepo $ do let dest = "addurlurldest" filecmd "addurl" ["--file", dest, url] @? ("addurl failed on " ++ url ++ " with --file") doesFileExist dest @? (dest ++ " missing after addurl --file") + +test_export_import :: Assertion +test_export_import = intmpclonerepoInDirect $ do + createDirectory "dir" + git_annex "initremote" (words "foo type=directory encryption=none directory=dir exporttree=yes importtree=yes") @? "initremote failed" + git_annex "get" [] @? "get of files failed" + annexed_present annexedfile + + git_annex "export" ["master", "--to", "foo"] @? "export to dir failed" + dircontains annexedfile (content annexedfile) + + writedir "import" (content "import") + git_annex "import" ["master", "--from", "foo"] @? "import from dir failed" + boolSystem "git" [Param "merge", Param "foo/master", Param "-mmerge", Param "--allow-unrelated-histories"] @? "git merge foo/master failed" + -- FIXME fails when in an adjusted unlocked branch because + -- it's imported locked + --annexed_present "import" + + nukeFile "import" + writecontent "import" (content "newimport1") + git_annex "add" ["import"] @? "add of import failed" + boolSystem "git" [Param "commit", Param "-q", Param "-mchanged"] @? "git commit failed" + git_annex "export" ["master", "--to", "foo"] @? "export modified file to dir failed" + dircontains "import" (content "newimport1") + + -- verify that export refuses to overwrite modified file + writedir "import" (content "newimport2") + nukeFile "import" + writecontent "import" (content "newimport3") + git_annex "add" ["import"] @? "add of import failed" + boolSystem "git" [Param "commit", Param "-q", Param "-mchanged"] @? "git commit failed" + git_annex_shouldfail "export" ["master", "--to", "foo"] @? "export failed to fail in conflict" + dircontains "import" (content "newimport2") + + -- resolving import conflict + git_annex "import" ["master", "--from", "foo"] @? "import from dir failed" + not <$> boolSystem "git" [Param "merge", Param "foo/master", Param "-mmerge"] @? "git merge of conflict failed to exit nonzero" + nukeFile "import" + writecontent "import" (content "newimport3") + git_annex "add" ["import"] @? "add of import failed" + boolSystem "git" [Param "commit", Param "-q", Param "-mchanged"] @? "git commit failed" + git_annex "export" ["master", "--to", "foo"] @? "export failed after import conflict" + dircontains "import" (content "newimport3") + where + dircontains f v = + ((v==) <$> readFile ("dir" f)) + @? ("did not find expected content of " ++ "dir" f) + writedir f = writecontent ("dir" f) diff --git a/doc/todo/import_tree.mdwn b/doc/todo/import_tree.mdwn index b8e067ad29..5a07085ec5 100644 --- a/doc/todo/import_tree.mdwn +++ b/doc/todo/import_tree.mdwn @@ -14,13 +14,11 @@ this. importing and resolving the merge conflict, exporting the resolution fails. It seems it's lost the old CID for the remote's content. + Hmm, can't reproduce that now, I may have been confused? + * getknowncids should run "updateexportdb exportdb exportdbv", but that leads to a STM deadlock for some reason? -* Check conflict behavior for both conflicting edits to existing file, - and conflicting new files. Note need to check both sequences - import,export and export,import. - * Need to support annex-tracking-branch configuration, which documentation says makes git-annex sync and assistant do imports.