From be397a3d610872f3b30452b468921ec6fa46dd7d Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Thu, 16 Jul 2026 00:18:45 +0200 Subject: [PATCH] perf(runner): emit per-test result payload with printf, not cat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit export_subshell_context emitted the encoded result payload via a `cat < 1 `mkdir` forks per cold start). No behaviour change - Faster test runs: the runner detects a failed source (syntax error / unexpected EOF) and discovery detects the `.bash` pattern variant with shell `case` matches instead of `grep` forks (2 -> 0 `grep` forks per sourced test file). No behaviour change - Faster cold start: the base64 `-w` capability is detected with a shell `case` on `base64 --help` instead of piping into a `grep` fork (1 -> 0 `grep` forks per cold start). Same detection, no behaviour change diff --git a/src/state.sh b/src/state.sh index 52f91255..99a2b25f 100644 --- a/src/state.sh +++ b/src/state.sh @@ -262,7 +262,11 @@ function bashunit::state::export_subshell_context() { bashunit::state::encode_field "$_BASHUNIT_TEST_HOOK_MESSAGE" encoded_test_hook_message=$_BASHUNIT_STATE_ENCODED_OUT - cat <"$fixture" + + local trace + trace="$(PS4='+ ' bash -x ./bashunit --no-parallel "$fixture" 2>&1 >/dev/null)" + + local cat_forks + cat_forks="$(printf '%s\n' "$trace" | grep -cE '^\++ +/?[a-z/]*cat( |$)' || true)" + + assert_less_or_equal_than 1 "$cat_forks" +}