Skip to content
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

Log package hash inputs file and contents / regression test for #6906 #7759

Merged
merged 10 commits into from
Oct 18, 2021
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
16 changes: 13 additions & 3 deletions cabal-install/src/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Lazy.Char8 as LBS.Char8

import Control.Exception (Handler (..), SomeAsyncException, assert, catches, handle)
import System.Directory (canonicalizePath, createDirectoryIfMissing, doesDirectoryExist, doesFileExist, removeFile, renameDirectory)
Expand Down Expand Up @@ -1016,9 +1017,18 @@ buildAndInstallUnpackedPackage verbosity
-- https://github.com/haskell/cabal/issues/4130
createDirectoryIfMissingVerbose verbosity True entryDir

LBS.writeFile
(entryDir </> "cabal-hash.txt")
(renderPackageHashInputs (packageHashInputs pkgshared pkg))
let hashFileName = entryDir </> "cabal-hash.txt"
outPkgHashInputs = renderPackageHashInputs (packageHashInputs pkgshared pkg)

info verbosity $
"creating file with the inputs used to compute the package hash: " ++ hashFileName

LBS.writeFile hashFileName outPkgHashInputs

debug verbosity "Package hash inputs:"
jneira marked this conversation as resolved.
Show resolved Hide resolved
traverse_
(debug verbosity . ("> " ++))
(lines $ LBS.Char8.unpack outPkgHashInputs)

-- Ensure that there are no files in `tmpDir`, that are
-- not in `entryDir`. While this breaks the
Expand Down
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T6906/cabal.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extra-include-dirs: foo
extra-lib-dirs: bar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
9 changes: 9 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T6906/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Test.Cabal.Prelude

main = cabalTest $ do
res <- cabalG' ["--config=cabal.config"] "v2-install" ["-v3"]
assertOutputContains "creating file with the inputs used to compute the package hash:" res
assertOutputContains "extra-lib-dirs: bar" res
expectBroken 6906 $ assertOutputDoesNotContain "extra-lib-dirs: bar bar" res
assertOutputContains "extra-include-dirs: foo" res
expectBroken 6906 $ assertOutputDoesNotContain "extra-include-dirs: foo foo" res
12 changes: 12 additions & 0 deletions cabal-testsuite/PackageTests/Regression/T6906/issue6906.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cabal-version: 3.0
name: issue6906
version: 0
synopsis: No duplicate entries for extra-*-dirs config options in the inputs used to compute the package hash
description: When informed in the global config
author: Javier Neira
category: Tests
maintainer: [email protected]

executable issue6906
build-depends: base
main-is: main.hs
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/Regression/T6906/main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = putStrLn "Hello issue6906"