Skip to content

Commit

Permalink
Add "when using config from" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Nov 13, 2024
1 parent f8e1bc2 commit 7070d18
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ In order, the following will be built:
Configuring my-0.1...
Preprocessing library for my-0.1...
Building library for my-0.1...
# checking "using config from message" without URI imports
# cabal v2-build
# checking "using config from message" with URI imports
# cabal v2-build
# checking bad conditional
# cabal v2-build
Error: [Cabal-7090]
Expand Down
65 changes: 65 additions & 0 deletions cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,71 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
log "checking if we detect when the same config is imported via many different paths (we don't)"
woopping <- cabal' "v2-build" [ "--project-file=woops-0.project" ]

log "checking \"using config from message\" without URI imports"
withDirectory "yops" $ do
yopping <- fails $ cabal' "v2-build" [ "--project-file=../yops-0.project" ]

-- Use assertRegex when the output is tainted by the temp directory, like
-- this:
--
-- When using configuration from:
-- - /tmp/cabal-testsuite-286573/yops-0.project
-- - /tmp/cabal-testsuite-286573/yops-2.config etc
assertRegex
"Project configuration is listed in full"
"When using configuration from:\n \
\ .*yops-0\\.project\n \
\ .*yops-2\\.config\n \
\ .*yops-4\\.config\n \
\ .*yops-6\\.config\n \
\ .*yops-8\\.config\n \
\ .*yops-1\\.config\n \
\ .*yops-3\\.config\n \
\ .*yops-5\\.config\n \
\ .*yops-7\\.config\n \
\ .*yops-9\\.config\n"
yopping

assertOutputContains
(normalizeWindowsOutput "The following errors occurred: \
\ - The package directory '.' does not contain any .cabal file.")
yopping

return ()

log "checking \"using config from message\" with URI imports"
withDirectory "woops" $ do
woopping <- fails $ cabal' "v2-build" [ "--project-file=../woops-0.project" ]

-- Use assertRegex when the output is tainted by the temp directory, like
-- this:
--
-- When using configuration from:
-- - /tmp/cabal-testsuite-282695/woops-0.project
-- - /tmp/cabal-testsuite-282695/woops-2.config etc
assertRegex
"Project configuration is listed in full"
"When using configuration from:\n \
\ .*woops-0\\.project\n \
\ .*woops-2\\.config\n \
\ .*woops-4\\.config\n \
\ .*woops-6\\.config\n \
\ .*woops-8\\.config\n \
\ .*woops-1\\.config\n \
\ .*woops-3\\.config\n \
\ .*woops-5\\.config\n \
\ .*woops-7\\.config\n \
\ .*woops-9\\.config\n \
\ .*https://www.stackage.org/lts-21.25/cabal.config\n"
woopping

assertOutputContains
(normalizeWindowsOutput "The following errors occurred: \
\ - The package directory '.' does not contain any .cabal file.")
woopping

return ()

log "checking bad conditional"
badIf <- fails $ cabal' "v2-build" [ "--project-file=bad-conditional.project" ]
assertOutputContains "Cannot set compiler in a conditional clause of a cabal project file" badIf
Expand Down

0 comments on commit 7070d18

Please sign in to comment.