use separate main repo dir for each test suite pass
This way a failure to clean up the main repo dir from a previous pass can't result in reusing that repo, which won't be configured right for the current pass.
This commit is contained in:
parent
70b71bf660
commit
298812a353
3 changed files with 36 additions and 17 deletions
|
@ -18,6 +18,7 @@ git-annex (7.20190731) UNRELEASED; urgency=medium
|
|||
* init: When the repo is already initialized, and --version requests a
|
||||
different version, error out rather than silently not changing the
|
||||
version.
|
||||
* Fix some test suite failures on Windows.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Thu, 01 Aug 2019 00:11:56 -0400
|
||||
|
||||
|
|
|
@ -102,7 +102,9 @@ innewrepo :: Assertion -> Assertion
|
|||
innewrepo a = withgitrepo $ \r -> indir r a
|
||||
|
||||
inmainrepo :: Assertion -> Assertion
|
||||
inmainrepo = indir mainrepodir
|
||||
inmainrepo a = do
|
||||
d <- mainrepodir
|
||||
indir d a
|
||||
|
||||
with_ssh_origin :: (Assertion -> Assertion) -> (Assertion -> Assertion)
|
||||
with_ssh_origin cloner a = cloner $ do
|
||||
|
@ -151,7 +153,8 @@ withtmpclonerepo = withtmpclonerepo' newCloneRepoConfig
|
|||
withtmpclonerepo' :: CloneRepoConfig -> (FilePath -> Assertion) -> Assertion
|
||||
withtmpclonerepo' cfg a = do
|
||||
dir <- tmprepodir
|
||||
clone <- clonerepo mainrepodir dir cfg
|
||||
maindir <- mainrepodir
|
||||
clone <- clonerepo maindir dir cfg
|
||||
r <- tryNonAsync (a clone)
|
||||
case r of
|
||||
Right () -> return ()
|
||||
|
@ -164,7 +167,9 @@ disconnectOrigin :: Assertion
|
|||
disconnectOrigin = boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "remote rm"
|
||||
|
||||
withgitrepo :: (FilePath -> Assertion) -> Assertion
|
||||
withgitrepo = bracket (setuprepo mainrepodir) return
|
||||
withgitrepo a = do
|
||||
maindir <- mainrepodir
|
||||
bracket (setuprepo maindir) return a
|
||||
|
||||
indir :: FilePath -> IO a -> IO a
|
||||
indir dir a = do
|
||||
|
@ -425,12 +430,13 @@ withTestMode testmode inittests = withResource prepare release . const
|
|||
where
|
||||
prepare = do
|
||||
setTestMode testmode
|
||||
setmainrepodir =<< newmainrepodir
|
||||
case tryIngredients [consoleTestReporter] mempty inittests of
|
||||
Nothing -> error "No tests found!?"
|
||||
Just act -> unlessM act $
|
||||
error "init tests failed! cannot continue"
|
||||
return ()
|
||||
release _ = cleanup mainrepodir
|
||||
release _ = noop
|
||||
|
||||
setTestMode :: TestMode -> IO ()
|
||||
setTestMode testmode = do
|
||||
|
@ -456,7 +462,6 @@ setTestMode testmode = do
|
|||
, ("GIT_ANNEX_USE_GIT_SSH", "1")
|
||||
, ("TESTMODE", show testmode)
|
||||
]
|
||||
|
||||
runFakeSsh :: [String] -> IO ()
|
||||
runFakeSsh ("-n":ps) = runFakeSsh ps
|
||||
runFakeSsh (_host:cmd:[]) = do
|
||||
|
@ -481,8 +486,24 @@ changeToTmpDir t = do
|
|||
tmpdir :: String
|
||||
tmpdir = ".t"
|
||||
|
||||
mainrepodir :: FilePath
|
||||
mainrepodir = tmpdir </> "repo"
|
||||
mainrepodir :: IO FilePath
|
||||
mainrepodir = Utility.Env.getEnvDefault "MAINREPODIR"
|
||||
(giveup "MAINREPODIR not set")
|
||||
|
||||
setmainrepodir :: FilePath -> IO ()
|
||||
setmainrepodir d = Utility.Env.Set.setEnv "MAINREPODIR" d True
|
||||
|
||||
newmainrepodir :: IO FilePath
|
||||
newmainrepodir = go (0 :: Int)
|
||||
where
|
||||
go n = do
|
||||
let d = tmpdir </> "main" ++ show n
|
||||
ifM (doesDirectoryExist d)
|
||||
( go $ n + 1
|
||||
, do
|
||||
createDirectory d
|
||||
return d
|
||||
)
|
||||
|
||||
tmprepodir :: IO FilePath
|
||||
tmprepodir = go (0 :: Int)
|
||||
|
|
|
@ -2,16 +2,13 @@ For some reason the test suite on windows is failing to set up the direct
|
|||
mode repo; git-annex direct fails because the repo is a v7 repo in adjusted
|
||||
unlocked mode.
|
||||
|
||||
It seems it's not running git-annex init with --version=5,
|
||||
or it does and it gets ignored.
|
||||
|
||||
I have not managed to reproduce this outside of the test suite.
|
||||
I wonder if perhaps the environment variable that the test suite sets
|
||||
to communicate with itself is not working on Windows, which sometimes
|
||||
has gotchas around environment variables. --[[Joey]]
|
||||
|
||||
Hmm, I reordered the direct mode tests to come first, and the failure went
|
||||
away. Think that .t/repo gets reused, and being already a v7 repo, git annex
|
||||
init --version=7 silently did not change it. (Made that error out.)
|
||||
So the test suite should use different paths for the base repo in each test
|
||||
pass.
|
||||
away. Think that .t/repo gets reused somehow, and being already a v7 repo,
|
||||
git annex init --version=7 silently did not change it. (Now it will error
|
||||
out instead.)
|
||||
|
||||
.t/repo is supposed to be deleted between each pass, but deleting
|
||||
directories on Windows is a fairly probabalistic venture. It would be
|
||||
better to use a different repo path for each pass. [[done]] --[[Joey]]
|
||||
|
|
Loading…
Add table
Reference in a new issue