Skip to content

Commit

Permalink
Merge pull request #599 from martin-schulze-vireso/fix/cleanup_run_=N…
Browse files Browse the repository at this point in the history
…_mess

Fix additional leftover instances of run =<N>
  • Loading branch information
martin-schulze-vireso committed May 24, 2022
2 parents 2025854 + 690ba7b commit 9695e7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog][kac] and this project adheres to
### Fixed

* added missing shebang (#597)
* remaining instances of `run -<N>` being incorrectly documented as `run =<N>` (#599)

#### Documentation

Expand Down
4 changes: 2 additions & 2 deletions lib/bats-core/test_functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ run() { # [!|-N] [--keep-empty-lines] [--separate-stderr] [--] <command to run..
-[0-9]*)
expected_rc=${1#-}
if [[ $expected_rc =~ [^0-9] ]]; then
printf "Usage error: run: '=NNN' requires numeric NNN (got: %s)\n" "$expected_rc" >&2
printf "Usage error: run: '-NNN' requires numeric NNN (got: %s)\n" "$expected_rc" >&2
return 1
elif [[ $expected_rc -gt 255 ]]; then
printf "Usage error: run: '=NNN': NNN must be <= 255 (got: %d)\n" "$expected_rc" >&2
printf "Usage error: run: '-NNN': NNN must be <= 255 (got: %d)\n" "$expected_rc" >&2
return 1
fi
;;
Expand Down
4 changes: 2 additions & 2 deletions test/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ print-stderr-stdout() {
[ "${lines[1]}" == "not ok 1 run '-4evah' echo hi" ]
[ "${lines[2]}" == "# (in test file ${RELATIVE_FIXTURE_ROOT}/invalid.bats, line 2)" ]
[ "${lines[3]}" == "# \`run '-4evah' echo hi' failed" ]
[ "${lines[4]}" == "# Usage error: run: '=NNN' requires numeric NNN (got: 4evah)" ]
[ "${lines[4]}" == "# Usage error: run: '-NNN' requires numeric NNN (got: 4evah)" ]
[ "${lines[5]}" == "not ok 2 run -256 echo hi" ]
[ "${lines[6]}" == "# (in test file ${RELATIVE_FIXTURE_ROOT}/invalid.bats, line 6)" ]
[ "${lines[7]}" == "# \`run -256 echo hi' failed" ]
[ "${lines[8]}" == "# Usage error: run: '=NNN': NNN must be <= 255 (got: 256)" ]
[ "${lines[8]}" == "# Usage error: run: '-NNN': NNN must be <= 255 (got: 256)" ]
}

0 comments on commit 9695e7c

Please sign in to comment.