File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed
Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog][kac] and this project adheres to
1414
1515* ` shfmt ` all files and enforce via CI (#651 )
1616* avoid kernel warning flood/hang with CTRL+C on Bash 5.2 RC (#656 )
17+ * Fix infinite wait with (invalid) ` -j<n> ` (without space) (#657 )
1718
1819## [ 1.8.0] - 2022-09-15
1920
Original file line number Diff line number Diff line change @@ -285,6 +285,11 @@ bats_read_tests_list_file() {
285285bats_run_tests () {
286286 bats_exec_file_status=0
287287
288+ if [[ " $num_jobs " -lt 1 ]]; then
289+ printf ' Invalid number of jobs: %s\n' " $num_jobs " >&2
290+ exit 1
291+ fi
292+
288293 if [[ " $num_jobs " != 1 && " ${BATS_NO_PARALLELIZE_WITHIN_FILE-False} " == False ]]; then
289294 export BATS_SEMAPHORE_NUMBER_OF_SLOTS=" $num_jobs "
290295 bats_run_tests_in_parallel " $BATS_RUN_TMPDIR /parallel_output" || bats_exec_file_status=1
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ bats_require_minimum_version 1.5.0
55load test_helper
66fixtures parallel
77
8+ # shellcheck disable=SC2034
9+ BATS_TEST_TIMEOUT=10 # only intended for the "short form ..."" test
10+
811setup () {
912 type -p parallel & > /dev/null || skip " --jobs requires GNU parallel"
1013 (type -p flock & > /dev/null || type -p shlock & > /dev/null) || skip " --jobs requires flock/shlock"
@@ -208,3 +211,10 @@ check_parallel_tests() { # <expected maximum parallelity>
208211@test " BATS_NO_PARALLELIZE_WITHIN_FILE does not work from inside test function" {
209212 DISABLE_IN_TEST_FUNCTION=1 reentrant_run ! bats --jobs 2 " $FIXTURE_ROOT /must_not_parallelize_within_file.bats"
210213}
214+
215+ @test " Short form typo does not run endlessly" {
216+ unset BATS_NO_PARALLELIZE_ACROSS_FILES
217+ run bats -j2 " $FIXTURE_ROOT /../bats/passing.bats"
218+ (( SECONDS < 5 ))
219+ [ " ${lines[1]} " = ' Invalid number of jobs: -2' ]
220+ }
Original file line number Diff line number Diff line change @@ -23,3 +23,7 @@ bats_require_minimum_version 1.5.0
2323 [ " ${lines[3]} " == " # \` sleep \"\$ {SLEEP?}\" ' failed due to timeout" ]
2424 (( SECONDS < 10 )) || false
2525}
26+
27+ @test " sleep in run" {
28+ run sleep 10
29+ }
You can’t perform that action at this time.
0 commit comments