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
|
* init: When the repo is already initialized, and --version requests a
|
||||||
different version, error out rather than silently not changing the
|
different version, error out rather than silently not changing the
|
||||||
version.
|
version.
|
||||||
|
* Fix some test suite failures on Windows.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Thu, 01 Aug 2019 00:11:56 -0400
|
-- 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
|
innewrepo a = withgitrepo $ \r -> indir r a
|
||||||
|
|
||||||
inmainrepo :: Assertion -> Assertion
|
inmainrepo :: Assertion -> Assertion
|
||||||
inmainrepo = indir mainrepodir
|
inmainrepo a = do
|
||||||
|
d <- mainrepodir
|
||||||
|
indir d a
|
||||||
|
|
||||||
with_ssh_origin :: (Assertion -> Assertion) -> (Assertion -> Assertion)
|
with_ssh_origin :: (Assertion -> Assertion) -> (Assertion -> Assertion)
|
||||||
with_ssh_origin cloner a = cloner $ do
|
with_ssh_origin cloner a = cloner $ do
|
||||||
|
@ -151,7 +153,8 @@ withtmpclonerepo = withtmpclonerepo' newCloneRepoConfig
|
||||||
withtmpclonerepo' :: CloneRepoConfig -> (FilePath -> Assertion) -> Assertion
|
withtmpclonerepo' :: CloneRepoConfig -> (FilePath -> Assertion) -> Assertion
|
||||||
withtmpclonerepo' cfg a = do
|
withtmpclonerepo' cfg a = do
|
||||||
dir <- tmprepodir
|
dir <- tmprepodir
|
||||||
clone <- clonerepo mainrepodir dir cfg
|
maindir <- mainrepodir
|
||||||
|
clone <- clonerepo maindir dir cfg
|
||||||
r <- tryNonAsync (a clone)
|
r <- tryNonAsync (a clone)
|
||||||
case r of
|
case r of
|
||||||
Right () -> return ()
|
Right () -> return ()
|
||||||
|
@ -164,7 +167,9 @@ disconnectOrigin :: Assertion
|
||||||
disconnectOrigin = boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "remote rm"
|
disconnectOrigin = boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "remote rm"
|
||||||
|
|
||||||
withgitrepo :: (FilePath -> Assertion) -> Assertion
|
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 :: FilePath -> IO a -> IO a
|
||||||
indir dir a = do
|
indir dir a = do
|
||||||
|
@ -425,12 +430,13 @@ withTestMode testmode inittests = withResource prepare release . const
|
||||||
where
|
where
|
||||||
prepare = do
|
prepare = do
|
||||||
setTestMode testmode
|
setTestMode testmode
|
||||||
|
setmainrepodir =<< newmainrepodir
|
||||||
case tryIngredients [consoleTestReporter] mempty inittests of
|
case tryIngredients [consoleTestReporter] mempty inittests of
|
||||||
Nothing -> error "No tests found!?"
|
Nothing -> error "No tests found!?"
|
||||||
Just act -> unlessM act $
|
Just act -> unlessM act $
|
||||||
error "init tests failed! cannot continue"
|
error "init tests failed! cannot continue"
|
||||||
return ()
|
return ()
|
||||||
release _ = cleanup mainrepodir
|
release _ = noop
|
||||||
|
|
||||||
setTestMode :: TestMode -> IO ()
|
setTestMode :: TestMode -> IO ()
|
||||||
setTestMode testmode = do
|
setTestMode testmode = do
|
||||||
|
@ -456,7 +462,6 @@ setTestMode testmode = do
|
||||||
, ("GIT_ANNEX_USE_GIT_SSH", "1")
|
, ("GIT_ANNEX_USE_GIT_SSH", "1")
|
||||||
, ("TESTMODE", show testmode)
|
, ("TESTMODE", show testmode)
|
||||||
]
|
]
|
||||||
|
|
||||||
runFakeSsh :: [String] -> IO ()
|
runFakeSsh :: [String] -> IO ()
|
||||||
runFakeSsh ("-n":ps) = runFakeSsh ps
|
runFakeSsh ("-n":ps) = runFakeSsh ps
|
||||||
runFakeSsh (_host:cmd:[]) = do
|
runFakeSsh (_host:cmd:[]) = do
|
||||||
|
@ -481,8 +486,24 @@ changeToTmpDir t = do
|
||||||
tmpdir :: String
|
tmpdir :: String
|
||||||
tmpdir = ".t"
|
tmpdir = ".t"
|
||||||
|
|
||||||
mainrepodir :: FilePath
|
mainrepodir :: IO FilePath
|
||||||
mainrepodir = tmpdir </> "repo"
|
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 :: IO FilePath
|
||||||
tmprepodir = go (0 :: Int)
|
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
|
mode repo; git-annex direct fails because the repo is a v7 repo in adjusted
|
||||||
unlocked mode.
|
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 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
|
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
|
away. Think that .t/repo gets reused somehow, and being already a v7 repo,
|
||||||
init --version=7 silently did not change it. (Made that error out.)
|
git annex init --version=7 silently did not change it. (Now it will error
|
||||||
So the test suite should use different paths for the base repo in each test
|
out instead.)
|
||||||
pass.
|
|
||||||
|
.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
Add a link
Reference in a new issue