Skip to content

Commit

Permalink
Add trimmed down PackageTests/VersionPriority
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 31, 2023
1 parent 9cea7e9 commit 4c73bfc
Show file tree
Hide file tree
Showing 33 changed files with 720 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module Distribution.Client.ProjectConfig.Legacy

import Data.Coerce (coerce)
import Distribution.Client.Compat.Prelude
import GHC.Stack (HasCallStack)

import Distribution.Types.Flag (FlagName, parsecFlagAssignment)

Expand Down Expand Up @@ -313,7 +312,7 @@ parseProjectSkeleton srcImporters srcImportee cacheDir httpTransport verbosity s
addWarnings x' = x'
liftPR _ (ParseFailed e) = pure $ ParseFailed e

fetchImportConfig :: HasCallStack => ProjectConfigPath -> IO BS.ByteString
fetchImportConfig :: ProjectConfigPath -> IO BS.ByteString
fetchImportConfig = \case
(ProjectRoot (RootConfig root)) -> fetch root
(ProjectImport ImportedConfig{importee = Importee pci}) -> fetch pci
Expand Down
14 changes: 14 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/0-local.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/0-local.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/0-local.project requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
3 changes: 3 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/0-local.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages: .
constraints: hashable ==1.4.3.0
constraints: hashable ==1.4.2.0
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/0-local.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude

main = cabalTest . withRepo "repo" . withProjectFile "0-local.project" $ do
fails $ cabal "v2-build" ["--dry-run"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
constraints: hashable ==1.4.2.0
import: stackage-local.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
import: stackage-local.config
constraints: hashable ==1.4.2.0
28 changes: 28 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/1-local.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/1-local-constraints-import.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/1-local-constraints-import.project
+-- stackage-local.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/1-local-import-constraints.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/1-local-import-constraints.project
+-- stackage-local.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
9 changes: 9 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/1-local.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Test.Cabal.Prelude

testVersionWin project =
withProjectFile project $ do
fails $ cabal "v2-build" ["--dry-run"]

main = cabalTest . withRepo "repo" $ do
testVersionWin "1-local-constraints-import.project"
testVersionWin "1-local-import-constraints.project"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
constraints: hashable ==1.4.2.0
import: https://www.stackage.org/nightly-2023-12-07/cabal.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
import: https://www.stackage.org/nightly-2023-12-07/cabal.config
constraints: hashable ==1.4.2.0
28 changes: 28 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/1-web.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/1-web-constraints-import.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/1-web-constraints-import.project
+-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/1-web-import-constraints.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/1-web-import-constraints.project
+-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/1-web.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Test.Cabal.Prelude

testVersionWin project =
withProjectFile project $ do
fails $ cabal "v2-build" ["--dry-run"]

main = cabalTest . withRepo "repo" $ do
-- To avoid this diff:
-- -Build profile: -w ghc-9.6.3 -O1
-- +Build profile: -w ghc-<GHCVER> -O1
skipIfGhcVersion "== 9.6.3"
testVersionWin "1-web-constraints-import.project"
testVersionWin "1-web-import-constraints.project"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
constraints: hashable ==1.4.2.0
import: hop-local.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
import: hop-local.config
constraints: hashable ==1.4.2.0
30 changes: 30 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/2-local.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/2-local-constraints-import.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/2-local-constraints-import.project
+-- hop-local.config
+-- stackage-local.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/2-local-import-constraints.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/2-local-import-constraints.project
+-- hop-local.config
+-- stackage-local.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
9 changes: 9 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/2-local.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Test.Cabal.Prelude

testVersionWin project =
withProjectFile project $ do
fails $ cabal "v2-build" ["--dry-run"]

main = cabalTest . withRepo "repo" $ do
testVersionWin "2-local-constraints-import.project"
testVersionWin "2-local-import-constraints.project"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
constraints: hashable ==1.4.2.0
import: stackage-web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
import: stackage-web.config
constraints: hashable ==1.4.2.0
30 changes: 30 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/2-web.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/2-web-constraints-import.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/2-web-constraints-import.project
+-- stackage-web.config
+-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/2-web-import-constraints.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/2-web-import-constraints.project
+-- stackage-web.config
+-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/2-web.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Test.Cabal.Prelude

testVersionWin project =
withProjectFile project $ do
fails $ cabal "v2-build" ["--dry-run"]

main = cabalTest . withRepo "repo" $ do
-- To avoid this diff:
-- -Build profile: -w ghc-9.6.3 -O1
-- +Build profile: -w ghc-<GHCVER> -O1
skipIfGhcVersion "== 9.6.3"
testVersionWin "2-web-constraints-import.project"
testVersionWin "2-web-import-constraints.project"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
constraints: hashable ==1.4.2.0
import: hop-web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .
allow-newer: hashable:*
import: hop-web.config
constraints: hashable ==1.4.2.0
32 changes: 32 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/3-web.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# cabal v2-update
Downloading the latest package list from test-local-repo
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/3-web-constraints-import.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/3-web-constraints-import.project
+-- hop-web.config
+-- stackage-web.config
+-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
# cabal v2-build
Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] trying: cabal-version-override-0.1.0.0 (user goal)
[__1] next goal: hashable (dependency of cabal-version-override)
[__1] rejecting: hashable-1.4.3.0 (constraint from project requires ==1.4.2.0)
+-- <ROOT>/3-web-import-constraints.project requires ==1.4.2.0
[__1] rejecting: hashable-1.4.2.0 (constraint from project requires ==1.4.3.0)
+-- <ROOT>/3-web-import-constraints.project
+-- hop-web.config
+-- stackage-web.config
+-- https://www.stackage.org/nightly-2023-12-07/cabal.config requires ==1.4.3.0
[__1] fail (backjumping, conflict set: cabal-version-override, hashable)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: hashable (3), cabal-version-override (2)
13 changes: 13 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/3-web.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Test.Cabal.Prelude

