perf(runner): outvar pattern in hot-path result helpers#672
Merged
Conversation
4 tasks
Convert bashunit::runner::extract_encoded_field, extract_subshell_type, format_subshell_output, compute_total_assertions to write to a caller-named outvar instead of stdout. Update the four call sites in run_test to pass a target variable name, eliminating one fork+pipe per call per test. Internal locals use a __bu_ prefix to avoid name collisions with caller variables passed by name (e.g. 'format_subshell_output subshell_output ...'). Adds direct unit tests for each helper covering the new signature. Closes #662
5886beb to
bdbfd33
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bashunit::runner::*helpers used per test inrun_testto the outvar pattern (first arg is the name of the variable to assign into).extract_encoded_field,extract_subshell_type,format_subshell_output,compute_total_assertions.$(...)capture call sites inrun_testto pass the target variable name, eliminating one fork+pipe per call per test.Implementation notes
__bu_prefix to avoid name collisions with caller variables passed by name (e.g.format_subshell_output subshell_output "$subshell_output"). The first iteration without this prefix caused the localsubshell_outputto shadow the caller's, swallowing the assignment — surfaced by 12 parallel failures.eval "$_out=\$_val"keeps the assignment Bash 3.0+ safe (noprintf -v, no namrefs).Test plan
tests/unit/runner_test.sh: empty/missing keys, multi-counter sum, subshell-type stripping, marker → newline expansion./bashunit tests/green (1060 passed, 3m21s — down from ~3m baseline)./bashunit --parallel tests/green (1055 passed, ~45s)make sacleanmake lintcleanCloses #662