Skip to content

Commit dee9fb2

Browse files
committed
test(miner): migrate backfill tests off hand-typed existing_versions
c9ee104 added existing_versions()/ExistingVersionsQuery as the intended producer for is_backfill()'s existing_versions argument, but left the two miner.rs tests that motivated it still hand-typing the expected Vec<String> (vec!["4.2.1".to_string()] / vec![]) instead of calling it against a real Candidate universe. Migrates both to build a small universe and query it, so the tests exercise the actual production path instead of asserting against a value nothing computes. Adds three unit tests for existing_versions() itself in eb_parse.rs (returns every match at the queried generation, empty for an absent package, excludes other toolchain generations of the same package) -- narrower scenarios than c9ee104's own existing_versions_filters_by_name_and_generation_newest_first, not a duplicate of it. Field names and types checked by hand against domain.rs's real Candidate/Toolchain definitions; not verified by a local build or test run (no cargo build on this laptop, no reachable remote builder this session -- CI on push is the actual verification here).
1 parent f86c0fa commit dee9fb2

2 files changed

Lines changed: 115 additions & 3 deletions

File tree

‎src/eb_parse.rs‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,6 +2165,82 @@ mod tests {
21652165
.any(|c| c.name == "OpenMPI" && c.version == "4.1.6"));
21662166
}
21672167

2168+
fn existing_versions_universe() -> Vec<Candidate> {
2169+
let gcccore = Toolchain {
2170+
name: "GCCcore".into(),
2171+
version: "15.2.0".into(),
2172+
};
2173+
let older = Toolchain {
2174+
name: "GCCcore".into(),
2175+
version: "14.3.0".into(),
2176+
};
2177+
let mk = |name: &str, version: &str, tc: &Toolchain| Candidate {
2178+
name: name.into(),
2179+
version: version.into(),
2180+
toolchain: tc.clone(),
2181+
versionsuffix: None,
2182+
easyconfig_path: String::new(),
2183+
dependencies: vec![],
2184+
builddependencies: vec![],
2185+
exts_list: vec![],
2186+
};
2187+
vec![
2188+
mk("CMake", "4.2.1", &gcccore),
2189+
mk("CMake", "3.31.10", &gcccore),
2190+
mk("CMake", "3.30.0", &older),
2191+
mk("Boost", "1.88.0", &older),
2192+
]
2193+
}
2194+
2195+
#[test]
2196+
fn existing_versions_returns_every_version_at_the_queried_generation() {
2197+
let universe = existing_versions_universe();
2198+
let generation = Toolchain {
2199+
name: "GCCcore".into(),
2200+
version: "15.2.0".into(),
2201+
};
2202+
let mut got = existing_versions(&ExistingVersionsQuery {
2203+
universe: &universe,
2204+
name: "CMake",
2205+
generation: &generation,
2206+
});
2207+
got.sort();
2208+
assert_eq!(got, vec!["3.31.10".to_string(), "4.2.1".to_string()]);
2209+
}
2210+
2211+
#[test]
2212+
fn existing_versions_is_empty_for_a_package_not_in_the_universe() {
2213+
let universe = existing_versions_universe();
2214+
let generation = Toolchain {
2215+
name: "GCCcore".into(),
2216+
version: "15.2.0".into(),
2217+
};
2218+
assert!(existing_versions(&ExistingVersionsQuery {
2219+
universe: &universe,
2220+
name: "LLVM",
2221+
generation: &generation,
2222+
})
2223+
.is_empty());
2224+
}
2225+
2226+
#[test]
2227+
fn existing_versions_excludes_other_generations_of_the_same_package() {
2228+
let universe = existing_versions_universe();
2229+
let generation = Toolchain {
2230+
name: "GCCcore".into(),
2231+
version: "15.2.0".into(),
2232+
};
2233+
let got = existing_versions(&ExistingVersionsQuery {
2234+
universe: &universe,
2235+
name: "Boost",
2236+
generation: &generation,
2237+
});
2238+
assert!(
2239+
got.is_empty(),
2240+
"Boost 1.88.0 sits at GCCcore-14.3.0 and must not answer a GCCcore-15.2.0 query, got {got:?}"
2241+
);
2242+
}
2243+
21682244
#[test]
21692245
fn strip_comments_preserves_hashes_in_strings() {
21702246
let s = "name = 'foo#bar'\n# comment\nversion = '1.0'\n";

‎src/miner.rs‎

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,21 @@ fn raw_line_diff(emitted: &str, target: &str) -> Vec<DiffLine> {
431431
#[cfg(test)]
432432
mod tests {
433433
use super::*;
434-
use crate::eb_parse::resolve_easyconfig_str;
434+
use crate::domain::{Candidate, Toolchain};
435+
use crate::eb_parse::{existing_versions, resolve_easyconfig_str, ExistingVersionsQuery};
436+
437+
fn backfill_candidate(name: &str, version: &str, toolchain: &Toolchain) -> Candidate {
438+
Candidate {
439+
name: name.into(),
440+
version: version.into(),
441+
toolchain: toolchain.clone(),
442+
versionsuffix: None,
443+
easyconfig_path: String::new(),
444+
dependencies: vec![],
445+
builddependencies: vec![],
446+
exts_list: vec![],
447+
}
448+
}
435449

436450
/// gompi-2026.1.eb, easybuilders/easybuild-easyconfigs PR #25613,
437451
/// merge commit f929f1f2ef4c15feb19692f33da59e9e1e072572. Real
@@ -506,7 +520,16 @@ moduleclass = 'mpi'
506520
// CMake-4.2.1-GCCcore-15.2.0.eb from an earlier PR. A plain string
507521
// compare of "3.31.11" vs "4.2.1" would (wrongly) rank 4.2.1 lower;
508522
// cmp_version must not make that mistake.
509-
let existing = vec!["4.2.1".to_string()];
523+
let generation = Toolchain {
524+
name: "GCCcore".into(),
525+
version: "15.2.0".into(),
526+
};
527+
let universe = vec![backfill_candidate("CMake", "4.2.1", &generation)];
528+
let existing = existing_versions(&ExistingVersionsQuery {
529+
universe: &universe,
530+
name: "CMake",
531+
generation: &generation,
532+
});
510533
assert!(
511534
is_backfill("3.31.11", &existing),
512535
"3.31.11 merging after 4.2.1 already exists at the same generation must be flagged as a backfill"
@@ -519,7 +542,20 @@ moduleclass = 'mpi'
519542
// GCC-15.2.0, with only 1.88.0 present at the prior generation
520543
// (GCC-14.3.0) in the merge-base tree, nothing newer already at
521544
// 15.2.0.
522-
let existing: Vec<String> = vec![];
545+
let generation = Toolchain {
546+
name: "GCC".into(),
547+
version: "15.2.0".into(),
548+
};
549+
let prior_generation = Toolchain {
550+
name: "GCC".into(),
551+
version: "14.3.0".into(),
552+
};
553+
let universe = vec![backfill_candidate("Boost", "1.88.0", &prior_generation)];
554+
let existing = existing_versions(&ExistingVersionsQuery {
555+
universe: &universe,
556+
name: "Boost",
557+
generation: &generation,
558+
});
523559
assert!(
524560
!is_backfill("1.90.0", &existing),
525561
"a version with nothing newer already in the tree at that generation is a clean bump, not a backfill"

0 commit comments

Comments
 (0)