diff --git a/changelog.d/+staged-before-build.bugfix.md b/changelog.d/+staged-before-build.bugfix.md new file mode 100644 index 0000000..bcf60f4 --- /dev/null +++ b/changelog.d/+staged-before-build.bugfix.md @@ -0,0 +1 @@ +A rebuild line on a staged target that ran as plain `eb`, because its module file was missing, is recorded as plain `eb` even when the build installs that module file. The result file said it `ran through eb-staged-rebuild`, against the run log's WARN, and a failing build's exit 2 or 75 was read as an eb-staged-rebuild refusal (78) or pending ledger event. diff --git a/src/run.rs b/src/run.rs index 97f02c0..d5173f0 100644 --- a/src/run.rs +++ b/src/run.rs @@ -982,6 +982,8 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options) -> RunResult { break; } make_route_dirs(p, u.role, "build"); + // Before the build, which may install the module file it looks for. + let staged = p.is_staged(l); let cmd = match p.build_cmd(u.role, l, s) { Ok(c) => c, Err(f) => { @@ -1000,7 +1002,6 @@ pub fn run(planner: &Planner, lines: &[ListLine], opts: &Options) -> RunResult { return finish(st, Some(f.code)); } }; - let staged = p.is_staged(l); let mut lr = LineResult { easyconfig: l.easyconfig.clone(), unit: u.name.clone(), diff --git a/tests/run_stubs.rs b/tests/run_stubs.rs index 691f934..55be2e6 100644 --- a/tests/run_stubs.rs +++ b/tests/run_stubs.rs @@ -87,6 +87,13 @@ if [ -n "${STUB_EB_SLEEP:-}" ]; then exit 0 fi case ",${STUB_EB_FAIL:-}," in *",$stem,"*) echo "ERROR: $stem failed"; exit 1;; esac +# STUB_EB_INSTALLS names the module file a build installs, under +# install/modules/all; STUB_EB_CODE is the build's exit code. +if [ "$kind" = build ] && [ -n "${STUB_EB_INSTALLS:-}" ]; then + mkdir -p "$(dirname "$D/install/modules/all/$STUB_EB_INSTALLS")" + echo '-- module' > "$D/install/modules/all/$STUB_EB_INSTALLS" +fi +[ "$kind" = build ] && exit "${STUB_EB_CODE:-0}" exit 0 "#; @@ -1208,6 +1215,31 @@ fn a_staged_line_records_that_it_ran_through_eb_staged_rebuild() { } } +#[test] +fn a_rebuild_that_installs_its_module_ran_as_plain_eb() { + // No module file before the build, so plain eb runs; the module file it + // installs does not make the line a staged rebuild after the fact. + for (code, status, exit) in [("0", "success", 0), ("2", "failed", 1)] { + let env = setup("[rebuild]\nstaged = true\n"); + let o = go( + &env, + "Foo-1.0-foss-2025a.eb --rebuild\n", + &[ + ("STUB_EB_INSTALLS", "Foo/1.0-foss-2025a.lua"), + ("STUB_EB_CODE", code), + ], + ); + assert_eq!(o.code, exit, "{}", o.stderr); + let r = o.result.unwrap(); + let line = &r["lines"][0]; + assert_eq!(line["status"], status, "{line}"); + assert_eq!(line["exit_code"], code.parse::().unwrap(), "{line}"); + assert!(line.get("note").is_none(), "{line}"); + assert!(calls(&env, "staged.calls").is_empty()); + assert_eq!(calls(&env, "eb.calls").len(), 1); + } +} + #[test] fn target_can_override_staged() { let env = setup("[rebuild]\nstaged = true\n");