test: Added --test-with-git-config option

Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
Joey Hess 2022-09-22 15:58:45 -04:00
parent d049228fd3
commit f64eff9355
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 47 additions and 8 deletions

View file

@ -169,7 +169,7 @@ withtmpclonerepo' cfg a = do
case r of
Right () -> return ()
Left e -> do
whenM (keepFailures <$> getTestMode) $
whenM (keepFailuresOption . testOptions <$> getTestMode) $
putStrLn $ "** Preserving repo for failure analysis in " ++ clone
throwM e
@ -255,6 +255,13 @@ configrepo dir = indir dir $ do
-- tell git-annex to not annex the ingitfile
git "config" ["annex.largefiles", "exclude=" ++ ingitfile]
"git config annex.largefiles"
-- set any additional git configs the user wants to test with
gc <- testGitConfig . testOptions <$> getTestMode
forM_ gc $ \case
(Git.Types.ConfigKey k, Git.Types.ConfigValue v) ->
git "config" [decodeBS k, decodeBS v]
"git config from test options"
(Git.Types.ConfigKey _, Git.Types.NoConfigValue) -> noop
ensuredir :: FilePath -> IO ()
ensuredir d = do
@ -483,15 +490,15 @@ data TestMode = TestMode
{ unlockedFiles :: Bool
, adjustedUnlockedBranch :: Bool
, annexVersion :: Types.RepoVersion.RepoVersion
, keepFailures :: Bool
} deriving (Show)
, testOptions :: TestOptions
}
testMode :: TestOptions -> Types.RepoVersion.RepoVersion -> TestMode
testMode opts v = TestMode
{ unlockedFiles = False
, adjustedUnlockedBranch = False
, annexVersion = v
, keepFailures = keepFailuresOption opts
, testOptions = opts
}
hasUnlockedFiles :: TestMode -> Bool