diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-16 17:11:44 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-16 17:11:44 +0300 |
| commit | 1309aff1606f7ec0f63b8b80a0b2d15d41697de9 (patch) | |
| tree | 60cc870890e05fe1b89379c849a30554015e68e4 /tests | |
| parent | 68aadbbc3469d81f2adff8cb1d3052db4f75fe5b (diff) | |
un0 build template context file without declare -f or a bash subprocess
source_template_file previously built the BASH_ENV context file by piping
"declare -p ...; declare -f; serialize_template_render_context ...;" into a
fresh "bash -euo pipefail" subprocess for every rendered page. That dumped all
~5000 lines of shuriken functions and spawned a subprocess per page just to run
the serializer - a large per-page cost for albums with hundreds-to-thousands of
pages.
Now serialize_template_render_context runs in the current shell with stdout
redirected straight into the context tempfile, followed by an appended
"unset BASH_ENV". The serializer returns its own non-zero status explicitly so
the failure is detected via an "if" status-test (which returns normally through
the RETURN trap and cleans up the partial context file), robust even when
source_template_file runs inside a status-tested "if template ..." call chain
where bash would otherwise suppress an inner errexit abort.
The trap-based cleanup (RETURN plus INT/TERM/HUP re-raising to $BASHPID) is
preserved unchanged. Two serializer test mocks that relied on the removed
"| bash" errexit now return non-zero explicitly. Rendered HTML output is
unchanged; 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')
| -rwxr-xr-x | tests/cli.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/cli.sh b/tests/cli.sh index 1dac04a..8727532 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -4433,8 +4433,12 @@ SHURIKEN_FAKE_CONTEXT_FILE="$context_file" export SHURIKEN_FAKE_CONTEXT_FILE serialize_template_render_context() { - false + # Simulate a serializer that writes some output and then fails. The new + # implementation propagates this non-zero status explicitly (it no longer + # relies on a "| bash -euo pipefail" subprocess), so source_template_file + # must detect the failure, skip the render and clean up the context file. printf 'partial_context=yes\n' + return 1 } # shellcheck disable=SC2034 @@ -4518,8 +4522,12 @@ SHURIKEN_OUTPUT_MODE=quiet apply_config_defaults serialize_template_render_context() { - false + # Simulate a serializer that writes some output and then fails. The new + # implementation propagates this non-zero status explicitly (it no longer + # relies on a "| bash -euo pipefail" subprocess), so source_template_file + # must detect the failure, skip the render and clean up the context file. printf 'partial_context=yes\n' + return 1 } if template preview out.html \ |
