Skip to content

docs(patterns): stop showing assertions that can never fail - #1212

Merged
Chemaclass merged 1 commit into
mainfrom
docs/1211-vacuous-exit-code-examples
Aug 14, 2026
Merged

Chemaclass merged 1 commit into
mainfrom
docs/1211-vacuous-exit-code-examples

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1211

assert_successful_code / assert_general_error read $? and do not run a
string handed to them. Seven examples in the guide users copy from passed one
anyway, so the assertion could never fail:

assert_successful_code "false"                         ✓ Passed
assert_successful_code "definitely_not_a_command_xyz"  ✓ Passed

A copied "test the server responds to ping" test verified nothing. Worse than
#1209, where swapped arguments at least failed loudly.

💡 Changes

Deliberately left alone

assert_successful_code "$(sync_with_the_api)" elsewhere is correct: the
substitution runs the command, so $? carries. Both shapes executed to confirm:

shape failing command
"$(failing_fn)" ✗ Failed — correct
"failing_fn" ✓ Passed — vacuous

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
@Chemaclass Chemaclass added the documentation Improvements or additions to documentation label Aug 14, 2026
@Chemaclass Chemaclass self-assigned this Aug 14, 2026
@Chemaclass
Chemaclass merged commit ca7d7d3 into main Aug 14, 2026
6 checks passed
@Chemaclass
Chemaclass deleted the docs/1211-vacuous-exit-code-examples branch August 14, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant