summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-04-20 15:27:59 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-04-20 15:27:59 -0400
commit1c30c81a9eba6e12a1acf9054a4a07e959a39362 (patch)
tree7e2701cc1018b17e2feb7a374d0f9be70f537469 /Test.hs
parent635a524ebc3cdfcfd27871466d0eaa21467055ad (diff)
use a separate tmp dir for the test home
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/Test.hs b/Test.hs
index 7a5a9aeaa..a98a3df3b 100644
--- a/Test.hs
+++ b/Test.hs
@@ -110,9 +110,8 @@ optParser = TestOptions
)
runner :: Maybe (TestOptions -> IO ())
-runner = Just $ \opts -> do
+runner = Just $ \opts -> isolateGitConfig $ do
ensuretmpdir
- isolateGitConfig
crippledfilesystem <- Annex.Init.probeCrippledFileSystem' tmpdir
case tryIngredients ingredients (tastyOptionSet opts) (tests crippledfilesystem opts) of
Nothing -> error "No tests found!?"
@@ -1790,14 +1789,13 @@ ensuretmpdir = do
createDirectory tmpdir
{- Prevent global git configs from affecting the test suite. -}
-isolateGitConfig :: IO ()
-isolateGitConfig = do
- let tmphome = tmpdir </> "home"
- createDirectoryIfMissing False tmphome
+isolateGitConfig :: IO a -> IO a
+isolateGitConfig a = Utility.Tmp.withTmpDir "testhome" $ \tmphome -> do
tmphomeabs <- absPath tmphome
Utility.Env.setEnv "HOME" tmphomeabs True
Utility.Env.setEnv "XDG_CONFIG_HOME" tmphomeabs True
Utility.Env.setEnv "GIT_CONFIG_NOSYSTEM" "1" True
+ a
cleanup :: FilePath -> IO ()
cleanup = cleanup' False