From: Joey Hess Date: Mon, 30 Aug 2021 20:39:02 +0000 (-0400) Subject: add test case for readonly remote X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~87^2~30 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ccf7e5b949afdce84eb0634647a390880b91d6a5;p=git-annex.git add test case for readonly remote Tests for the reversion fixed in 837116ef1e253f82726b023bfe6ca46777060e27 and similar problems. Sponsored-by: Dartmouth College's Datalad project --- diff --git a/Test.hs b/Test.hs index 1ffed562cd..e8a5d83edd 100644 --- a/Test.hs +++ b/Test.hs @@ -75,6 +75,7 @@ import qualified BuildInfo import qualified Utility.Format import qualified Utility.Verifiable import qualified Utility.Process +import qualified Utility.Process.Transcript import qualified Utility.Misc import qualified Utility.InodeCache import qualified Utility.Env @@ -309,6 +310,7 @@ unitTests :: String -> TestTree unitTests note = testGroup ("Unit Tests " ++ note) [ testCase "add dup" test_add_dup , testCase "add extras" test_add_extras + , testCase "readonly" test_readonly , testCase "ignore deleted files" test_ignore_deleted_files , testCase "metadata" test_metadata , testCase "export_import" test_export_import @@ -427,6 +429,23 @@ test_add_extras = intmpclonerepo $ do annexed_present wormannexedfile checkbackend wormannexedfile backendWORM +test_readonly :: Assertion +test_readonly = + withtmpclonerepo $ \r1 -> + withtmpclonerepo $ \r2 -> do + pair r1 r2 + indir r1 $ do + git_annex "get" [annexedfile] "get failed in first repo" + {- chmod may fail, or not be available, or the + - filesystem not support permissions. -} + void $ Utility.Process.Transcript.processTranscript + "chmod" ["-R", "-w", r1] Nothing + indir r2 $ do + git_annex "sync" ["r1", "--no-push"] "sync with readonly repo" + git_annex "get" [annexedfile, "--from", "r1"] "get from readonly repo" + git "remote" ["rm", "origin"] "remote rm" + git_annex "drop" [annexedfile] "drop vs readonly repo" + test_ignore_deleted_files :: Assertion test_ignore_deleted_files = intmpclonerepo $ do git_annex "get" [annexedfile] "get" @@ -1640,14 +1659,6 @@ test_adjusted_branch_subtree_regression = git "checkout" [origbranch] "git checkout" doesFileExist "a/b/x/y" @? ("a/b/x/y missing from master after adjusted branch sync") -{- Set up repos as remotes of each other. -} -pair :: FilePath -> FilePath -> Assertion -pair r1 r2 = forM_ [r1, r2] $ \r -> indir r $ do - when (r /= r1) $ - git "remote" ["add", "r1", "../../" ++ r1] "remote add" - when (r /= r2) $ - git "remote" ["add", "r2", "../../" ++ r2] "remote add" - test_map :: Assertion test_map = intmpclonerepo $ do -- set descriptions, that will be looked for in the map diff --git a/Test/Framework.hs b/Test/Framework.hs index f5b380f26f..73a3ce355b 100644 --- a/Test/Framework.hs +++ b/Test/Framework.hs @@ -631,3 +631,12 @@ origBranch :: Types.Annex String origBranch = maybe "foo" (Git.Types.fromRef . Git.Ref.base . Annex.AdjustedBranch.fromAdjustedBranch) <$> Annex.inRepo Git.Branch.current + +{- Set up repos as remotes of each other. -} +pair :: FilePath -> FilePath -> Assertion +pair r1 r2 = forM_ [r1, r2] $ \r -> indir r $ do + when (r /= r1) $ + git "remote" ["add", "r1", "../../" ++ r1] "remote add" + when (r /= r2) $ + git "remote" ["add", "r2", "../../" ++ r2] "remote add" +