Skip to content

Commit

Permalink
Add verbatim *.expect.txt expectations
Browse files Browse the repository at this point in the history
- Add oops.expect.txt
- Add cabal-missing-package.expect.txt
- Add hops.expect.txt
- Add DedupUsingConfigFromComplex/errors.expect.txt
- Add using configuration from to errors.expect.txt
  • Loading branch information
philderbeast committed Jan 1, 2025
1 parent 10bb996 commit 24af359
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 118 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
When using configuration from:
- cabal-missing-package.project
- missing/pkgs.config
- missing/pkgs/default.config
The following errors occurred:
- The package location 'pkg-doesnt-exist' does not exist.
91 changes: 7 additions & 84 deletions cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Test.Cabal.Prelude
import Test.Cabal.OutputNormalizer
import Data.Function ((&))
import Data.Functor ((<&>))

main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
let log = recordHeader . pure
Expand Down Expand Up @@ -111,64 +112,8 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
log "checking that imports work skipping into a subfolder and then back out again and again"
hopping <- cabal' "v2-build" [ "--project-file=hops-0.project" ]

"Configuration is affected by the following files:\n\
\- hops-0.project\n\
\- hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops-4.config\n\
\ imported by: hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops-6.config\n\
\ imported by: hops/hops-5.config\n\
\ imported by: hops-4.config\n\
\ imported by: hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops-8.config\n\
\ imported by: hops/hops-7.config\n\
\ imported by: hops-6.config\n\
\ imported by: hops/hops-5.config\n\
\ imported by: hops-4.config\n\
\ imported by: hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops/hops-5.config\n\
\ imported by: hops-4.config\n\
\ imported by: hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops/hops-7.config\n\
\ imported by: hops-6.config\n\
\ imported by: hops/hops-5.config\n\
\ imported by: hops-4.config\n\
\ imported by: hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project\n\
\- hops/hops-9.config\n\
\ imported by: hops-8.config\n\
\ imported by: hops/hops-7.config\n\
\ imported by: hops-6.config\n\
\ imported by: hops/hops-5.config\n\
\ imported by: hops-4.config\n\
\ imported by: hops/hops-3.config\n\
\ imported by: hops-2.config\n\
\ imported by: hops/hops-1.config\n\
\ imported by: hops-0.project"
& normalizeWindowsOutput
& flip (assertOn multilineNeedleHaystack) hopping
readVerbatimFile "hops.expect.txt" >>=
flip (assertOn multilineNeedleHaystack) hopping . normalizeWindowsOutput

-- The project is named oops as it is like hops but has conflicting constraints.
-- +-- oops-0.project
Expand All @@ -184,24 +129,8 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
log "checking conflicting constraints skipping into a subfolder and then back out again and again"
oopsing <- fails $ cabal' "v2-build" [ "all", "--project-file=oops-0.project" ]

"Could not resolve dependencies:\n\
\[__0] trying: oops-0.1 (user goal)\n\
\[__1] next goal: hashable (dependency of oops)\n\
\[__1] rejecting: hashable-1.4.3.0\n\
\ (constraint from oops/oops-9.config requires ==1.4.2.0)\n\
\ imported by: oops-8.config\n\
\ imported by: oops/oops-7.config\n\
\ imported by: oops-6.config\n\
\ imported by: oops/oops-5.config\n\
\ imported by: oops-4.config\n\
\ imported by: oops/oops-3.config\n\
\ imported by: oops-2.config\n\
\ imported by: oops/oops-1.config\n\
\ imported by: oops-0.project\n\
\[__1] rejecting: hashable-1.4.2.0\n\
\ (constraint from oops-0.project requires ==1.4.3.0)"
& normalizeWindowsOutput
& flip (assertOn multilineNeedleHaystack) oopsing
readVerbatimFile "oops.expect.txt"
>>= flip (assertOn multilineNeedleHaystack) oopsing . normalizeWindowsOutput

-- The project is named yops as it is like hops but with y's for forks.
-- +-- yops-0.project
Expand Down Expand Up @@ -243,13 +172,7 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
log "checking that missing package message lists configuration provenance"
missing <- fails $ cabal' "v2-build" [ "--project-file=cabal-missing-package.project" ]

"When using configuration from:\n\
\ - cabal-missing-package.project\n\
\ - missing/pkgs.config\n\
\ - missing/pkgs/default.config\n\
\The following errors occurred:\n\
\ - The package location 'pkg-doesnt-exist' does not exist."
& normalizeWindowsOutput
& flip (assertOn multilineNeedleHaystack) missing
readVerbatimFile "cabal-missing-package.expect.txt"
>>= flip (assertOn multilineNeedleHaystack) missing . normalizeWindowsOutput

return ()
56 changes: 56 additions & 0 deletions cabal-testsuite/PackageTests/ConditionalAndImport/hops.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Configuration is affected by the following files:
- hops-0.project
- hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops-6.config
imported by: hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops-8.config
imported by: hops/hops-7.config
imported by: hops-6.config
imported by: hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops/hops-1.config
imported by: hops-0.project
- hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops/hops-7.config
imported by: hops-6.config
imported by: hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
- hops/hops-9.config
imported by: hops-8.config
imported by: hops/hops-7.config
imported by: hops-6.config
imported by: hops/hops-5.config
imported by: hops-4.config
imported by: hops/hops-3.config
imported by: hops-2.config
imported by: hops/hops-1.config
imported by: hops-0.project
16 changes: 16 additions & 0 deletions cabal-testsuite/PackageTests/ConditionalAndImport/oops.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Could not resolve dependencies:
[__0] trying: oops-0.1 (user goal)
[__1] next goal: hashable (dependency of oops)
[__1] rejecting: hashable-1.4.3.0
(constraint from oops/oops-9.config requires ==1.4.2.0)
imported by: oops-8.config
imported by: oops/oops-7.config
imported by: oops-6.config
imported by: oops/oops-5.config
imported by: oops-4.config
imported by: oops/oops-3.config
imported by: oops-2.config
imported by: oops/oops-1.config
imported by: oops-0.project
[__1] rejecting: hashable-1.4.2.0
(constraint from oops-0.project requires ==1.4.3.0)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# checking "using config from message" with URI imports
# check "using config from message" with URI imports
# cabal v2-build
# checking that package directories and locations are reported in order
# check project configuration with URI imports is listed in full and
# check package directories and locations are reported in order
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,12 @@ import Data.Function ((&))
main = cabalTest . recordMode RecordMarked $ do
let log = recordHeader . pure

log "checking \"using config from message\" with URI imports"
log "check \"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 "check project configuration with URI imports is listed in full and"
log "check package directories and locations are reported in order"

log "checking that package directories and locations are reported in order"

"The following errors occurred:\n\
\ - The package directory 'no-pkg-1' does not contain any .cabal file.\n\
\ - The package location 'no-pkg-2-dir' does not exist.\n\
\ - The package directory 'no-pkg-3' does not contain any .cabal file.\n\
\ - The package location 'no-pkg-4-dir' does not exist."
& flip (assertOn multilineNeedleHaystack) out
readVerbatimFile "errors.expect.txt" >>= flip (assertOn multilineNeedleHaystack) out

return ()
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
When using configuration from:
- no-pkgs.project
- 0.config
- 2.config
- 4.config
- 6.config
- 8.config
- cfg/1.config
- cfg/3.config
- cfg/5.config
- cfg/7.config
- cfg/9.config
- with-ghc.config
- https://www.stackage.org/lts-21.25/cabal.config
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.

0 comments on commit 24af359

Please sign in to comment.