test: Added --test-with-git-config option
Sponsored-by: Dartmouth College's DANDI project
This commit is contained in:
parent
d049228fd3
commit
f64eff9355
6 changed files with 47 additions and 8 deletions
|
@ -31,6 +31,7 @@ git-annex (10.20220823) UNRELEASED; urgency=medium
|
|||
* Improved handling of --time-limit when combined with -J
|
||||
* Fix updating git index file after getting an unlocked file
|
||||
when annex.stalldetection is set.
|
||||
* test: Added --test-with-git-config option.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 29 Aug 2022 15:03:04 -0400
|
||||
|
||||
|
|
20
Test.hs
20
Test.hs
|
@ -1,6 +1,6 @@
|
|||
{- git-annex test suite
|
||||
-
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2022 oey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -13,12 +13,12 @@ import Types.Test
|
|||
import Types.RepoVersion
|
||||
import Types.Concurrency
|
||||
import Test.Framework
|
||||
import Options.Applicative.Types
|
||||
|
||||
import Test.Tasty
|
||||
import Test.Tasty.HUnit
|
||||
import Test.Tasty.QuickCheck
|
||||
import Options.Applicative (switch, long, short, help, internal, maybeReader, option)
|
||||
import Options.Applicative.Types
|
||||
import Options.Applicative (switch, long, short, help, internal, maybeReader, option, metavar)
|
||||
|
||||
import qualified Data.Map as M
|
||||
import qualified Data.ByteString.Lazy.UTF8 as BU8
|
||||
|
@ -92,7 +92,7 @@ import qualified Utility.Gpg
|
|||
|
||||
optParser :: Parser TestOptions
|
||||
optParser = TestOptions
|
||||
<$> snd (tastyParser (tests 1 False True (TestOptions mempty False False Nothing mempty)))
|
||||
<$> snd (tastyParser (tests 1 False True (TestOptions mempty False False Nothing mempty mempty)))
|
||||
<*> switch
|
||||
( long "keep-failures"
|
||||
<> help "preserve repositories on test failure"
|
||||
|
@ -106,7 +106,19 @@ optParser = TestOptions
|
|||
<> short 'J'
|
||||
<> help "number of concurrent jobs"
|
||||
))
|
||||
<*> many (option (maybeReader parseconfigvalue)
|
||||
( long "test-git-config"
|
||||
<> help "run tests with a git config set"
|
||||
<> metavar "NAME=VALUE"
|
||||
))
|
||||
<*> cmdParams "non-options are for internal use only"
|
||||
where
|
||||
parseconfigvalue s = case break (== '=') s of
|
||||
(_, []) -> Nothing
|
||||
(k, v) -> Just
|
||||
( Git.Types.ConfigKey (encodeBS k)
|
||||
, Git.Types.ConfigValue (encodeBS (drop 1 v))
|
||||
)
|
||||
|
||||
runner :: TestOptions -> IO ()
|
||||
runner opts = parallelTestRunner opts tests
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,12 +11,14 @@ import Test.Tasty.Options
|
|||
|
||||
import Types.Concurrency
|
||||
import Types.Command
|
||||
import Git.Types
|
||||
|
||||
data TestOptions = TestOptions
|
||||
{ tastyOptionSet :: OptionSet
|
||||
, keepFailuresOption :: Bool
|
||||
, fakeSsh :: Bool
|
||||
, concurrentJobs :: Maybe Concurrency
|
||||
, testGitConfig :: [(ConfigKey, ConfigValue)]
|
||||
, internalData :: CmdParams
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,20 @@ framework. Pass --help for details about those.
|
|||
When there are test failures, leave the `.t` directory populated with
|
||||
repositories that demonstate the failures, for later analysis.
|
||||
|
||||
* `--test-git-config name=value`
|
||||
|
||||
The test suite prevents git from reading any git configuration files.
|
||||
Usually it is a good idea to run the test suite with a standard
|
||||
git configuration. However, this option can be useful to see what
|
||||
effect a git configuration setting has on the test suite.
|
||||
|
||||
Some configuration settings will break the test suite, in ways that are
|
||||
due to a bug in git-annex. But it is possible that changing a
|
||||
configuration can find a legitimate bug in git-annex.
|
||||
|
||||
One valid use of this is to change a git configuration to a value that
|
||||
is planned to be the new default in a future version of git.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
[[git-annex]](1)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
`git-annex test` prevents ~/.gitconfig or /etc/gitconfig from being read.
|
||||
The `-c` option also doesn't propagate into the test suite.
|
||||
|
||||
It would sometimes be useful to test git-annex with a given git config set.
|
||||
Although some might break the test suite, others might expose actual bugs
|
||||
in git-annex. --[[Joey]]
|
||||
|
||||
> Added "--test-git-config" option, [[done]] --[[Joey]]
|
||||
|
|
Loading…
Reference in a new issue