Skip to content

fix(runner): detect set_up failure when source file does not exist - #612

Merged
Chemaclass merged 1 commit into
mainfrom
fix/611-source-inexistent-file-makes-test-pass
Mar 19, 2026
Merged

fix(runner): detect set_up failure when source file does not exist#612
Chemaclass merged 1 commit into
mainfrom
fix/611-source-inexistent-file-makes-test-pass

Conversation

@Chemaclass

@ChemaclassChemaclass commented Mar 19, 2026

Copy link
Copy Markdown
Member

Summary

Fixes#611

  • Fix source of non-existent file in set_up() silently passing all tests
  • Save subshell stdout to FD 5 and restore it in EXIT trap to prevent leaked redirect from losing export_subshell_context output
  • Add sentinel variable _BASHUNIT_SETUP_COMPLETED to detect unexpected exit during set_up when $? is incorrectly 0

Root cause

When source of a non-existent file fails under set -eE (as used by execute_test_hook):

  1. The ERR trap does not fire (Bash behavior for special builtins)
  2. set -e kills the subshell, but the { hook } >file 2>&1 redirect from execute_test_hookleaks into the EXIT trap
  3. export_subshell_context output goes to the hook output file instead of stdout
  4. test_execution_result is empty → no failures detected → test silently passes

@ChemaclassChemaclass added the bug Something isn't working label Mar 19, 2026
@ChemaclassChemaclass self-assigned this Mar 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Contributor Report

User:@Chemaclass
Status: Trusted contributor (whitelisted)

This user is on the trusted contributors list and was automatically approved.

@Chemaclass
Chemaclassforce-pushed the fix/611-source-inexistent-file-makes-test-pass branch 7 times, most recently from 6a0949c to c4a2cf0CompareMarch 19, 2026 09:59
)
When `source` of a non-existent file fails under `set -eE` in a hook,
the ERR trap does not fire and bash exits the subshell with a leaked
stdout redirect, causing `export_subshell_context` output to be lost.
This made all tests silently pass.
Fix by saving the subshell's stdout to FD 5 and restoring it in the
EXIT trap, plus using a sentinel variable to detect unexpected exit
during set_up when $? is incorrectly 0.
@Chemaclass
Chemaclassforce-pushed the fix/611-source-inexistent-file-makes-test-pass branch from c4a2cf0 to 4ec3d90CompareMarch 19, 2026 10:27
@Chemaclass
Chemaclass merged commit d2ed146 into mainMar 19, 2026
26 checks passed
@Chemaclass
Chemaclass deleted the fix/611-source-inexistent-file-makes-test-pass branch March 19, 2026 10:50
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Source inexistent file makes test pass

1 participant

@Chemaclass