testVersionWin project =
withProjectFile project $ do
fails $ cabal "v2-build" ["--dry-run"]

main = cabalTest . withRepo "repo" $ do
-- To avoid this diff:
-- -Build profile: -w ghc-9.6.3 -O1
-- +Build profile: -w ghc-<GHCVER> -O1
skipIfGhcVersion "== 9.6.3"
testVersionWin "3-web-constraints-import.project"
testVersionWin "3-web-import-constraints.project"
51 changes: 51 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Version Priority Tests

The `1-` prefix projects have an import depth of 1, the `2-` prefix projects
have a depth of 2 and `3-` prefix has depth 3. The `0-` prefix project have any
imports. Only projects have the `.project` extension. Imported configuration
has a `.config` extension.

- *0-local.project*
```
.
└── 0-local.project
```
- *1-local.project*
```
.
└── 1-local.project
└── stackage-local.config
```
- *2-local.project*
```
.
└── 2-local.project
└── hop-local.config
└── stackage-local.config
```
- *1-web.project*
```
.
└── 1-web.project
└── https://www.stackage.org/nightly-2023-12-07/cabal.config
```
- *2-web.project*
```
.
└── 2-web.project
└── stackage-web.config
└── https://www.stackage.org/nightly-2023-12-07/cabal.config
```
- *3-web.project*
```
.
└── 3-web.project
└── hop-web.config
└── stackage-web.config
└── https://www.stackage.org/nightly-2023-12-07/cabal.config
```
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/VersionPriority/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main where

import Data.Hashable

main :: IO ()
main = print $ hash "foo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: 3.0
name: cabal-version-override
version: 0.1.0.0
license: MPL-2.0
author: Phil de Joux
category: Development
build-type: Simple

common warnings
ghc-options: -Wall

executable cabal-version-override
import: warnings
main-is: Main.hs
build-depends: base, hashable
hs-source-dirs: app
default-language: Haskell2010
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import: stackage-local.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import: stackage-web.config
Loading

0 comments on commit 4c73bfc

Please sign in to comment.