diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-17 21:24:45 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-17 21:24:45 +0300 |
| commit | 6109e2a6f5bc45c3c4080259bd09a1e3dc48ea4d (patch) | |
| tree | dd862d7319be1c6a8b8ac24d15cd3518bd192c4e /tests/cli.sh | |
| parent | 5ebee8ef2a54b8578daf47b17fa82fc85b2cd1cd (diff) | |
on0 remove run_action_body serialization runner
Shuriken is a single-process CLI, yet the action layer could serialize 30+
globals plus every function definition (declare -p / declare -f) and pipe them
into a fresh "bash -euo pipefail" process to run an action. Production already
forced the in-process run_action_body_direct via SHURIKEN_ACTION_BODY_RUNNER, so
the serialized-subprocess path was dead in production and only added complexity
(a hand-maintained variable list to keep in sync). Per KISS, drop it.
- Remove run_action_body_context and the run_action_body dispatcher.
- Collapse run_configured_action_body to call the action in-process directly and
remove the SHURIKEN_ACTION_BODY_RUNNER indirection in main().
- Move the only genuinely needed isolation into a test-only shim
(test::run_action_isolated in tests/helpers.sh) for the generate real-failure
test, which must capture a failure status without the in-process errexit abort
ending the caller (correct in production, where main runs under errexit).
- Update the errexit/status-propagation tests to exercise the direct path.
Template-engine serialization is unrelated and left untouched.
just test, just shellcheck, just check-generated and git diff --check all pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/cli.sh')
| -rwxr-xr-x | tests/cli.sh | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/cli.sh b/tests/cli.sh index a28c1f1..2ca65ce 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -2428,7 +2428,10 @@ SHURIKEN_CLI_OVERRIDES=() SHURIKEN_CLI_SYNC_DESTINATIONS=() SHURIKEN_FORCE_GENERATE=no -set +e +# Production runs the action in-process under "set -euo pipefail" (main calls +# run_action with errexit active), so an internal failure inside the action body +# aborts immediately. Leave errexit ON here (no "set +e") to exercise that real +# path: dry_run's "false" must abort before the "dry_run continued" write. run_configured_action BASH ) @@ -2479,8 +2482,12 @@ export continued_file success_file # shellcheck source=/dev/null source <(sed '$d' "$shuriken") +# The action runs in-process; a failing action must return a non-zero status so +# a status-tested caller (the "if" below) takes the failure branch. "return 1" +# fails honestly regardless of the caller's errexit state, and the write after +# it must never run. dry_run() { - false + return 1 printf 'dry_run continued\n' > "$continued_file" } @@ -2544,8 +2551,12 @@ export continued_file success_file # shellcheck source=/dev/null source <(sed '$d' "$shuriken") +# The action runs in-process; a failing action must return a non-zero status so +# a status-tested caller (the "if" below) takes the failure branch. "return 1" +# fails honestly regardless of the caller's errexit state, and the write after +# it must never run. dry_run() { - false + return 1 printf 'dry_run continued\n' > "$continued_file" } @@ -2601,15 +2612,19 @@ test_generate_real_failure_returns_with_errexit_disabled() { "$config_file" \ "$fake_bin" \ "$status_file" \ + "$TEST_REPO_ROOT/tests/helpers.sh" \ 2>&1 \ <<'BASH' shuriken="$1"; shift config_file="$1"; shift fake_bin="$1"; shift status_file="$1"; shift +helpers="$1"; shift # shellcheck source=/dev/null source <(sed '$d' "$shuriken") +# shellcheck source=/dev/null +source "$helpers" PATH="$fake_bin:$PATH" SHURIKEN_CLI_ACTION=--generate @@ -2619,8 +2634,11 @@ SHURIKEN_CLI_OVERRIDES=() SHURIKEN_CLI_SYNC_DESTINATIONS=() SHURIKEN_FORCE_GENERATE=no +# A real generation failure aborts the shell in production (main runs under +# errexit, by design). To capture the failure status and keep asserting, run the +# action in the test-only isolation shim. The status it returns must be nonzero. set +e -run_configured_action +test::run_action_isolated run_configured_action generate_status=$? printf '%s\n' "$generate_status" > "$status_file" exit 0 |
