Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 5913ce3

Browse files
Add backtracking tests
Verify that transitive constraints are properly popped during a backtrack
1 parent f11e8f6 commit 5913ce3

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

gps/solve_bimodal_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,58 @@ var bimodalFixtures = map[string]bimodalFixture{
152152
"baz 1.0.0",
153153
),
154154
},
155+
"backtrack drops transitive constraint": {
156+
ds: []depspec{
157+
dsp(mkDepspec("root 1.0.0", "foo ^1.0.0"),
158+
pkg("root", "foo"),
159+
),
160+
dsp(mkDepspec("foo 1.0.1", "bar =1.0.1", "baz =1.0.1"), // This transitive constraint should not be applied in the final solution
161+
pkg("foo", "bar"),
162+
),
163+
dsp(mkDepspec("foo 1.0.0", "bar =1.0.0"),
164+
pkg("foo", "bar"),
165+
),
166+
dsp(mkDepspec("bar 1.0.1", "baz =1.0.0-notexist"), // This should trigger a backtrack
167+
pkg("bar", "baz"),
168+
),
169+
dsp(mkDepspec("bar 1.0.0", "baz =1.0.0"), // This will conflict with the transitive constraint if it's not dropped during backtracking
170+
pkg("bar", "baz"),
171+
),
172+
dsp(mkDepspec("baz 1.0.1"), pkg("baz")),
173+
dsp(mkDepspec("baz 1.0.0"), pkg("baz")),
174+
},
175+
r: mksolution(
176+
"foo 1.0.0",
177+
"bar 1.0.0",
178+
"baz 1.0.0",
179+
),
180+
},
181+
"backtrack adds transitive constraint": {
182+
ds: []depspec{
183+
dsp(mkDepspec("root 1.0.0", "foo ^1.0.0"),
184+
pkg("root", "foo"),
185+
),
186+
dsp(mkDepspec("foo 1.0.1", "bar =1.0.1"),
187+
pkg("foo", "bar"),
188+
),
189+
dsp(mkDepspec("foo 1.0.0", "bar =1.0.0", "baz =1.0.0"), // This transitive constraint should be applied in the final solution
190+
pkg("foo", "bar"),
191+
),
192+
dsp(mkDepspec("bar 1.0.1", "baz =1.0.0-notexist"), // This should trigger a backtrack
193+
pkg("bar", "baz"),
194+
),
195+
dsp(mkDepspec("bar 1.0.0", "baz ^1.0.0"), // Normally this would pick baz 1.0.1 but the transitive constraint should force an older version
196+
pkg("bar", "baz"),
197+
),
198+
dsp(mkDepspec("baz 1.0.1"), pkg("baz")),
199+
dsp(mkDepspec("baz 1.0.0"), pkg("baz")),
200+
},
201+
r: mksolution(
202+
"foo 1.0.0",
203+
"bar 1.0.0",
204+
"baz 1.0.0",
205+
),
206+
},
155207
// Constraints apply only if the project that declares them has a
156208
// reachable import
157209
"constraints activated by import": {

0 commit comments

Comments
 (0)