Uh oh!
There was an error while loading. Please reload this page.
fix(assert): let assert_exec assert a non-zero exit under --strict - #1208
Merged
Conversation
assert_exec ran the command with eval "$cmd" >"$stdout_file" 2>"$stderr_file" local exit_code=$? and --strict enables set -e, so a command exiting non-zero aborted the test function on the eval and never reached the next line. The one assertion whose job is checking an exit code could not check a failing one. Successful commands were unaffected, which is why it went unnoticed. Capture the status in both branches: local exit_code=0 first, then '|| exit_code=$?'. Declaring and assigning together would mask the status behind local's own. Found by executing docs/common-patterns.md 'Testing Failure Cases' under --strict, where both documented forms failed. The other one is the $?-capture trap documented in #1170; this was a real defect underneath it, so the guide's recommended form now works as written. Closes#1207
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 freeto 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.
🤔 Background
Related #1207
--strictSuccessful commands were unaffected in both modes, which is why it went
unnoticed — only the failing case breaks, and that is the whole point of
--exit 1.💡 Changes
local exit_code=0then|| exit_code=$?. Declaring and assigning together would mask it behindlocal's own statusHow it surfaced
Executing
docs/common-patterns.md→ "Testing Failure Cases" under--strict:both documented forms failed. The second is the
$?-capture trap alreadydocumented in #1170; the first was this defect. With it fixed the guide's
recommended form works as written, so no doc change is needed.