Skip to content

Commit 484ac9c

Browse files
committed
Fix up existing tests with multiline expectations
1 parent 30f5d3f commit 484ac9c

File tree

8 files changed

+119
-136
lines changed

8 files changed

+119
-136
lines changed

cabal-testsuite/PackageTests/BuildDeps/InternalLibrary2/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ main = setupAndCabalTest . withPackageDb $ do
66
assertEqual
77
("executable should have linked with the internal library")
88
("foo foo myLibFunc internal")
9-
(concatOutput (resultOutput r))
9+
(lineBreaksToSpaces $ resultOutput r)

cabal-testsuite/PackageTests/BuildDeps/InternalLibrary3/setup.test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ main = setupAndCabalTest . withPackageDb $ do
88
assertEqual
99
("executable should have linked with the internal library")
1010
("foo foo myLibFunc internal")
11-
(concatOutput (resultOutput r))
11+
(lineBreaksToSpaces $ resultOutput r)

cabal-testsuite/PackageTests/CheckSetup/setup.test.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ main = cabalTest $ do
1313
"The dependency 'setup-depends: 'base' does not specify "
1414
++ "an upper bound on the version number"
1515

16+
-- Replace line breaks with spaces in the haystack so that we can search
17+
-- for a string that wraps lines.
18+
let lineBreakBlind = needleHaystack{txHaystack = txContainsId{txFwd = lineBreaksToSpaces}}
19+
1620
-- Asserts for the desired check messages after configure.
17-
assertOutputContains libError1 checkResult
18-
assertOutputContains libError2 checkResult
21+
assertOn lineBreakBlind libError1 checkResult
22+
assertOn lineBreakBlind libError2 checkResult
1923

2024
return ()

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

Lines changed: 87 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Test.Cabal.Prelude
2-
3-
normalizeWindowsOutput :: String -> String
4-
normalizeWindowsOutput = if isWindows then map (\x -> case x of '/' -> '\\'; _ -> x) else id
2+
import Test.Cabal.OutputNormalizer
3+
import Data.Function ((&))
54

