Skip to content

Commit

Permalink
Fix HaddockKeepTmpsCustom test for merge skew
Browse files Browse the repository at this point in the history
The `HaddockKeepTmpsCustom` test added in #10392 skewed against #10366,
which changes where temporary files are written.

We can work around this by setting `$TMPDIR` and `$TEMP` while running
tests, so that temporary files are written to the test's temporary
directory rather than the system one.
  • Loading branch information
9999years committed Oct 4, 2024
1 parent ad439ea commit 183fe15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ main = cabalTest $ recordMode DoNotRecord $ withProjectFile "cabal.project" $ do
-- "foobar.ext" will be "fooXXX.ext".
let glob =
if isWindows
then "**/had*.txt"
else "**/haddock-response*.txt"
then "had*.txt"
else "haddock-response*.txt"

-- Check that there is a response file.
responseFiles <- assertGlobMatchesTestDir testDistDir glob
responseFiles <- assertGlobMatchesTestDir testTmpDir glob

-- Check that the matched response file is not empty, and is indeed a Haddock
-- response file.
Expand Down
4 changes: 4 additions & 0 deletions cabal-testsuite/src/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ runTestM mode m =
-- effect on Windows.
, ("CABAL_DIR", Just (testCabalDir env))
, ("CABAL_CONFIG", Just (testUserCabalConfigFile env))
-- Set `TMPDIR` so that temporary files aren't created in the global `TMPDIR`.
, ("TMPDIR", Just tmp_dir)
-- Windows uses `TEMP` for the `TMPDIR`.
, ("TEMP", Just tmp_dir)
],
testShouldFail = False,
testRelativeCurrentDir = ".",
Expand Down

0 comments on commit 183fe15

Please sign in to comment.