Skip to content

Commit

Permalink
scenarios: add more tests for resolver forks tracking markers
Browse files Browse the repository at this point in the history
These tests were motivated by @konstin's question here:
astral-sh/uv#4339 (comment)
  • Loading branch information
BurntSushi committed Jun 17, 2024
1 parent 95b8af8 commit 2279c4d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name = "fork-allows-non-conflicting-non-overlapping-dependencies"
description = '''
This test ensures that multiple non-conflicting but also
non-overlapping dependency specifications with the same package name
are allowed and supported.
At time of writing, this provokes a fork in the resolver, but it
arguably shouldn't since the requirements themselves do not conflict
with one another. However, this does impact resolution. Namely, it
leaves the `a>=1` fork free to choose `a==2.0.0` since it behaves as if
the `a<2` constraint doesn't exist.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

[root]
requires = [
"a>=1 ; sys_platform == 'linux'",
"a<2 ; sys_platform == 'darwin'",
]

[packages.a.versions."1.0.0"]
[packages.a.versions."2.0.0"]
26 changes: 26 additions & 0 deletions scenarios/fork/allows-non-conflicting-repeated-dependencies.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name = "fork-allows-non-conflicting-repeated-dependencies"
description = '''
This test ensures that multiple non-conflicting dependency
specifications with the same package name are allowed and supported.
This test exists because the universal resolver forks itself based on
duplicate dependency specifications by looking at package name. So at
first glance, a case like this could perhaps cause an errant fork.
While it's difficult to test for "does not create a fork" (at time of
writing, the implementation does not fork), we can at least check that
this case is handled correctly without issue. Namely, forking should
only occur when there are duplicate dependency specifications with
disjoint marker expressions.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

[root]
requires = ["a>=1", "a<2"]

[packages.a.versions."1.0.0"]
[packages.a.versions."2.0.0"]
23 changes: 23 additions & 0 deletions scenarios/fork/conflict-unsatisfiable.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name = "fork-conflict-unsatisfiable"
description = '''
This test ensures that conflicting dependency specifications lead to an
unsatisfiable result.
In particular, this is a case that should not fork even though there
are conflicting requirements because their marker expressions are
overlapping. (Well, there aren't any marker expressions here, which
means they are both unconditional.)
'''

[resolver_options]
universal = true

[expected]
satisfiable = false

[root]
requires = ["a>=2", "a<2"]

[packages.a.versions."1.0.0"]
[packages.a.versions."2.0.0"]
[packages.a.versions."3.0.0"]

0 comments on commit 2279c4d

Please sign in to comment.