Uh oh!
There was an error while loading. Please reload this page.
docs(patterns): stop showing assertions that can never fail - #1212
Merged
Conversation
assert_successful_code and assert_general_error read $?; they do not run a string handed to them, as assertions.md states. Seven examples passed a command string anyway, so the string was ignored, $? was 0, and the assertion could never fail: assert_successful_code "false" passes assert_successful_code "definitely_not_a_command_xyz" passes A copied 'test the server responds' test therefore verified nothing. Worse than the swapped arguments in #1209, which at least failed loudly. Replaced with assert_exec, which executes the string and, since #1208, handles a non-zero exit under --strict. Verified with shell functions, a pipeline and both modes. The "$(cmd)" forms in test-files.md, skipping-incomplete.md and test-doubles.md are correct -- the substitution runs the command so $? carries -- and are left alone. Both shapes were executed to confirm the difference. Closes#1211
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 #1211
assert_successful_code/assert_general_errorread$?and do not run astring handed to them. Seven examples in the guide users copy from passed one
anyway, so the assertion could never fail:
A copied "test the server responds to ping" test verified nothing. Worse than
#1209, where swapped arguments at least failed loudly.
💡 Changes
assert_exec, which executes the string and — since fix(assert): let assert_exec assert a non-zero exit under --strict #1208 — handles a non-zero exit under--strict. Verified with shell functions, a pipeline, and both modesDeliberately left alone
assert_successful_code "$(sync_with_the_api)"elsewhere is correct: thesubstitution runs the command, so
$?carries. Both shapes executed to confirm:"$(failing_fn)""failing_fn"