Skip to content

Commit

Permalink
scenarios: add several tests for forks tracking marker expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Jun 15, 2024
1 parent cddfd6f commit 52b7145
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scenarios/fork/marker-inherit-combined-allowed.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name = "fork-marker-inherit-combined-allowed"
description = '''
This test builds on `fork-marker-inherit-combined`. Namely, we add
`or implementation_name == 'pypy'` to the dependency on `c`. While
`sys_platform == 'linux'` cannot be true because of the first fork,
the second fork which includes `b==1.0.0` happens precisely when
`implementation_name == 'pypy'`. So in this case, `c` should be
included.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = [
"b>=2 ; implementation_name == 'cpython'",
"b<2 ; implementation_name == 'pypy'",
]
[packages.a.versions."2.0.0"]

[packages.b.versions."1.0.0"]
requires = [
"c ; sys_platform == 'linux' or implementation_name == 'pypy'",
]
[packages.b.versions."2.0.0"]

[packages.c.versions."1.0.0"]
37 changes: 37 additions & 0 deletions scenarios/fork/marker-inherit-combined-disallowed.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name = "fork-marker-inherit-combined-disallowed"
description = '''
This test builds on `fork-marker-inherit-combined`. Namely, we add
`or implementation_name == 'cpython'` to the dependency on `c`.
While `sys_platform == 'linux'` cannot be true because of the first
fork, the second fork which includes `b==1.0.0` happens precisely
when `implementation_name == 'pypy'`, which is *also* disjoint with
`implementation_name == 'cpython'`. Therefore, `c` should not be
included here.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = [
"b>=2 ; implementation_name == 'cpython'",
"b<2 ; implementation_name == 'pypy'",
]
[packages.a.versions."2.0.0"]

[packages.b.versions."1.0.0"]
requires = [
"c ; sys_platform == 'linux' or implementation_name == 'cpython'",
]
[packages.b.versions."2.0.0"]

[packages.c.versions."1.0.0"]
38 changes: 38 additions & 0 deletions scenarios/fork/marker-inherit-combined.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name = "fork-marker-inherit-combined"
description = '''
In this test, we check that marker expressions which provoke a fork
are carried through to subsequent forks. Here, the `a>=2` and `a<2`
dependency specifications create a fork, and then the `a<2` fork leads
to `a==1.0.0` with dependency specifications on `b>=2` and `b<2` that
provoke yet another fork. Finally, in the `b<2` fork, a dependency on
`c` is introduced whose marker expression is disjoint with the marker
expression that provoked the *first* fork. Therefore, `c` should be
entirely excluded from the resolution.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = [
"b>=2 ; implementation_name == 'cpython'",
"b<2 ; implementation_name == 'pypy'",
]
[packages.a.versions."2.0.0"]

[packages.b.versions."1.0.0"]
requires = [
"c ; sys_platform == 'linux'",
]
[packages.b.versions."2.0.0"]

[packages.c.versions."1.0.0"]
32 changes: 32 additions & 0 deletions scenarios/fork/marker-inherit-isolated.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name = "fork-marker-inherit-isolated"
description = '''
This is like `fork-marker-inherit`, but where both `a>=2` and `a<2`
have a conditional dependency on `b`. For `a>=2`, the conditional
dependency on `b` has overlap with the `a>=2` marker expression, and
thus, `b` should be included *only* in the dependencies for `a==2.0.0`.
As with `fork-marker-inherit`, the `a<2` path should exclude `b==1.0.0`
since their marker expressions are disjoint.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = [
"b ; sys_platform == 'linux'"
]
[packages.a.versions."2.0.0"]
requires = [
"b ; sys_platform == 'linux'"
]

[packages.b.versions."1.0.0"]
33 changes: 33 additions & 0 deletions scenarios/fork/marker-inherit-transitive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name = "fork-marker-inherit-transitive"
description = '''
This is like `fork-marker-inherit`, but tests that the marker
expressions that provoke a fork are carried transitively through the
dependency graph. In this case, `a<2 -> b -> c -> d`, but where the
last dependency on `d` requires a marker expression that is disjoint
with the initial `a<2` dependency. Therefore, it ought to be completely
excluded from the resolution.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = ["b"]
[packages.a.versions."2.0.0"]

[packages.b.versions."1.0.0"]
requires = ["c"]

[packages.c.versions."1.0.0"]
requires = ["d ; sys_platform == 'linux'"]

[packages.d.versions."1.0.0"]
33 changes: 33 additions & 0 deletions scenarios/fork/marker-inherit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name = "fork-marker-inherit"
description = '''
This tests that markers which provoked a fork in the universal resolver
are used to ignore dependencies which cannot possibly be installed by a
resolution produced by that fork.
In this example, the `a<2` dependency is only active on Darwin
platforms. But the `a==1.0.0` distribution has a dependency on on `b`
that is only active on Linux, where as `a==2.0.0` does not. Therefore,
when the fork provoked by the `a<2` dependency considers `b`, it should
ignore it because it isn't possible for `sys_platform == 'linux'` and
`sys_platform == 'darwin'` to be simultaneously true.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = [
"b ; sys_platform == 'linux'"
]
[packages.a.versions."2.0.0"]

[packages.b.versions."1.0.0"]
38 changes: 38 additions & 0 deletions scenarios/fork/marker-limited-inherit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name = "fork-marker-limited-inherit"
description = '''
This is like `fork-marker-inherit`, but it tests that dependency
filtering only occurs in the context of a fork.
For example, as in `fork-marker-inherit`, the `c` dependency of
`a<2` should be entirely excluded here since it is possible for
`sys_platform` to be simultaneously equivalent to Darwin and Linux.
However, the unconditional dependency on `b`, which in turn depends on
`c` for Linux only, should still incorporate `c` as the dependency is
not part of any fork.
'''

[resolver_options]
universal = true

[expected]
satisfiable = true

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

[packages.a.versions."1.0.0"]
requires = [
"c ; sys_platform == 'linux'"
]
[packages.a.versions."2.0.0"]

[packages.b.versions."1.0.0"]
requires = [
"c ; sys_platform == 'linux'"
]

[packages.c.versions."1.0.0"]

0 comments on commit 52b7145

Please sign in to comment.