diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-12 15:36:53 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-12 15:36:53 +0300 |
| commit | 4bc2494fa2ed576e2e656402567df0f10c38460f (patch) | |
| tree | 5618d7322b49c207fdad11fb6930835d864b18ca | |
| parent | d5a58a1115bb3faa45caefeb053a5808406afa35 (diff) | |
Make run_action status-safe for bm0
| -rwxr-xr-x | bin/shuriken | 5 | ||||
| -rw-r--r-- | src/lib/action.source.sh | 3 | ||||
| -rwxr-xr-x | src/shuriken.sh | 2 | ||||
| -rwxr-xr-x | tests/cli.sh | 68 |
4 files changed, 72 insertions, 6 deletions
diff --git a/bin/shuriken b/bin/shuriken index 3c815ed..ff6173f 100755 --- a/bin/shuriken +++ b/bin/shuriken @@ -3413,8 +3413,7 @@ run_action() { fi ;; --clean|--generate|--refresh-splash|--sync|--dry-run|--print-config) - SHURIKEN_ACTION_BODY_RUNNER=run_action_body_direct \ - run_configured_action + run_configured_action status=$? if (( status != 0 )); then return "$status" @@ -3449,7 +3448,7 @@ main() { return "$status" fi - run_action + SHURIKEN_ACTION_BODY_RUNNER=run_action_body_direct run_action status=$? if (( status != 0 )); then return "$status" diff --git a/src/lib/action.source.sh b/src/lib/action.source.sh index 77b7f8c..a041c9a 100644 --- a/src/lib/action.source.sh +++ b/src/lib/action.source.sh @@ -271,8 +271,7 @@ run_action() { fi ;; --clean|--generate|--refresh-splash|--sync|--dry-run|--print-config) - SHURIKEN_ACTION_BODY_RUNNER=run_action_body_direct \ - run_configured_action + run_configured_action status=$? if (( status != 0 )); then return "$status" diff --git a/src/shuriken.sh b/src/shuriken.sh index 901b558..d8a6923 100755 --- a/src/shuriken.sh +++ b/src/shuriken.sh @@ -120,7 +120,7 @@ main() { return "$status" fi - run_action + SHURIKEN_ACTION_BODY_RUNNER=run_action_body_direct run_action status=$? if (( status != 0 )); then return "$status" diff --git a/tests/cli.sh b/tests/cli.sh index 42522a2..62cede8 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -2195,6 +2195,71 @@ BASH test::teardown } +test_generate_action_failure_fails_status_tested_run_action() { + local config_file + local continued_file + local output + local success_file + local -i status=0 + + test::setup + config_file="$TEST_TMPDIR/shuriken.conf" + continued_file="$TEST_TMPDIR/dry-run-continued" + success_file="$TEST_TMPDIR/action-success" + mkdir -p "$TEST_TMPDIR/incoming" + test::write_preflight_config \ + "$config_file" "$TEST_TMPDIR/incoming" "$TEST_TMPDIR/dist" \ + "$TEST_REPO_ROOT/share/templates/default" + + set +e + output=$( + bash -euo pipefail -s \ + "$TEST_SHURIKEN" \ + "$config_file" \ + "$continued_file" \ + "$success_file" \ + 2>&1 \ + <<'BASH' +shuriken="$1"; shift +config_file="$1"; shift +continued_file="$1"; shift +success_file="$1"; shift +export continued_file success_file + +# shellcheck source=/dev/null +source <(sed '$d' "$shuriken") + +dry_run() { + false + printf 'dry_run continued\n' > "$continued_file" +} + +SHURIKEN_CLI_ACTION=--dry-run +SHURIKEN_CLI_CONFIG_FILE="$config_file" +SHURIKEN_CLI_HAS_CONFIG_OVERRIDES=no +SHURIKEN_CLI_OVERRIDES=() +SHURIKEN_CLI_SYNC_DESTINATIONS=() +SHURIKEN_FORCE_GENERATE=no + +if run_action; then + printf 'run_action reported success\n' > "$success_file" +fi +BASH + ) + status=$? + set -e + + if (( status != 0 )); then + printf 'FAIL: expected child shell to finish status-tested action\n' >&2 + printf '%s\n' "$output" >&2 + exit 1 + fi + + test::assert_path_absent "$continued_file" + test::assert_path_absent "$success_file" + test::teardown +} + test_generate_real_failure_returns_with_errexit_disabled() { local config_file local fake_bin @@ -4637,6 +4702,9 @@ main() { '--generate action failure fails status-tested dispatcher' \ test_generate_action_failure_fails_status_tested_dispatcher test::run_case \ + '--generate action failure fails status-tested run_action' \ + test_generate_action_failure_fails_status_tested_run_action + test::run_case \ '--generate real failure returns with errexit disabled' \ test_generate_real_failure_returns_with_errexit_disabled test::run_case \ |
