1 import Test
.Cabal
.Prelude
3 main
= cabalTest
. withRepo
"repo" . recordMode RecordMarked
$ do
4 let log = recordHeader
. pure
6 cabal
"v2-run" [ "some-exe" ]
8 -- +-- cyclical-0-self.project (imports cyclical-0-self.project)
9 -- +-- cyclical-0-self.project (already processed)
11 log "checking cyclical loopback of a project importing itself"
12 cyclical0
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-0-self.project" ]
13 assertOutputContains
"cyclical import of cyclical-0-self.project" cyclical0
15 -- +-- cyclical-1-out-back.project
16 -- +-- cyclical-1-out-back.config (imports cyclical-1-out-back.project)
17 -- +-- cyclical-1-out-back.project (already processed)
19 log "checking cyclical with hops; out and back"
20 cyclical1a
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-1-out-back.project" ]
21 assertOutputContains
"cyclical import of cyclical-1-out-back.project" cyclical1a
23 -- +-- cyclical-1-out-self.project
24 -- +-- cyclical-1-out-self.config (imports cyclical-1-out-self.config)
25 -- +-- cyclical-1-out-self.config (already processed)
27 log "checking cyclical with hops; out to a config that imports itself"
28 cyclical1b
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-1-out-self.project" ]
29 assertOutputContains
"cyclical import of cyclical-1-out-self.config" cyclical1b
31 -- +-- cyclical-2-out-out-backback.project
32 -- +-- cyclical-2-out-out-backback-a.config
33 -- +-- cyclical-2-out-out-backback-b.config (imports cyclical-2-out-out-backback.project)
34 -- +-- cyclical-2-out-out-backback.project (already processed)
36 log "checking cyclical with hops; out, out, twice back"
37 cyclical2a
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-2-out-out-backback.project" ]
38 assertOutputContains
"cyclical import of cyclical-2-out-out-backback.project" cyclical2a
40 -- +-- cyclical-2-out-out-back.project
41 -- +-- cyclical-2-out-out-back-a.config
42 -- +-- cyclical-2-out-out-back-b.config (imports cyclical-2-out-out-back-a.config)
43 -- +-- cyclical-2-out-out-back-a.config (already processed)
45 log "checking cyclical with hops; out, out, once back"
46 cyclical2b
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-2-out-out-back.project" ]
47 assertOutputContains
"cyclical import of cyclical-2-out-out-back-a.config" cyclical2b
49 -- +-- cyclical-2-out-out-self.project
50 -- +-- cyclical-2-out-out-self-a.config
51 -- +-- cyclical-2-out-out-self-b.config (imports cyclical-2-out-out-self-b.config)
52 -- +-- cyclical-2-out-out-self-b.config (already processed)
54 log "checking cyclical with hops; out, out to a config that imports itself"
55 cyclical2c
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-2-out-out-self.project" ]
56 assertOutputContains
"cyclical import of cyclical-2-out-out-self-b.config" cyclical2c
58 -- +-- noncyclical-same-filename-a.project
59 -- +-- noncyclical-same-filename-a.config
60 -- +-- same-filename/noncyclical-same-filename-a.config (no further imports so not cyclical)
61 log "checking that cyclical check doesn't false-positive on same file names in different folders; hoping within a folder and then into a subfolder"
62 cyclical3b
<- cabal
' "v2-build" [ "--project-file=noncyclical-same-filename-a.project" ]
63 assertOutputDoesNotContain
"cyclical import of" cyclical3b
65 -- +-- noncyclical-same-filename-b.project
66 -- +-- same-filename/noncyclical-same-filename-b.config
67 -- +-- noncyclical-same-filename-b.config (no further imports so not cyclical)
68 log "checking that cyclical check doesn't false-positive on same file names in different folders; hoping into a subfolder and then back out again"
69 cyclical3c
<- cabal
' "v2-build" [ "--project-file=noncyclical-same-filename-b.project" ]
70 assertOutputDoesNotContain
"cyclical import of" cyclical3c
72 -- +-- cyclical-same-filename-out-out-self.project
73 -- +-- cyclical-same-filename-out-out-self.config
74 -- +-- same-filename/cyclical-same-filename-out-out-self.config
75 -- +-- same-filename/cyclical-same-filename-out-out-self.config (already processed)
77 log "checking that cyclical check catches a same file name that imports itself"
78 cyclical4a
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-same-filename-out-out-self.project" ]
79 assertOutputContains
"cyclical import of same-filename/cyclical-same-filename-out-out-self.config" cyclical4a
81 -- +-- cyclical-same-filename-out-out-backback.project
82 -- +-- cyclical-same-filename-out-out-backback.config
83 -- +-- same-filename/cyclical-same-filename-out-out-backback.config
84 -- +-- cyclical-same-filename-out-out-backback.project (already processed)
86 log "checking that cyclical check catches importing its importer (with the same file name)"
87 cyclical4b
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-same-filename-out-out-backback.project" ]
88 assertOutputContains
"cyclical import of cyclical-same-filename-out-out-backback.project" cyclical4b
90 -- +-- cyclical-same-filename-out-out-back.project
91 -- +-- cyclical-same-filename-out-out-back.config
92 -- +-- same-filename/cyclical-same-filename-out-out-back.config
93 -- +-- cyclical-same-filename-out-out-back.config (already processed)
95 log "checking that cyclical check catches importing its importer's importer (hopping over same file names)"
96 cyclical4c
<- fails
$ cabal
' "v2-build" [ "--project-file=cyclical-same-filename-out-out-back.project" ]
97 assertOutputContains
"cyclical import of cyclical-same-filename-out-out-back.config" cyclical4c
100 -- +-- hops/hops-1.config
102 -- +-- hops/hops-3.config
104 -- +-- hops/hops-5.config
106 -- +-- hops/hops-7.config
108 -- +-- hops/hops-9.config (no further imports so not cyclical)
109 log "checking that imports work skipping into a subfolder and then back out again and again"
110 hopping
<- cabal
' "v2-build" [ "--project-file=hops-0.project" ]
111 assertOutputContains
"this build was affected by the following (project) config files:" hopping
112 assertOutputContains
"- hops-0.project" hopping
116 \ imported by: hops/hops-1.config \
117 \ imported by: hops-0.project"
122 \ imported by: hops/hops-3.config \
123 \ imported by: hops-2.config \
124 \ imported by: hops/hops-1.config \
125 \ imported by: hops-0.project"
130 \ imported by: hops/hops-5.config \
131 \ imported by: hops-4.config \
132 \ imported by: hops/hops-3.config \
133 \ imported by: hops-2.config \
134 \ imported by: hops/hops-1.config \
135 \ imported by: hops-0.project"
140 \ imported by: hops/hops-7.config \
141 \ imported by: hops-6.config \
142 \ imported by: hops/hops-5.config \
143 \ imported by: hops-4.config \
144 \ imported by: hops/hops-3.config \
145 \ imported by: hops-2.config \
146 \ imported by: hops/hops-1.config \
147 \ imported by: hops-0.project"
151 "- hops/hops-1.config \
152 \ imported by: hops-0.project"
156 "- hops/hops-3.config \
157 \ imported by: hops-2.config \
158 \ imported by: hops/hops-1.config \
159 \ imported by: hops-0.project"
163 "- hops/hops-5.config \
164 \ imported by: hops-4.config \
165 \ imported by: hops/hops-3.config \
166 \ imported by: hops-2.config \
167 \ imported by: hops/hops-1.config \
168 \ imported by: hops-0.project"
172 "- hops/hops-7.config \
173 \ imported by: hops-6.config \
174 \ imported by: hops/hops-5.config \
175 \ imported by: hops-4.config \
176 \ imported by: hops/hops-3.config \
177 \ imported by: hops-2.config \
178 \ imported by: hops/hops-1.config \
179 \ imported by: hops-0.project"
183 "- hops/hops-9.config \
184 \ imported by: hops-8.config \
185 \ imported by: hops/hops-7.config \
186 \ imported by: hops-6.config \
187 \ imported by: hops/hops-5.config \
188 \ imported by: hops-4.config \
189 \ imported by: hops/hops-3.config \
190 \ imported by: hops-2.config \
191 \ imported by: hops/hops-1.config \
192 \ imported by: hops-0.project"
195 -- The project is named oops as it is like hops but has conflicting constraints.
196 -- +-- oops-0.project
197 -- +-- oops/oops-1.config
199 -- +-- oops/oops-3.config
201 -- +-- oops/oops-5.config
203 -- +-- oops/oops-7.config
205 -- +-- oops/oops-9.config (has conflicting constraints)
206 log "checking conflicting constraints skipping into a subfolder and then back out again and again"
207 oopsing
<- fails
$ cabal
' "v2-build" [ "all", "--project-file=oops-0.project" ]
208 assertOutputContains
"rejecting: hashable-1.4.2.0" oopsing
209 assertOutputContains
"rejecting: hashable-1.4.3.0" oopsing
210 assertOutputContains
"(constraint from oops-0.project requires ==1.4.3.0)" oopsing
213 " (constraint from oops/oops-9.config requires ==1.4.2.0) \
214 \ imported by: oops-8.config \
215 \ imported by: oops/oops-7.config \
216 \ imported by: oops-6.config \
217 \ imported by: oops/oops-5.config \
218 \ imported by: oops-4.config \
219 \ imported by: oops/oops-3.config \
220 \ imported by: oops-2.config \
221 \ imported by: oops/oops-1.config \
222 \ imported by: oops-0.project"
225 log "checking bad conditional"
226 badIf
<- fails
$ cabal
' "v2-build" [ "--project-file=bad-conditional.project" ]
227 assertOutputContains
"Cannot set compiler in a conditional clause of a cabal project file" badIf
229 log "checking that missing package message lists configuration provenance"
230 missing
<- fails
$ cabal
' "v2-build" [ "--project-file=cabal-missing-package.project" ]
232 "When using configuration from: \
233 \ - cabal-missing-package.project \
234 \ - missing/pkgs.config \
235 \ - missing/pkgs/default.config \
236 \The following errors occurred: \
237 \ - The package location 'pkg-doesnt-exist' does not exist."