Fix assertion failure when combining build-tool-depends and --enable-documentation
commitad96c424780890f0b4a101cb08dcb737b0d611eb
authorMatthew Pickering <matthewtpickering@gmail.com>
Tue, 14 Nov 2023 11:05:04 +0000 (14 11:05 +0000)
committerMikolaj <281893+Mikolaj@users.noreply.github.com>
Thu, 23 Nov 2023 14:27:12 +0000 (23 14:27 +0000)
tree9fe885b65a795209758da2b38ee3d4875dafb4d0
parent4d85411bf05cc32d6d9039d3516ed9912f2f36e0
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
cabal-install/src/Distribution/Client/ProjectPlanning.hs
cabal-testsuite/PackageTests/HaddockBuildDepends/a.cabal [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.out [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.project [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.test.hs [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/Main.hs [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/exe.cabal [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/Lib.hs [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/lib.cabal [new file with mode: 0644]
cabal-testsuite/PackageTests/HaddockBuildDepends/src/MyLib.hs [new file with mode: 0644]