Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions changelog.d/+staged-before-build.bugfix.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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(),
Expand Down
32 changes: 32 additions & 0 deletions tests/run_stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"#;

Expand Down Expand Up @@ -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::<i64>().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");
Expand Down
Loading