65
main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
76
let log = recordHeader . pure
@@ -111,89 +110,65 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
111110
-- +-- hops/hops-9.config (no further imports so not cyclical)
112111
log "checking that imports work skipping into a subfolder and then back out again and again"
113112
hopping <- cabal' "v2-build" [ "--project-file=hops-0.project" ]
114-
assertOutputContains "Configuration is affected by the following files" hopping
115-
assertOutputContains "- hops-0.project" hopping
116-
117-
assertOutputContains
118-
(normalizeWindowsOutput "- hops-2.config \
119-
\ imported by: hops/hops-1.config \
120-
\ imported by: hops-0.project")
121-
hopping
122-
123-
assertOutputContains
124-
(normalizeWindowsOutput "- hops-4.config \
125-
\ imported by: hops/hops-3.config \
126-
\ imported by: hops-2.config \
127-
\ imported by: hops/hops-1.config \
128-
\ imported by: hops-0.project")
129-
hopping
130-
131-
assertOutputContains
132-
(normalizeWindowsOutput "- hops-6.config \
133-
\ imported by: hops/hops-5.config \
134-
\ imported by: hops-4.config \
135-
\ imported by: hops/hops-3.config \
136-
\ imported by: hops-2.config \
137-
\ imported by: hops/hops-1.config \
138-
\ imported by: hops-0.project")
139-
hopping
140-
141-
assertOutputContains
142-
(normalizeWindowsOutput "- hops-8.config \
143-
\ imported by: hops/hops-7.config \
144-
\ imported by: hops-6.config \
145-
\ imported by: hops/hops-5.config \
146-
\ imported by: hops-4.config \
147-
\ imported by: hops/hops-3.config \
148-
\ imported by: hops-2.config \
149-
\ imported by: hops/hops-1.config \
150-
\ imported by: hops-0.project")
151-
hopping
152113

153-
assertOutputContains
154-
(normalizeWindowsOutput "- hops/hops-1.config \
155-
\ imported by: hops-0.project")
156-
hopping
157-
158-
assertOutputContains
159-
(normalizeWindowsOutput "- hops/hops-3.config \
160-
\ imported by: hops-2.config \
161-
\ imported by: hops/hops-1.config \
162-
\ imported by: hops-0.project")
163-
hopping
164-
165-
assertOutputContains
166-
(normalizeWindowsOutput "- hops/hops-5.config \
167-
\ imported by: hops-4.config \
168-
\ imported by: hops/hops-3.config \
169-
\ imported by: hops-2.config \
170-
\ imported by: hops/hops-1.config \
171-
\ imported by: hops-0.project")
172-
hopping
173-
174-
assertOutputContains
175-
(normalizeWindowsOutput "- hops/hops-7.config \
176-
\ imported by: hops-6.config \
177-
\ imported by: hops/hops-5.config \
178-
\ imported by: hops-4.config \
179-
\ imported by: hops/hops-3.config \
180-
\ imported by: hops-2.config \
181-
\ imported by: hops/hops-1.config \
182-
\ imported by: hops-0.project")
183-
hopping
184-
185-
assertOutputContains
186-
(normalizeWindowsOutput "- hops/hops-9.config \
187-
\ imported by: hops-8.config \
188-
\ imported by: hops/hops-7.config \
189-
\ imported by: hops-6.config \
190-
\ imported by: hops/hops-5.config \
191-
\ imported by: hops-4.config \
192-
\ imported by: hops/hops-3.config \
193-
\ imported by: hops-2.config \
194-
\ imported by: hops/hops-1.config \
195-
\ imported by: hops-0.project")
196-
hopping
114+
"Configuration is affected by the following files:\n\
115+
\- hops-0.project\n\
116+
\- hops-2.config\n\
117+
\ imported by: hops/hops-1.config\n\
118+
\ imported by: hops-0.project\n\
119+
\- hops-4.config\n\
120+
\ imported by: hops/hops-3.config\n\
121+
\ imported by: hops-2.config\n\
122+
\ imported by: hops/hops-1.config\n\
123+
\ imported by: hops-0.project\n\
124+
\- hops-6.config\n\
125+
\ imported by: hops/hops-5.config\n\
126+
\ imported by: hops-4.config\n\
127+
\ imported by: hops/hops-3.config\n\
128+
\ imported by: hops-2.config\n\
129+
\ imported by: hops/hops-1.config\n\
130+
\ imported by: hops-0.project\n\
131+
\- hops-8.config\n\
132+
\ imported by: hops/hops-7.config\n\
133+
\ imported by: hops-6.config\n\
134+
\ imported by: hops/hops-5.config\n\
135+
\ imported by: hops-4.config\n\
136+
\ imported by: hops/hops-3.config\n\
137+
\ imported by: hops-2.config\n\
138+
\ imported by: hops/hops-1.config\n\
139+
\ imported by: hops-0.project\n\
140+
\- hops/hops-1.config\n\
141+
\ imported by: hops-0.project\n\
142+
\- hops/hops-3.config\n\
143+
\ imported by: hops-2.config\n\
144+
\ imported by: hops/hops-1.config\n\
145+
\ imported by: hops-0.project\n\
146+
\- hops/hops-5.config\n\
147+
\ imported by: hops-4.config\n\
148+
\ imported by: hops/hops-3.config\n\
149+
\ imported by: hops-2.config\n\
150+
\ imported by: hops/hops-1.config\n\
151+
\ imported by: hops-0.project\n\
152+
\- hops/hops-7.config\n\
153+
\ imported by: hops-6.config\n\
154+
\ imported by: hops/hops-5.config\n\
155+
\ imported by: hops-4.config\n\
156+
\ imported by: hops/hops-3.config\n\
157+
\ imported by: hops-2.config\n\
158+
\ imported by: hops/hops-1.config\n\
159+
\ imported by: hops-0.project\n\
160+
\- hops/hops-9.config\n\
161+
\ imported by: hops-8.config\n\
162+
\ imported by: hops/hops-7.config\n\
163+
\ imported by: hops-6.config\n\
164+
\ imported by: hops/hops-5.config\n\
165+
\ imported by: hops-4.config\n\
166+
\ imported by: hops/hops-3.config\n\
167+
\ imported by: hops-2.config\n\
168+
\ imported by: hops/hops-1.config\n\
169+
\ imported by: hops-0.project"
170+
& normalizeWindowsOutput
171+
& flip (assertOn multilineNeedleHaystack) hopping
197172

198173
-- The project is named oops as it is like hops but has conflicting constraints.
199174
-- +-- oops-0.project
@@ -208,22 +183,25 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
208183
-- +-- oops/oops-9.config (has conflicting constraints)
209184
log "checking conflicting constraints skipping into a subfolder and then back out again and again"
210185
oopsing <- fails $ cabal' "v2-build" [ "all", "--project-file=oops-0.project" ]
211-
assertOutputContains "rejecting: hashable-1.4.2.0" oopsing
212-
assertOutputContains "rejecting: hashable-1.4.3.0" oopsing
213-
assertOutputContains "(constraint from oops-0.project requires ==1.4.3.0)" oopsing
214186

215-
assertOutputContains
216-
(normalizeWindowsOutput " (constraint from oops/oops-9.config requires ==1.4.2.0) \
217-
\ imported by: oops-8.config \
218-
\ imported by: oops/oops-7.config \
219-
\ imported by: oops-6.config \
220-
\ imported by: oops/oops-5.config \
221-
\ imported by: oops-4.config \
222-
\ imported by: oops/oops-3.config \
223-
\ imported by: oops-2.config \
224-
\ imported by: oops/oops-1.config \
225-
\ imported by: oops-0.project")
226-
oopsing
187+
"Could not resolve dependencies:\n\
188+
\[__0] trying: oops-0.1 (user goal)\n\
189+
\[__1] next goal: hashable (dependency of oops)\n\
190+
\[__1] rejecting: hashable-1.4.3.0\n\
191+
\ (constraint from oops/oops-9.config requires ==1.4.2.0)\n\
192+
\ imported by: oops-8.config\n\
193+
\ imported by: oops/oops-7.config\n\
194+
\ imported by: oops-6.config\n\
195+
\ imported by: oops/oops-5.config\n\
196+
\ imported by: oops-4.config\n\
197+
\ imported by: oops/oops-3.config\n\
198+
\ imported by: oops-2.config\n\
199+
\ imported by: oops/oops-1.config\n\
200+
\ imported by: oops-0.project\n\
201+
\[__1] rejecting: hashable-1.4.2.0\n\
202+
\ (constraint from oops-0.project requires ==1.4.3.0)"
203+
& normalizeWindowsOutput
204+
& flip (assertOn multilineNeedleHaystack) oopsing
227205

228206
-- The project is named yops as it is like hops but with y's for forks.
229207
-- +-- yops-0.project
@@ -264,13 +242,14 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
264242

265243
log "checking that missing package message lists configuration provenance"
266244
missing <- fails $ cabal' "v2-build" [ "--project-file=cabal-missing-package.project" ]
267-
assertOutputContains
268-
(normalizeWindowsOutput "When using configuration from: \
269-
\ - cabal-missing-package.project \
270-
\ - missing/pkgs.config \
271-
\ - missing/pkgs/default.config \
272-
\The following errors occurred: \
273-
\ - The package location 'pkg-doesnt-exist' does not exist.")
274-
missing
245+
246+
"When using configuration from:\n\
247+
\ - cabal-missing-package.project\n\
248+
\ - missing/pkgs.config\n\
249+
\ - missing/pkgs/default.config\n\
250+
\The following errors occurred:\n\
251+
\ - The package location 'pkg-doesnt-exist' does not exist."
252+
& normalizeWindowsOutput
253+
& flip (assertOn multilineNeedleHaystack) missing
275254

276255
return ()
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Test.Cabal.Prelude
2+
import Data.Function ((&))
23

34
-- This test is similar to the simplified example in issue #4288. The package's
45
-- setup script only depends on base and setup-helper. setup-helper exposes a
@@ -10,8 +11,7 @@ main = cabalTest $ do
1011
skipUnless "no v2-build compatible boot-Cabal" =<< hasNewBuildCompatBootCabal
1112
r <- recordMode DoNotRecord $ cabal' "v2-build" ["T4288"]
1213
assertOutputContains "This is setup-helper-1.0." r
13-
assertOutputContains
14-
("In order, the following will be built: "
15-
++ " - setup-helper-1.0 (lib:setup-helper) (first run) "
16-
++ " - T4288-1.0 (lib:T4288) (first run)")
17-
r
14+
"In order, the following will be built:\n\
15+
\ - setup-helper-1.0 (lib:setup-helper) (first run)\n\
16+
\ - T4288-1.0 (lib:T4288) (first run)"
17+
& flip (assertOn multilineNeedleHaystack) r
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
# checking "using config from message" with URI imports
1+
# check "using config from message" with URI imports
22
# cabal v2-build
3-
# checking that package directories and locations are reported in order
3+
# check project configuration with URI imports is listed in full and
4+
# check package directories and locations are reported in order

cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Test.Cabal.Prelude
2+
import Data.Function ((&))
23

34
main = cabalTest . recordMode RecordMarked $ do
45
let log = recordHeader . pure
@@ -31,12 +32,12 @@ main = cabalTest . recordMode RecordMarked $ do
3132
out
3233

3334
log "checking that package directories and locations are reported in order"
34-
assertOutputContains
35-
"The following errors occurred: \
36-
\ - The package directory 'no-pkg-1' does not contain any .cabal file. \
37-
\ - The package location 'no-pkg-2-dir' does not exist. \
38-
\ - The package directory 'no-pkg-3' does not contain any .cabal file. \
39-
\ - The package location 'no-pkg-4-dir' does not exist."
40-
out
35+
36+
"The following errors occurred:\n\
37+
\ - The package directory 'no-pkg-1' does not contain any .cabal file.\n\
38+
\ - The package location 'no-pkg-2-dir' does not exist.\n\
39+
\ - The package directory 'no-pkg-3' does not contain any .cabal file.\n\
40+
\ - The package location 'no-pkg-4-dir' does not exist."
41+
& flip (assertOn multilineNeedleHaystack) out
4142

4243
return ()
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Test.Cabal.Prelude
2+
import Data.Function ((&))
23

34
-- The local package, pkg-1.0, depends on build-tool-pkg-1 as a library and
45
-- build-tool-pkg-2 as a build-tool. This test checks that cabal uses the
@@ -16,16 +17,13 @@ main = cabalTest $ withShorterPathForNewBuildStore $ do
1617
r1 <- recordMode DoNotRecord $
1718
cabal' "v2-build" ["pkg:my-exe"]
1819

19-
let msg = concat
20-
[ "In order, the following will be built:"
21-
, " - build-tool-pkg-1 (lib) (requires build)"
22-
, " - build-tool-pkg-2 (lib) (requires build)"
23-
, " - build-tool-pkg-2 (exe:build-tool-exe) (requires build)"
24-
, " - pkg-1.0 (exe:my-exe) (first run)"
25-
]
20+
"In order, the following will be built:\n\
21+
\ - build-tool-pkg-1 (lib) (requires build)\n\
22+
\ - build-tool-pkg-2 (lib) (requires build)\n\
23+
\ - build-tool-pkg-2 (exe:build-tool-exe) (requires build)\n\
24+
\ - pkg-1.0 (exe:my-exe) (first run)"
25+
& flip (assertOn multilineNeedleHaystack) r1
2626

27-
assertOutputContains msg r1
2827
withPlan $ do
2928
r2 <- runPlanExe' "pkg" "my-exe" []
30-
assertOutputContains
31-
"build-tool library version: 1, build-tool exe version: 2" r2
29+
assertOn multilineNeedleHaystack "build-tool library version: 1,\nbuild-tool exe version: 2" r2

0 commit comments

Comments
 (0)