Skip to content

Add haddock --keep-temp-files test #10392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cabal-testsuite/PackageTests/HaddockKeepTmpsCustom/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Distribution.Simple

main = defaultMain
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/HaddockKeepTmpsCustom/Simple.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Simple where

-- | For hiding needles.
data Haystack = Haystack
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages: .

haddock-keep-temp-files: true
22 changes: 22 additions & 0 deletions cabal-testsuite/PackageTests/HaddockKeepTmpsCustom/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
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 testDistDir glob

-- Check that the matched response file is not empty, and is indeed a Haddock
-- response file.
assertAnyFileContains responseFiles "--package-name"
16 changes: 16 additions & 0 deletions cabal-testsuite/PackageTests/HaddockKeepTmpsCustom/my.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cabal-version: 3.0
name: HaddockKeepsTmpsCustom
version: 0.1
license: BSD-3-Clause
author: Rodrigo Mesquita
stability: stable
category: PackageTests
build-type: Custom

custom-setup
setup-depends: Cabal, base

library
default-language: Haskell2010
exposed-modules: Simple
build-depends: base
Loading