Skip to content

Commit 88b92e6

Browse files
committed
Add "when using config from" tests
1 parent 4c17c99 commit 88b92e6

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,10 @@ In order, the following will be built:
655655
Configuring my-0.1...
656656
Preprocessing library for my-0.1...
657657
Building library for my-0.1...
658+
# checking "using config from message" without URI imports
659+
# cabal v2-build
660+
# checking "using config from message" with URI imports
661+
# cabal v2-build
658662
# checking bad conditional
659663
# cabal v2-build
660664
Error: [Cabal-7090]

cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,71 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
261261
log "checking if we detect when the same config is imported via many different paths (we don't)"
262262
woopping <- cabal' "v2-build" [ "--project-file=woops-0.project" ]
263263

264+
log "checking \"using config from message\" without URI imports"
265+
withDirectory "yops" $ do
266+
yopping <- fails $ cabal' "v2-build" [ "--project-file=../yops-0.project" ]
267+
268+
-- Use assertRegex when the output is tainted by the temp directory, like
269+
-- this:
270+
--
271+
-- When using configuration from:
272+
-- - /tmp/cabal-testsuite-286573/yops-0.project
273+
-- - /tmp/cabal-testsuite-286573/yops-2.config etc
274+
assertRegex
275+
"Project configuration is listed in full"
276+
"When using configuration from:\n \
277+
\ .*yops-0\\.project\n \
278+
\ .*yops-2\\.config\n \
279+
\ .*yops-4\\.config\n \
280+
\ .*yops-6\\.config\n \
281+
\ .*yops-8\\.config\n \
282+
\ .*yops-1\\.config\n \
283+
\ .*yops-3\\.config\n \
284+
\ .*yops-5\\.config\n \
285+
\ .*yops-7\\.config\n \
286+
\ .*yops-9\\.config\n"
287+
yopping
288+
289+
assertOutputContains
290+
(normalizeWindowsOutput "The following errors occurred: \
291+
\ - The package directory '.' does not contain any .cabal file.")
292+
yopping
293+
294+
return ()
295+
296+
log "checking \"using config from message\" with URI imports"
297+
withDirectory "woops" $ do
298+
woopping <- fails $ cabal' "v2-build" [ "--project-file=../woops-0.project" ]
299+
300+
-- Use assertRegex when the output is tainted by the temp directory, like
301+
-- this:
302+
--
303+
-- When using configuration from:
304+
-- - /tmp/cabal-testsuite-282695/woops-0.project
305+
-- - /tmp/cabal-testsuite-282695/woops-2.config etc
306+
assertRegex
307+
"Project configuration is listed in full"
308+
"When using configuration from:\n \
309+
\ .*woops-0\\.project\n \
310+
\ .*woops-2\\.config\n \
311+
\ .*woops-4\\.config\n \
312+
\ .*woops-6\\.config\n \
313+
\ .*woops-8\\.config\n \
314+
\ .*woops-1\\.config\n \
315+
\ .*woops-3\\.config\n \
316+
\ .*woops-5\\.config\n \
317+
\ .*woops-7\\.config\n \
318+
\ .*woops-9\\.config\n \
319+
\ .*https://www.stackage.org/lts-21.25/cabal.config\n"
320+
woopping
321+
322+
assertOutputContains
323+
(normalizeWindowsOutput "The following errors occurred: \
324+
\ - The package directory '.' does not contain any .cabal file.")
325+
woopping
326+
327+
return ()
328+
264329
log "checking bad conditional"
265330
badIf <- fails $ cabal' "v2-build" [ "--project-file=bad-conditional.project" ]
266331
assertOutputContains "Cannot set compiler in a conditional clause of a cabal project file" badIf

0 commit comments

Comments
 (0)