forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request haskell#10424 from 9999years/fix-tmpdir
Fix `HaddockKeepTmpsCustom` test for merge skew
- Loading branch information
Showing
3 changed files
with
27 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 20 additions & 14 deletions
34
cabal-testsuite/PackageTests/HaddockKeepsTmps/cabal.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
import Test.Cabal.Prelude | ||
import Data.List (sort, isPrefixOf) | ||
import Distribution.Verbosity | ||
import Data.List (isPrefixOf, sort) | ||
import Distribution.Simple.Glob | ||
import Distribution.Simple.Glob.Internal | ||
import Distribution.Simple.Utils | ||
import Distribution.Verbosity | ||
import System.Directory | ||
import Test.Cabal.Prelude | ||
|
||
-- Test that "cabal haddock" preserves temporary files | ||
-- We use haddock-keep-temp-file: True in the cabal.project. | ||
main = | ||
cabalTest $ recordMode DoNotRecord $ withProjectFile "cabal.project" $ do | ||
pwd <- testTmpDir <$> getTestEnv | ||
liftIO $ createDirectory (pwd </> "temp") | ||
withEnv [(if isWindows then "TMP" else "TMPDIR", Just $ pwd </> "temp")] $ | ||
cabal "haddock" [] | ||
files <- liftIO $ listDirectory (pwd </> "temp") | ||
case [ pwd </> "temp" </> f | f <- files, takeExtension f == ".txt" ] of | ||
[] -> error "Expecting a response file being mentioned in the outcome" | ||
files' -> | ||
-- Assert the matched response file is not empty, and indeed a haddock rsp | ||
assertAnyFileContains files' "--package-name" | ||
cabal "haddock" [] | ||
|
||
-- From the docs for `System.IO.openTempFile`: | ||
-- | ||
-- On Windows, the template prefix may be truncated to 3 chars, e.g. | ||
-- "foobar.ext" will be "fooXXX.ext". | ||
let glob = | ||
if isWindows | ||
then "had*.txt" | ||
else "haddock-response*.txt" | ||
|
||
-- Check that there is a response file. | ||
responseFiles <- assertGlobMatchesTestDir testTmpDir glob | ||
|
||
-- Check that the matched response file is not empty, and is indeed a Haddock | ||
-- response file. | ||
assertAnyFileContains responseFiles "--package-name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters