Skip to content

Commit 5dae4e4

Browse files
authored
Merge pull request #10392 from MercuryTechnologies/wiggles/add-haddock-keep-temp-files-test
Add `haddock --keep-temp-files` test
2 parents c14bcfe + b0b6abd commit 5dae4e4

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Distribution.Simple
2+
3+
main = defaultMain
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Simple where
2+
3+
-- | For hiding needles.
4+
data Haystack = Haystack
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages: .
2+
3+
haddock-keep-temp-files: true
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Test that "cabal haddock" preserves temporary files
4+
-- We use haddock-keep-temp-file: True in the cabal.project.
5+
main = cabalTest $ recordMode DoNotRecord $ withProjectFile "cabal.project" $ do
6+
cabal "haddock" []
7+
8+
-- From the docs for `System.IO.openTempFile`:
9+
--
10+
-- On Windows, the template prefix may be truncated to 3 chars, e.g.
11+
-- "foobar.ext" will be "fooXXX.ext".
12+
let glob =
13+
if isWindows
14+
then "**/had*.txt"
15+
else "**/haddock-response*.txt"
16+
17+
-- Check that there is a response file.
18+
responseFiles <- assertGlobMatchesTestDir testDistDir glob
19+
20+
-- Check that the matched response file is not empty, and is indeed a Haddock
21+
-- response file.
22+
assertAnyFileContains responseFiles "--package-name"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cabal-version: 3.0
2+
name: HaddockKeepsTmpsCustom
3+
version: 0.1
4+
license: BSD-3-Clause
5+
author: Rodrigo Mesquita
6+
stability: stable
7+
category: PackageTests
8+
build-type: Custom
9+
10+
custom-setup
11+
setup-depends: Cabal, base
12+
13+
library
14+
default-language: Haskell2010
15+
exposed-modules: Simple
16+
build-depends: base

0 commit comments

Comments
 (0)