-
Notifications
You must be signed in to change notification settings - Fork 696
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix assertion failure when combining build-tool-depends and --enable-…
…documentation The `setDocumentation` function was modifying the elaborated package after the hash was computed. This led to the assertion failing as the computed hash was different to what was computed in the initial install plan. Therefore in order to fix this we either needed to: 1. Set elabBuildHaddocks = False at the point where the hash is initially computed. 2. Verify that elabBuildHaddocks = True will not lead to unexpected results. The latter has been implemented. The elabBuildHaddocks option is only consulted in `hasValidHaddockTargets`, at which point documentation building the executable component is disabled because elabHaddockExecutables is False. In the added test we ensure this by checking that we didn't build documentation for the executable which is built because of build-tool-depends. Fixes #6006 #8313
- Loading branch information
1 parent
2dad49a
commit bccd4ec
Showing
10 changed files
with
101 additions
and
26 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: a | ||
version: 0.1.0.0 | ||
build-type: Simple | ||
cabal-version: >= 1.10 | ||
|
||
library | ||
exposed-modules: MyLib | ||
build-depends: base, lib | ||
hs-source-dirs: src | ||
default-language: Haskell2010 |
27 changes: 27 additions & 0 deletions
27
cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.out
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# cabal v2-update | ||
Downloading the latest package list from test-local-repo | ||
# cabal build | ||
Resolving dependencies... | ||
Build profile: -w ghc-<GHCVER> -O1 | ||
In order, the following will be built: | ||
- exe-1 (exe:exe) (requires build) | ||
- lib-1 (lib) (requires build) | ||
- a-0.1.0.0 (lib) (first run) | ||
Configuring executable 'exe' for exe-1... | ||
Preprocessing executable 'exe' for exe-1... | ||
Building executable 'exe' for exe-1... | ||
Installing executable exe in <PATH> | ||
Warning: The directory <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>/incoming/new-<RAND><ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>/<PACKAGE>-<HASH>/bin is not in the system search path. | ||
Configuring library for lib-1... | ||
Preprocessing library for lib-1... | ||
Building library for lib-1... | ||
Preprocessing library for lib-1... | ||
Running Haddock on library for lib-1... | ||
Documentation created: dist/doc/html/lib/ | ||
Installing library in <PATH> | ||
Configuring library for a-0.1.0.0... | ||
Preprocessing library for a-0.1.0.0... | ||
Building library for a-0.1.0.0... | ||
Preprocessing library for a-0.1.0.0... | ||
Running Haddock on library for a-0.1.0.0... | ||
Documentation created: <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/a-0.1.0.0/doc/html/a/ |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: . |
22 changes: 22 additions & 0 deletions
22
cabal-testsuite/PackageTests/HaddockBuildDepends/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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Test.Cabal.Prelude | ||
|
||
|
||
main = cabalTest . withRepo "repo" $ do | ||
cabal "build" ["--enable-documentation"] | ||
|
||
env <- getTestEnv | ||
let storeDir = testCabalDir env </> "store" | ||
|
||
-- Check properties of executable component | ||
libDir <- liftIO $ findDependencyInStore storeDir "exe" | ||
-- Documentation is enabled.. | ||
assertFileDoesContain (libDir </> "cabal-hash.txt") "documentation: True" | ||
-- But not built | ||
shouldDirectoryNotExist ( libDir </> "share" </> "doc" ) | ||
|
||
-- Check properties of library | ||
libDir <- liftIO $ findDependencyInStore storeDir "lib" | ||
-- Documentation is enabled.. | ||
assertFileDoesContain (libDir </> "cabal-hash.txt") "documentation: True" | ||
-- and has been built | ||
shouldDirectoryExist ( libDir </> "share" </> "doc" ) |
3 changes: 3 additions & 0 deletions
3
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/Main.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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Main where | ||
|
||
main = return () |
12 changes: 12 additions & 0 deletions
12
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/exe.cabal
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: exe | ||
version: 1 | ||
license: BSD3 | ||
author: Edward Z. Yang | ||
maintainer: [email protected] | ||
build-type: Simple | ||
cabal-version: 2.0 | ||
|
||
executable exe | ||
build-depends: base | ||
main-is: Main.hs | ||
default-language: Haskell2010 |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/Lib.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module Lib where |
13 changes: 13 additions & 0 deletions
13
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/lib.cabal
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: lib | ||
version: 1 | ||
license: BSD3 | ||
author: Edward Z. Yang | ||
maintainer: [email protected] | ||
build-type: Simple | ||
cabal-version: 2.0 | ||
|
||
library | ||
build-depends: base | ||
build-tool-depends: exe:exe | ||
exposed-modules: Lib | ||
default-language: Haskell2010 |
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/HaddockBuildDepends/src/MyLib.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module MyLib (someFunc) where | ||
|
||
someFunc :: IO () | ||
someFunc = return () |