Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
741d178
Avoid propagating unrelated extras during export
charliermarsh Oct 19, 2026
ba20b8b
Use sparse conflict propagation for all exports
charliermarsh Oct 20, 2026
cc60964
Merge main after the export activation revert
charliermarsh Oct 20, 2026
dee0444
Limit conflict propagation to paths with marker readers
charliermarsh Oct 20, 2026
b1c2716
Resolve negative extra guards before exporting dependencies
charliermarsh Oct 20, 2026
84454f3
Resolve global extra activation after symbolic reachability
charliermarsh Oct 20, 2026
de1be33
Resolve uncertain export selections with complete activation models
charliermarsh Oct 20, 2026
860b983
Fold unconditional extra activations before symbolic export traversal
charliermarsh Oct 20, 2026
2ef9b4b
Track empty dependency groups in export conflicts
charliermarsh Oct 20, 2026
a8314d4
Respect group-only selection in export conflicts
charliermarsh Oct 20, 2026
a81ffff
Simplify export activation graph construction
charliermarsh Oct 20, 2026
3950259
Keep one pathological export benchmark
charliermarsh Oct 20, 2026
a779eaf
Use explicit export regression test cases
charliermarsh Oct 20, 2026
9b889b2
Remove exact fallback for recursive export conditions
charliermarsh Oct 20, 2026
2bdf686
Remove export benchmarks from activation changes
charliermarsh Oct 20, 2026
2ec7a2d
Use an enum for virtual package export policy
charliermarsh Oct 20, 2026
209d2fc
Clarify export activation analysis
charliermarsh Oct 20, 2026
cde2b42
Centralize export conflict variables
charliermarsh Oct 20, 2026
75235d4
Group export reachability state by node
charliermarsh Oct 20, 2026
e5c0998
Separate export component solving
charliermarsh Oct 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use explicit export regression test cases
  • Loading branch information
charliermarsh committed Oct 20, 2026
commit a779eafc71a1c2cfbe166aa10456bdac00ad3d77
184 changes: 63 additions & 121 deletions crates/uv-pep508/src/marker/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2380,74 +2380,6 @@ mod test {
assert_eq!(marker.resolve_extras(known), condition);
}

/// Exhaust all three-extra Boolean functions and their consistent activation intervals.
#[test]
fn resolve_extras_with_bounds_truth_tables() {
let names =
["a", "b", "c"].map(|name| name.parse::<ExtraName>().expect("valid extra name"));
let variables = [m("extra == 'a'"), m("extra == 'b'"), m("extra == 'c'")];
let minterms: [MarkerTree; 8] = std::array::from_fn(|assignment| {
variables
.iter()
.enumerate()
.fold(MarkerTree::TRUE, |term, (index, &variable)| {
term.and(if assignment & (1 << index) == 0 {
variable.negate()
} else {
variable
})
})
});
let constant = |value| {
if value {
MarkerTree::TRUE
} else {
MarkerTree::FALSE
}
};

for truth in 0..=u8::MAX {
let marker = minterms.iter().enumerate().fold(
MarkerTree::FALSE,
|marker, (assignment, &minterm)| {
if truth & (1 << assignment) != 0 {
marker.or(minterm)
} else {
marker
}
},
);
for lower in 0..8u8 {
for upper in 0..8u8 {
if lower & !upper != 0 {
continue;
}
let mut expected = (true, false);
for assignment in 0..8u8 {
if assignment & lower == lower && assignment & upper == assignment {
let value = truth & (1 << assignment) != 0;
expected.0 &= value;
expected.1 |= value;
}
}
assert_eq!(
marker.resolve_extras_with_bounds(names.iter().enumerate().map(
|(index, name)| (
name.clone(),
(
constant(lower & (1 << index) != 0),
constant(upper & (1 << index) != 0),
),
)
)),
(constant(expected.0), constant(expected.1)),
"truth table {truth:08b}, interval {lower:03b}..={upper:03b}"
);
}
}
}
}

