diff --git a/changelog.d/+short-force.bugfix.md b/changelog.d/+short-force.bugfix.md new file mode 100644 index 00000000..3857cc7c --- /dev/null +++ b/changelog.d/+short-force.bugfix.md @@ -0,0 +1 @@ +`stack shard` counts `-f`, EasyBuild's short form of `--force`, as forcing a rebuild, as it counts `--force` and `--rebuild`. A line that rebuilt an installed module with `-f` was planned as building nothing: the module had no weight and was in no closure, so a line that needs it could land in another shard and build while `eb -f` rebuilt it. diff --git a/docs/orgmode/reference/cli.org b/docs/orgmode/reference/cli.org index b43536a5..5f43beff 100644 --- a/docs/orgmode/reference/cli.org +++ b/docs/orgmode/reference/cli.org @@ -883,8 +883,9 @@ path minus the installed modules, as ~pr-overlap~ computes a root's set. Installed modules come from ~--installed-modules-dir~, an Lmod ~modules/all~ tree read as ~Name/Version~ (EESSI's tree for the CPU target and the site tree, for example), and from ~--installed~ lists, one -~Name/VersionFull~ per line; both repeat. A line with ~--rebuild~ or -~--force~ builds its own module even when it is installed. Two lines share +~Name/VersionFull~ per line; both repeat. A line with ~--rebuild~, +~--force~ or its short form ~-f~ builds its own module even when it is +installed. Two lines share a shard only when one line's easyconfig is in the other's set, or both name the same easyconfig; the line that is needed comes first. Every other module the sets of two or more shards need goes to the prelude, so the shards' diff --git a/llms-full.txt b/llms-full.txt index 7cb9a62a..553998e0 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -7586,8 +7586,9 @@ path minus the installed modules, as `pr-overlap` computes a root's set. Installed modules come from `--installed-modules-dir`, an Lmod `modules/all` tree read as `Name/Version` (EESSI's tree for the CPU target and the site tree, for example), and from `--installed` lists, one -`Name/VersionFull` per line; both repeat. A line with `--rebuild` or -`--force` builds its own module even when it is installed. Two lines share +`Name/VersionFull` per line; both repeat. A line with `--rebuild`, +`--force` or its short form `-f` builds its own module even when it is +installed. Two lines share a shard only when one line's easyconfig is in the other's set, or both name the same easyconfig; the line that is needed comes first. Every other module the sets of two or more shards need goes to the prelude, so the shards' diff --git a/src/shard.rs b/src/shard.rs index 8e9260b6..154d1719 100644 --- a/src/shard.rs +++ b/src/shard.rs @@ -33,8 +33,8 @@ pub struct ShardLine { pub text: String, /// The first word, the easyconfig filename. pub file: String, - /// Whether the line forces a rebuild (`--rebuild` or `--force`), so its - /// own module counts as not installed. + /// Whether the line forces a rebuild (`--rebuild`, `--force` or its short + /// form `-f`), so its own module counts as not installed. pub forced: bool, /// Whether EasyBuild fetches the line's easyconfig itself /// (`--from-pr` or `--from-commit`), so it need not be on the robot path. @@ -139,7 +139,9 @@ pub fn parse_lines(text: &str) -> Vec { .iter() .map(|w| w.split('=').next().unwrap_or(w)) .collect(); - let forced = keys.iter().any(|k| *k == "--rebuild" || *k == "--force"); + let forced = keys + .iter() + .any(|k| matches!(*k, "--rebuild" | "--force" | "-f")); let fetched = keys .iter() .any(|k| *k == "--from-pr" || *k == "--from-commit"); @@ -539,6 +541,13 @@ mod tests { assert!(!lines[0].fetched && !lines[1].fetched); } + #[test] + fn rebuild_force_and_its_short_form_force_a_line() { + let lines = parse_lines("A-1.eb --rebuild\nB-2.eb --force\nC-3.eb -f\nD-4.eb --hooks=-f\n"); + let forced: Vec = lines.iter().map(|line| line.forced).collect(); + assert_eq!(forced, [true, true, true, false]); + } + #[test] fn from_pr_and_from_commit_lines_are_fetched() { let lines = parse_lines( diff --git a/tests/stack_shard.rs b/tests/stack_shard.rs index 5a9a54a1..3715280c 100644 --- a/tests/stack_shard.rs +++ b/tests/stack_shard.rs @@ -154,6 +154,38 @@ fn wave_one_splits_into_three_shards_and_a_prelude() { ); } +#[test] +fn a_short_force_line_rebuilds_its_module_before_the_line_that_needs_it() { + let tmp = tempfile::tempdir().unwrap(); + let out = tmp.path().join("shards"); + let run = shard("force.list", &out, &["--shards", "4"]); + assert!( + run.status.success(), + "{}", + String::from_utf8_lossy(&run.stderr) + ); + // CMake is installed, but `-f` rebuilds it, so Szip's closure has it and + // the two lines share a shard with CMake first, as for `--force`. + assert_eq!( + String::from_utf8_lossy(&run.stdout), + "shards=1 prelude=0 lines=2\n" + ); + assert_eq!( + listing(&out), + ["plan.json", "prelude.list", "shard-01.list"] + ); + assert_eq!( + read(out.join("shard-01.list")), + "CMake-3.31.8-GCCcore-15.2.0.eb -f\nSzip-2.1.1-GCCcore-15.2.0.eb\n" + ); + let plan: Value = serde_json::from_str(&read(out.join("plan.json"))).unwrap(); + assert_eq!( + plan["lines"][0]["closure"], + serde_json::json!(["CMake/3.31.8-GCCcore-15.2.0"]) + ); + assert_eq!(plan["shards"][0]["weight"], 2); +} + #[test] fn weights_balance_the_shards_by_time() { let tmp = tempfile::tempdir().unwrap(); diff --git a/tests/stack_shard_fixtures/force.list b/tests/stack_shard_fixtures/force.list new file mode 100644 index 00000000..fb3738aa --- /dev/null +++ b/tests/stack_shard_fixtures/force.list @@ -0,0 +1,3 @@ +# CMake is installed; -f is EasyBuild's short form of --force +CMake-3.31.8-GCCcore-15.2.0.eb -f +Szip-2.1.1-GCCcore-15.2.0.eb