Skip to content

fix(runner): fail test on syntax error instead of silent halt#628

Merged
Chemaclass merged 6 commits intomainfrom
fix/220-syntax-error-does-not-fail-test
Apr 19, 2026
Merged

fix(runner): fail test on syntax error instead of silent halt#628
Chemaclass merged 6 commits intomainfrom
fix/220-syntax-error-does-not-fail-test

Conversation

@Chemaclass
Copy link
Copy Markdown
Member

🤔 Background

Related #220

When a test file contained a Bash syntax error, source printed the error to stderr but the runner continued silently — tests after the error were dropped and the run still reported "All tests passed". Bug hid broken test files.

💡 Changes

  • Capture stderr and exit status of source "$test_file" in bashunit::runner::load_test_files
  • Detect syntax errors (also unexpected EOF) and record a source hook failure via record_file_hook_failure
  • Skip the faulty file cleanly and surface a failing test in the summary
  • Add acceptance test + fixture reproducing a syntax-error test file

Capture stderr and exit code of `source "$test_file"`. On syntax error
or non-zero exit, record a source hook failure and skip the file so the
suite surfaces the problem instead of continuing silently.

Closes #220
@Chemaclass Chemaclass added the bug Something isn't working label Apr 19, 2026
@Chemaclass Chemaclass self-assigned this Apr 19, 2026
@Chemaclass Chemaclass added the bug Something isn't working label Apr 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.

…n shellcheck

- Force LC_ALL=C/LANG=C in the acceptance test so bash's "syntax error"
  message stays English; assert on "Error" + "failed" which the runner
  renders regardless of locale.
- Exclude fixtures/test_bashunit_when_syntax_error.sh from the ShellCheck
  workflow; the fixture intentionally contains a parse error.
ShellCheck's find-based scanner matched the fixture even with ignore_paths,
so rename to .bash to keep it out of both the CI scanner and `make sa`.
ignore_paths only matches directory prefixes; ignore_names skips by
basename, which is what we need for a single fixture file.
@Chemaclass Chemaclass merged commit 1bcd003 into main Apr 19, 2026
30 checks passed
@Chemaclass Chemaclass deleted the fix/220-syntax-error-does-not-fail-test branch April 19, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants