-
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.
- Add woops test - Regen expected output without duplication - Add "when using config from" tests - Remove unnecessary normalizeWindowsOutput - Change assertion message - Match on (\n|\r\n) for line endings - Note /tmp/cabal-testsuite-*/ not seen on Windows - Always have the project itself sort first - Use with-ghc.config with woops project - Remove docProjectConfigPaths - docProjectConfigFiles is the better name when not reporting "imported by" - Use --dry-run for config listing tests - Only use woops project once in tests - Don't use same project twice in tests - Put dedup test into its own folder - Simplify the project file names - Can be done now that the test is in its own folder - Move using config dedup test to ProjectImport dir - Remove an additional test on yops project - checking "using config from message" without URI imports - Add simple test for changelog - Better explain the message changes - Redo the test so the project doesn't sort 1st - Don't need to specify default project explicitly - Add a z-empty.config lexically sorted last
- Loading branch information
1 parent
124d471
commit 73a13f1
Showing
26 changed files
with
220 additions
and
6 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
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/ConditionalAndImport/with-ghc.config
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,7 @@ | ||
-- WARNING: Override the `with-compiler: ghc-x.y.z` of the stackage import, of | ||
-- https://www.stackage.org/nightly-yyyy-mm-dd/cabal.config. Otherwise tests | ||
-- will fail with: | ||
-- -Error: [Cabal-5490] | ||
-- -Cannot find the program 'ghc'. User-specified path 'ghc-x.y.z' does not | ||
-- refer to an executable and the program is not on the system path. | ||
with-compiler: ghc |
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/0.config
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,7 @@ | ||
import: cfg/1.config | ||
import: cfg/3.config | ||
import: cfg/5.config | ||
import: cfg/7.config | ||
import: cfg/9.config | ||
|
||
import: with-ghc.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/2.config
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,2 @@ | ||
import: cfg/3.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/4.config
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,2 @@ | ||
import: cfg/5.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/6.config
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,2 @@ | ||
import: cfg/7.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/8.config
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,2 @@ | ||
import: cfg/9.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
3 changes: 3 additions & 0 deletions
3
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/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,3 @@ | ||
# checking "using config from message" with URI imports | ||
# cabal v2-build | ||
# checking that package directories and locations are reported in order |
42 changes: 42 additions & 0 deletions
42
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/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,42 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest . recordMode RecordMarked $ do | ||
let log = recordHeader . pure | ||
|
||
log "checking \"using config from message\" with URI imports" | ||
out <- fails $ cabal' "v2-build" [ "all", "--dry-run", "--project-file=no-pkgs.project" ] | ||
|
||
-- Use assertRegex when the output is tainted by the temp directory, like | ||
-- this: | ||
-- | ||
-- When using configuration from: | ||
-- - /tmp/cabal-testsuite-282695/cabal.project | ||
-- - /tmp/cabal-testsuite-282695/2.config etc | ||
assertRegex | ||
"Project configuration with URI imports is listed in full" | ||
"When using configuration from:(\n|\r\n) \ | ||
\ .*no-pkgs\\.project(\n|\r\n) \ | ||
\ .*0\\.config(\n|\r\n) \ | ||
\ .*2\\.config(\n|\r\n) \ | ||
\ .*4\\.config(\n|\r\n) \ | ||
\ .*6\\.config(\n|\r\n) \ | ||
\ .*8\\.config(\n|\r\n) \ | ||
\ .*1\\.config(\n|\r\n) \ | ||
\ .*3\\.config(\n|\r\n) \ | ||
\ .*5\\.config(\n|\r\n) \ | ||
\ .*7\\.config(\n|\r\n) \ | ||
\ .*9\\.config(\n|\r\n) \ | ||
\ .*with-ghc\\.config(\n|\r\n) \ | ||
\ .*https://www.stackage.org/lts-21.25/cabal.config(\n|\r\n)" | ||
out | ||
|
||
log "checking that package directories and locations are reported in order" | ||
assertOutputContains | ||
"The following errors occurred: \ | ||
\ - The package directory 'no-pkg-1' does not contain any .cabal file. \ | ||
\ - The package location 'no-pkg-2-dir' does not exist. \ | ||
\ - The package directory 'no-pkg-3' does not contain any .cabal file. \ | ||
\ - The package location 'no-pkg-4-dir' does not exist." | ||
out | ||
|
||
return () |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cfg/1.config
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,2 @@ | ||
import: ../2.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cfg/3.config
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,2 @@ | ||
import: ../4.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cfg/5.config
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,2 @@ | ||
import: ../6.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cfg/7.config
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,2 @@ | ||
import: ../8.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cfg/9.config
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,2 @@ | ||
-- No imports here | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
...suite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/no-pkg-1/README.md
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,2 @@ | ||
There's intentionally no package here but the directory for the package exists | ||
so that the project can find it. |
2 changes: 2 additions & 0 deletions
2
...suite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/no-pkg-3/README.md
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,2 @@ | ||
There's intentionally no package here but the directory for the package exists | ||
so that the project can find it. |
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/no-pkgs.project
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,7 @@ | ||
packages: | ||
no-pkg-1 | ||
no-pkg-2-dir | ||
no-pkg-3 | ||
no-pkg-4-dir | ||
|
||
import: 0.config |
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/with-ghc.config
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,7 @@ | ||
-- WARNING: Override the `with-compiler: ghc-x.y.z` of the stackage import, of | ||
-- https://www.stackage.org/nightly-yyyy-mm-dd/cabal.config. Otherwise tests | ||
-- will fail with: | ||
-- -Error: [Cabal-5490] | ||
-- -Cannot find the program 'ghc'. User-specified path 'ghc-x.y.z' does not | ||
-- refer to an executable and the program is not on the system path. | ||
with-compiler: ghc |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/a-very-extra.config
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,2 @@ | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/an-extra.config
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,2 @@ | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/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 @@ | ||
# cabal v2-build |
9 changes: 9 additions & 0 deletions
9
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/cabal.project
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,9 @@ | ||
packages: no-pkg-dir | ||
import: z-empty.config | ||
import: an-extra.config | ||
import: an-extra.config | ||
import: a-very-extra.config | ||
import: a-very-extra.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: with-ghc.config |
24 changes: 24 additions & 0 deletions
24
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/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,24 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest . recordMode RecordMarked $ do | ||
let log = recordHeader . pure | ||
|
||
out <- fails $ cabal' "v2-build" [ "all", "--dry-run" ] | ||
|
||
-- Use assertRegex when the output is tainted by the temp directory, like | ||
-- this: | ||
-- | ||
-- When using configuration from: | ||
-- - /tmp/cabal-testsuite-282695/cabal.project | ||
assertRegex | ||
"Project configuration is listed in full and deduplicated" | ||
"When using configuration from:(\n|\r\n) \ | ||
\ .*cabal\\.project(\n|\r\n) \ | ||
\ .*a-very-extra\\.config(\n|\r\n) \ | ||
\ .*an-extra\\.config(\n|\r\n) \ | ||
\ .*with-ghc\\.config(\n|\r\n) \ | ||
\ .*z-empty\\.config(\n|\r\n) \ | ||
\ .*https://www.stackage.org/lts-21.25/cabal.config(\n|\r\n)" | ||
out | ||
|
||
return () |
7 changes: 7 additions & 0 deletions
7
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/with-ghc.config
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,7 @@ | ||
-- WARNING: Override the `with-compiler: ghc-x.y.z` of the stackage import, of | ||
-- https://www.stackage.org/nightly-yyyy-mm-dd/cabal.config. Otherwise tests | ||
-- will fail with: | ||
-- -Error: [Cabal-5490] | ||
-- -Cannot find the program 'ghc'. User-specified path 'ghc-x.y.z' does not | ||
-- refer to an executable and the program is not on the system path. | ||
with-compiler: ghc |
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromSimple/z-empty.config
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 @@ | ||
-- This file is intentionally empty, just this comment. |
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 |
---|---|---|
@@ -1,9 +1,82 @@ | ||
--- | ||
synopsis: Add an Ord instance for ProjectConfigPath | ||
synopsis: Deduplicate "using configuration from" message | ||
packages: [cabal-install-solver] | ||
prs: 10546 | ||
--- | ||
|
||
Add an `Ord` instance for `ProjectConfigPath` that sorts URIs after local paths | ||
and longer paths after shorter ones. Deduplicate the printing of "Configuration is | ||
affected by the following files" messages. | ||
## Using Configuration From Message Changes | ||
|
||
Deduplicates and sorts the list of configuration files and URIs printed with the | ||
"using configuration from" message. This message is shown when there's a build | ||
failure. We can trigger that message by using a non-existant package in the | ||
project, "no-pkg-dir". | ||
|
||
If an import is repeated in a `.project` or `.config` file it only imported once | ||
but if the same import is made from an imported file then it was being repeated | ||
in the message. Additional problems were not showing the project first and | ||
mixing configuration files and URIs together. | ||
|
||
* The test set up: | ||
|
||
``` | ||
$ cat cabal.project | ||
cat cabal.project | ||
packages: no-pkg-dir | ||
import: z-empty.config | ||
import: an-extra.config | ||
import: an-extra.config | ||
import: a-very-extra.config | ||
import: a-very-extra.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
|
||
$ cat an-extra.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
|
||
$ cat a-very-extra.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
import: https://www.stackage.org/lts-21.25/cabal.config | ||
|
||
$ cat z-empty.config | ||
- This file is intentionally empty, just this comment. | ||
``` | ||
|
||
* Before the fix: | ||
|
||
``` | ||
$ ~/.ghcup/bin/cabal-3.12.1.0 build all --dry-run | ||
When using configuration from: | ||
- a-very-extra.config | ||
- an-extra.config | ||
- cabal.project | ||
- https://www.stackage.org/lts-21.25/cabal.config | ||
- https://www.stackage.org/lts-21.25/cabal.config | ||
- https://www.stackage.org/lts-21.25/cabal.config | ||
- z-empty.config | ||
The following errors occurred: | ||
- The package location 'no-pkg-dir' does not exist. | ||
``` | ||
|
||
* After the fix: | ||
|
||
``` | ||
$ cabal build all --dry-run | ||
When using configuration from: | ||
- cabal.project | ||
- a-very-extra.config | ||
- an-extra.config | ||
- z-empty.config | ||
- https://www.stackage.org/lts-21.25/cabal.config | ||
The following errors occurred: | ||
- The package location 'no-pkg-dir' does not exist. | ||
``` | ||
|
||
## Ord ProjectConfigPath Instance Changes | ||
|
||
Adds a custom `Ord` instance for `ProjectConfigPath` that sorts URIs after local | ||
file paths and longer file paths after shorter ones as measured by the number of | ||
path segments. If still equal, then sorting is lexical. The project itself, a | ||
single element root path, compared to any of the configuration paths it imports, | ||
should always sort first. Comparing one project root path against another is | ||
done lexically. |