Skip to content

Commit 33494d7

Browse files
cailmdaleyclaude
andcommitted
Propagate shapepipe_run's exit code (main must return run's value)
`main()` called `run(args)` but discarded its return value, so `exit(main())` was always `exit(None)` → 0. `run()` returns 1 when it catches an error (`catch_error` + `return 1`), so *every* handled failure has been exiting 0 — invisible to `exit $?` in the job scripts and to any CI/automation. One-word fix: `return run(args)`. Add a regression test that main forwards run's value. Surfaced while end-to-end testing the MPI singleton guard: the guard fired and logged loudly but the job still exited 0 until this fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e82de0e commit 33494d7

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/shapepipe/shapepipe_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def main(args=None):
1717

18-
run(args)
18+
return run(args)
1919

2020

2121
if __name__ == "__main__":

tests/unit/test_entrypoints.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,18 @@ def test_console_entrypoint_help_runs(entrypoint):
4747

4848
assert result.returncode == 0, result.stderr
4949
assert "usage:" in result.stdout.lower()
50+
51+
52+
@pytest.mark.parametrize("exit_code", [1, None])
53+
def test_main_propagates_run_exit_code(monkeypatch, exit_code):
54+
"""``main`` must forward ``run``'s return value.
55+
56+
``run`` returns 1 when it catches an error; if ``main`` drops that,
57+
``exit(main())`` becomes ``exit(0)`` and every handled failure looks like
58+
success to the batch system.
59+
"""
60+
import shapepipe.shapepipe_run as entry
61+
62+
monkeypatch.setattr(entry, "run", lambda args=None: exit_code)
63+
64+
assert entry.main() == exit_code

0 commit comments

Comments
 (0)