Skip to content

Commit 8a9bf94

Browse files
committed
perf(runner): replace state getter subshells with direct variable access
Eliminate 5 subshell forks per test by accessing global state variables directly instead of calling getter functions via $() command substitution.
1 parent cf63216 commit 8a9bf94

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/runner.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ function bashunit::runner::run_test() {
762762
return
763763
fi
764764

765-
if [[ "$current_assertions_failed" != "$(bashunit::state::get_assertions_failed)" ]]; then
765+
if [[ "$current_assertions_failed" != "$_BASHUNIT_ASSERTIONS_FAILED" ]]; then
766766
bashunit::state::add_tests_failed
767767
bashunit::reports::add_test_failed "$test_file" "$label" "$duration" "$total_assertions" "$subshell_output"
768768
bashunit::runner::write_failure_result_output "$test_file" "$fn_name" "$subshell_output"
@@ -779,7 +779,7 @@ function bashunit::runner::run_test() {
779779
return
780780
fi
781781

782-
if [[ "$current_assertions_snapshot" != "$(bashunit::state::get_assertions_snapshot)" ]]; then
782+
if [[ "$current_assertions_snapshot" != "$_BASHUNIT_ASSERTIONS_SNAPSHOT" ]]; then
783783
bashunit::state::add_tests_snapshot
784784
# In failures-only mode, suppress snapshot test output
785785
if ! bashunit::env::is_failures_only_enabled; then
@@ -790,15 +790,15 @@ function bashunit::runner::run_test() {
790790
return
791791
fi
792792

793-
if [[ "$current_assertions_incomplete" != "$(bashunit::state::get_assertions_incomplete)" ]]; then
793+
if [[ "$current_assertions_incomplete" != "$_BASHUNIT_ASSERTIONS_INCOMPLETE" ]]; then
794794
bashunit::state::add_tests_incomplete
795795
bashunit::reports::add_test_incomplete "$test_file" "$label" "$duration" "$total_assertions"
796796
bashunit::runner::write_incomplete_result_output "$test_file" "$fn_name" "$subshell_output"
797797
bashunit::internal_log "Test incomplete" "$label"
798798
return
799799
fi
800800

801-
if [[ "$current_assertions_skipped" != "$(bashunit::state::get_assertions_skipped)" ]]; then
801+
if [[ "$current_assertions_skipped" != "$_BASHUNIT_ASSERTIONS_SKIPPED" ]]; then
802802
bashunit::state::add_tests_skipped
803803
bashunit::reports::add_test_skipped "$test_file" "$label" "$duration" "$total_assertions"
804804
bashunit::runner::write_skipped_result_output "$test_file" "$fn_name" "$subshell_output"
@@ -1228,7 +1228,7 @@ function bashunit::runner::record_test_hook_failure() {
12281228
local hook_message="$2"
12291229
local status="$3"
12301230

1231-
if [[ -n "$(bashunit::state::get_test_hook_failure)" ]]; then
1231+
if [[ -n "$_BASHUNIT_TEST_HOOK_FAILURE" ]]; then
12321232
return "$status"
12331233
fi
12341234

0 commit comments

Comments
 (0)