Commit fcc5382c authored by kristenk's avatar kristenk Committed by Mikhail Glushenkov
Browse files

Set CABAL_DIR in cabal-tests (fixes #5187).

This change gives each test a new cabal directory on Windows and prevents the
tests from accessing the user's cabal directory.

This commit also re-enables
PackageTests/Regression/T4154/install-time-with-constraint.test.hs on Windows.
parent a343dee1
......@@ -8,5 +8,5 @@ main = cabalTest $ do
-- database, don't record the output
recordMode DoNotRecord $ do
-- TODO: Hack, delete me
withEnvFilter (/= "HOME") $ do
withEnvFilter (`notElem` ["HOME", "CABAL_DIR"]) $ do
cabal "new-build" ["all"]
......@@ -5,7 +5,7 @@ main = cabalTest $ do
-- Regression test for #4393
recordMode DoNotRecord $ do
-- TODO: Hack; see also CustomDep/cabal.test.hs
withEnvFilter (/= "HOME") $ do
withEnvFilter (`notElem` ["HOME", "CABAL_DIR"]) $ do
-- On -v2, we don't have vQuiet set, which suppressed
-- the error
cabal "new-build" ["-v1"]
......@@ -5,9 +5,6 @@ import Test.Cabal.Prelude
-- building its setup script with the installed Cabal, which depends on the
-- installed time, even though the installed time doesn't fit the constraint.
main = cabalTest $ do
-- TODO: Run this test on Windows once #5187 is resolved.
skipIf =<< isWindows
cabal "new-build" ["time", "--constraint=time==99999", "--dry-run"]
-- Temporarily disabled recording here because output is not stable
......
......@@ -31,12 +31,12 @@ module Test.Cabal.Monad (
testPrefixDir,
testDistDir,
testPackageDbDir,
testHomeDir,
testSandboxDir,
testSandboxConfigFile,
testRepoDir,
testKeysDir,
testSourceCopyDir,
testCabalDir,
testUserCabalConfigFile,
testActualFile,
-- * Skipping tests
......@@ -318,7 +318,10 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
-- Try to avoid Unicode output
[ ("LC_ALL", Just "C")
-- Hermetic builds (knot-tied)
, ("HOME", Just (testHomeDir env))],
, ("HOME", Just (testHomeDir env))
-- Set CABAL_DIR in addition to HOME, since HOME has no
-- effect on Windows.
, ("CABAL_DIR", Just (testCabalDir env))],
testShouldFail = False,
testRelativeCurrentDir = ".",
testHavePackageDb = False,
......@@ -345,7 +348,7 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
-- the default configuration hardcodes Hackage, which we do
-- NOT want to assume for these tests (no test should
-- hit Hackage.)
liftIO $ createDirectoryIfMissing True (testHomeDir env </> ".cabal")
liftIO $ createDirectoryIfMissing True (testCabalDir env)
ghc_path <- programPathM ghcProgram
liftIO $ writeFile (testUserCabalConfigFile env)
$ unlines [ "with-compiler: " ++ ghc_path ]
......@@ -645,10 +648,13 @@ testKeysDir env = testWorkDir env </> "keys"
testSourceCopyDir :: TestEnv -> FilePath
testSourceCopyDir env = testWorkDir env </> "source"
-- | The user cabal directory
testCabalDir :: TestEnv -> FilePath
testCabalDir env = testHomeDir env </> ".cabal"
-- | The user cabal config file
-- TODO: Not obviously working on Windows
testUserCabalConfigFile :: TestEnv -> FilePath
testUserCabalConfigFile env = testHomeDir env </> ".cabal" </> "config"
testUserCabalConfigFile env = testCabalDir env </> "config"
-- | The file where the expected output of the test lives
testExpectFile :: TestEnv -> FilePath
......
......@@ -512,7 +512,7 @@ withRepo repo_dir m = do
hackageRepoTool "bootstrap" ["--keys", testKeysDir env, "--repo", testRepoDir env]
-- 5. Wire it up in .cabal/config
-- TODO: libify this
let package_cache = testHomeDir env </> ".cabal" </> "packages"
let package_cache = testCabalDir env </> "packages"
liftIO $ appendFile (testUserCabalConfigFile env)
$ unlines [ "repository test-local-repo"
, " url: file:" ++ testRepoDir env
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment