-
Notifications
You must be signed in to change notification settings - Fork 748
Hooks: use the appropriate Cabal unit ID #11429
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
6 changes: 6 additions & 0 deletions
6
cabal-testsuite/PackageTests/SetupHooks/T11331/Cabal-bad/Cabal.cabal
This file contains hidden or 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,6 @@ | ||
| cabal-version: 2.4 | ||
| name: Cabal | ||
| version: 3.16.666.0 | ||
| library | ||
| default-language: Haskell2010 | ||
| build-depends: stub == 0.1 |
10 changes: 10 additions & 0 deletions
10
cabal-testsuite/PackageTests/SetupHooks/T11331/Cabal-good/Cabal.cabal
This file contains hidden or 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 @@ | ||
| cabal-version: 2.4 | ||
| name: Cabal | ||
| version: 3.16.777.0 | ||
| library | ||
| default-language: Haskell2010 | ||
| build-depends: base, stub == 0.2 | ||
| exposed-modules: | ||
| Distribution.Simple.SetupHooks | ||
| Distribution.Simple | ||
| hs-source-dirs: src |
13 changes: 13 additions & 0 deletions
13
cabal-testsuite/PackageTests/SetupHooks/T11331/Cabal-good/src/Distribution/Simple.hs
This file contains hidden or 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 @@ | ||
| module Distribution.Simple ( defaultMainWithSetupHooks ) where | ||
|
|
||
| import System.Exit ( exitFailure ) | ||
| import Distribution.Simple.SetupHooks ( SetupHooks ) | ||
|
|
||
| defaultMainWithSetupHooks :: SetupHooks -> IO () | ||
| defaultMainWithSetupHooks _ = do | ||
| putStrLn "Chosen GOOD Cabal" | ||
| exitFailure | ||
| -- NB: we call 'exitFailure' here so that cabal-install, who is invoking | ||
| -- this code thinking it is building the package, doesn't try to proceed | ||
| -- when actually we haven't done anything (e.g. try to read a package | ||
| -- description file). |
3 changes: 3 additions & 0 deletions
3
...testsuite/PackageTests/SetupHooks/T11331/Cabal-good/src/Distribution/Simple/SetupHooks.hs
This file contains hidden or 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 Distribution.Simple.SetupHooks where | ||
|
|
||
| data SetupHooks = SetupHooks |
This file contains hidden or 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,14 @@ | ||
| {-# LANGUAGE NoImplicitPrelude #-} | ||
|
|
||
| module Main where | ||
|
|
||
| -- Cabal | ||
| import Distribution.Simple ( defaultMainWithSetupHooks ) | ||
|
|
||
| -- T11331 | ||
| import SetupHooks ( setupHooks ) | ||
|
|
||
| -------------------------------------------------------------------------------- | ||
|
|
||
| main :: IO () | ||
| main = defaultMainWithSetupHooks setupHooks |
This file contains hidden or 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 SetupHooks (setupHooks) where | ||
|
|
||
| -- fancy-hooks | ||
| import FancyHooks (setupHooks) |
18 changes: 18 additions & 0 deletions
18
cabal-testsuite/PackageTests/SetupHooks/T11331/T11331.cabal
This file contains hidden or 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,18 @@ | ||
| cabal-version: 3.14 | ||
| name: T11331 | ||
| version: 0.1.0.0 | ||
| synopsis: Test for Cabal bug 11331 | ||
| license: BSD-3-Clause | ||
| author: NA | ||
| maintainer: NA | ||
| category: Testing | ||
| build-type: Hooks | ||
|
|
||
| custom-setup | ||
| setup-depends: fancy-hooks | ||
|
|
||
| library | ||
| default-language: Haskell2010 | ||
| build-depends: stub == 0.1 | ||
|
|
||
| -- See cabal.test.hs for explanation of this test. |
This file contains hidden or 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: . |
56 changes: 56 additions & 0 deletions
56
cabal-testsuite/PackageTests/SetupHooks/T11331/cabal.test.hs
This file contains hidden or 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,56 @@ | ||
| import Test.Cabal.Prelude | ||
|
|
||
| {- Test for https://github.com/haskell/cabal/issues/11331 | ||
|
|
||
| This test works by having a package database with two Cabal libraries in it, | ||
| a good one (Cabal-good) and a poisoned one (Cabal-bad). | ||
|
|
||
| Cabal-good depends on stub == 0.2 and Cabal-bad depends on stub == 0.1. | ||
|
|
||
| Moreover, we have a fancy-hooks package in the package database, that has been | ||
| built against Cabal-good. | ||
|
|
||
| T11331 has the following Cabal file: | ||
|
|
||
| T11331.setup --> fancy-hooks | ||
| T11331.lib --> stub == 0.1 | ||
|
|
||
| The test checks that, for the setup component, we correctly use Cabal-good | ||
| and not Cabal-bad, as only Cabal-good is compatible with fancy-hooks (correct | ||
| ABI hash of Cabal dependency). | ||
| -} | ||
| main :: IO () | ||
| main = cabalTest $ recordMode DoNotRecord $ withPackageDb $ do | ||
| -- Build good package set 'fancy-hooks -> Cabal-good -> stub-0.2' first. | ||
| withDirectory "stub-0.2" $ do | ||
| setup "configure" [] | ||
| setup "build" [] | ||
| setup "register" ["--inplace"] | ||
| withDirectory "Cabal-good" $ do | ||
| setup "configure" [] | ||
| setup "build" [] | ||
| setup "register" ["--inplace"] | ||
| withDirectory "fancy-hooks" $ do | ||
| setup "configure" [] | ||
| setup "build" [] | ||
| setup "register" ["--inplace"] | ||
|
|
||
| -- Now build bad package set 'Cabal-bad -> stub-0.1'. | ||
| withDirectory "stub-0.1" $ do | ||
| setup "configure" [] | ||
| setup "build" [] | ||
| setup "register" ["--inplace"] | ||
| withDirectory "Cabal-bad" $ do | ||
| setup "configure" [] | ||
| setup "build" [] | ||
| setup "register" ["--inplace"] | ||
|
|
||
| -- Now try to build 'T11331' with cabal-install, using the package database | ||
| -- that we carefully crafted above. This tests that cabal-install picks | ||
| -- 'Cabal-good' for the setup component of 'T11331', otherwise we will fail. | ||
| dbDir <- testPackageDbDir <$> getTestEnv | ||
|
|
||
| -- This fails because the fake Cabal-good defaultMain doesn't do anything | ||
|
sheaf marked this conversation as resolved.
|
||
| -- except print "Chosen GOOD Cabal". | ||
| res <- fails $ cabal' "build" [ "--package-db=" ++ dbDir, "T11331" ] | ||
|
sheaf marked this conversation as resolved.
|
||
| assertOutputContains "Chosen GOOD Cabal" res | ||
8 changes: 8 additions & 0 deletions
8
cabal-testsuite/PackageTests/SetupHooks/T11331/fancy-hooks/fancy-hooks.cabal
This file contains hidden or 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,8 @@ | ||
| cabal-version: 2.4 | ||
| name: fancy-hooks | ||
| version: 1.0 | ||
| library | ||
| default-language: Haskell2010 | ||
| build-depends: Cabal | ||
| exposed-modules: FancyHooks | ||
| hs-source-dirs: src |
8 changes: 8 additions & 0 deletions
8
cabal-testsuite/PackageTests/SetupHooks/T11331/fancy-hooks/src/FancyHooks.hs
This file contains hidden or 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,8 @@ | ||
| {-# LANGUAGE NoImplicitPrelude #-} | ||
|
|
||
| module FancyHooks ( setupHooks ) where | ||
|
|
||
| import Distribution.Simple.SetupHooks ( SetupHooks(..) ) | ||
|
|
||
| setupHooks :: SetupHooks | ||
| setupHooks = SetupHooks |
5 changes: 5 additions & 0 deletions
5
cabal-testsuite/PackageTests/SetupHooks/T11331/stub-0.1/stub.cabal
This file contains hidden or 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,5 @@ | ||
| cabal-version: 2.4 | ||
| name: stub | ||
| version: 0.1 | ||
| library | ||
| default-language: Haskell2010 |
5 changes: 5 additions & 0 deletions
5
cabal-testsuite/PackageTests/SetupHooks/T11331/stub-0.2/stub.cabal
This file contains hidden or 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,5 @@ | ||
| cabal-version: 2.4 | ||
| name: stub | ||
| version: 0.2 | ||
| library | ||
| default-language: Haskell2010 |
This file contains hidden or 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 @@ | ||
| --- | ||
| synopsis: Ensure consistency of `Cabal` version for `SetupHooks` | ||
| packages: [cabal-install] | ||
| prs: 11429 | ||
| issues: 11331 | ||
| --- | ||
|
|
||
| When building a package with `build-type: Hooks`, we build an executable which | ||
| is invoked during the build process to perform build steps. This executable | ||
| needs to be linked against the `Cabal` library, therefore we now add a | ||
| dependency on `Cabal` when solving dependencies for the setup stanza. | ||
|
|
||
| This fixes a bug which resulted in the solver choosing two inconsistent versions | ||
| of the `Cabal` library, avoiding strange error messages like: | ||
|
|
||
| ``` | ||
| SetupHooks.hs: error: [GHC-83865] | ||
| • Couldn't match expected type ‘Distribution.Verbosity.Verbosity’ | ||
| with actual type ‘Verbosity’ | ||
| NB: ‘Distribution.Verbosity.Verbosity’ | ||
| is defined in ‘Distribution.Verbosity’ in package ‘Cabal-3.16.0.0’ | ||
| ‘Verbosity’ | ||
| is defined in ‘Distribution.Verbosity’ in package ‘Cabal-3.16.0.0’ | ||
| ``` | ||
|
|
||
| where the error is that there are two different unit IDs for `Cabal` being | ||
| passed when compiling the `SetupHooks` module. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.