/// An unknown decision cannot hide a condition guaranteed by both branches.
#[test]
fn resolve_extras_with_bounds_consensus() {
Expand All @@ -2466,6 +2398,7 @@ mod test {
);

let linux = m("sys_platform == 'linux'");

assert_eq!(
m("(extra == 'x' and extra == 'y') or (extra != 'x' and extra == 'z')")
.resolve_extras_with_bounds([
Expand Down Expand Up @@ -2499,13 +2432,16 @@ mod test {
m("sys_platform == 'linux' or sys_platform == 'darwin'"),
),
)];

assert_eq!(
m("extra != 'a'").resolve_extras_with_bounds(known.clone()),
(
m("sys_platform != 'linux' and sys_platform != 'darwin'"),
m("sys_platform != 'linux'"),
)
);

// Missing extras are inactive, including in negated expressions.
assert_eq!(
m("extra == 'missing'").resolve_extras_with_bounds(known.clone()),
(MarkerTree::FALSE, MarkerTree::FALSE)
Expand All @@ -2520,6 +2456,7 @@ mod test {
#[test]
fn resolve_extras_with_bounds_environment_conditions() {
let marker = m("platform_release >= '24' and (extra == 'x' or extra == 'y')");

assert_eq!(
marker.resolve_extras_with_bounds([
(
Expand Down Expand Up @@ -2548,45 +2485,39 @@ mod test {
);
}

/// Exact bounds agree with ordinary simultaneous substitution for every decision kind.
/// Exact substitution retains each environment decision kind and leaves replacement extras alone.
#[test]
fn resolve_extras_with_bounds_exact() {
fn resolve_extras_with_bounds_substitutes_simultaneously() {
let condition = m("sys_platform == 'darwin' or extra == 'b'");
let known = [
(
"a".parse().expect("valid extra name"),
m("sys_platform == 'darwin' or extra == 'b'"),
(condition, condition),
),
(
"b".parse().expect("valid extra name"),
(MarkerTree::FALSE, MarkerTree::FALSE),
),
("b".parse().expect("valid extra name"), MarkerTree::FALSE),
];
for marker in [
"extra == 'a'",
"extra != 'a'",
"python_version >= '3.10' and extra == 'a'",
"implementation_name == 'cpython' and extra == 'a'",
"platform_release >= '24' and extra == 'a'",
"'python' in implementation_name and extra == 'a'",
"'dev' in dependency_groups and extra == 'a'",
"extra == 'missing' or extra == 'a'",
] {
let marker = m(marker);
let expected = marker.resolve_extras(known.clone());
assert_eq!(
marker.resolve_extras_with_bounds(
known
.iter()
.map(|(name, value)| (name.clone(), (*value, *value)))
),
(expected, expected)
);
assert_eq!(
marker.negate().resolve_extras_with_bounds(
known
.iter()
.map(|(name, value)| (name.clone(), (*value, *value)))
),
(expected.negate(), expected.negate())
);
}
let marker = m("python_version >= '3.10'
and implementation_name == 'cpython'
and platform_release >= '24'
and platform_machine in 'x86_64,aarch64'
and 'beta' in platform_version
and 'dev' in dependency_groups
and extra == 'a'");
let expected = m("python_version >= '3.10'
and implementation_name == 'cpython'
and platform_release >= '24'
and platform_machine in 'x86_64,aarch64'
and 'beta' in platform_version
and 'dev' in dependency_groups
and (sys_platform == 'darwin' or extra == 'b')");

assert_eq!(
marker.resolve_extras_with_bounds(known),
(expected, expected)
);
}

/// Replacement iterators can acquire the interner lock, and are unnecessary without extras.
Expand All @@ -2601,11 +2532,13 @@ mod test {
)
});
let environment = m("python_version >= '3.10'");

assert_eq!(
environment.resolve_extras_with_bounds(replacements.clone()),
(environment, environment)
);
assert_eq!(replacements_built.get(), 0);

assert_eq!(
m("python_version >= '3.10' and extra == 'a'").resolve_extras_with_bounds(replacements),
(
Expand All @@ -2616,32 +2549,41 @@ mod test {
assert_eq!(replacements_built.get(), 1);
}

/// The shared diagram has more than 16 million DNF paths but only two decisions per pair.
/// Shared subgraphs and their complements must retain distinct activation bounds.
#[test]
fn resolve_extras_with_bounds_shared_subgraphs() {
let condition = m("sys_platform == 'darwin'");
let mut known = Vec::new();
let mut marker = MarkerTree::TRUE;
for index in 0..24 {
let left = format!("pair-{index:02}-a");
let right = format!("pair-{index:02}-b");
marker = marker.and(m(&format!("extra == '{left}' or extra == '{right}'")));
known.push((
left.parse().expect("valid extra name"),
let known = [
(
"a".parse().expect("valid extra name"),
(MarkerTree::FALSE, MarkerTree::TRUE),
));
known.push((
right.parse().expect("valid extra name"),
),
(
"b".parse().expect("valid extra name"),
(condition, condition),
));
}
assert_eq!(
marker.resolve_extras_with_bounds(known.clone()),
(condition, MarkerTree::TRUE)
);
),
(
"c".parse().expect("valid extra name"),
(MarkerTree::FALSE, MarkerTree::TRUE),
),
(
"d".parse().expect("valid extra name"),
(condition, condition),
),
];
let marker = m("(implementation_name == 'cpython'
and (extra == 'a' or extra == 'b')
and (extra == 'c' or extra == 'd'))
or (implementation_name != 'cpython'
and ((extra != 'a' and extra != 'b')
or (extra != 'c' and extra != 'd')))");

assert_eq!(
marker.negate().resolve_extras_with_bounds(known),
(MarkerTree::FALSE, condition.negate())
marker.resolve_extras_with_bounds(known),
(
m("implementation_name == 'cpython' and sys_platform == 'darwin'"),
m("implementation_name == 'cpython' or sys_platform != 'darwin'"),
)
);
}

Expand Down
Loading
Loading
⌂ 换网址