Skip to content

Commit

Permalink
test/parallel: add a test for negative jobs number arguments
Browse files Browse the repository at this point in the history
Before commit 48b0d26, -j2 and -j -2 both triggered an infinite
loop. That commit fixed the infinite loop but -j2 and -j -2 are still
parsed the same. In the corresponding code review bats-core#657 Martin expressed
an intent to change the parser and parse these differently in the
future.

In commit 0ec3619 Martin added a "no infinite loop" test for
"-j2". However this test will stop testing negative arguments when the
parser changes (the test will also have to be adjusted when the parser
changes).

Add one additional test with a "-j -3" argument that will test a
negative argument forever.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information
marc-hb committed Jan 24, 2023
1 parent 5a47c79 commit cc22e67
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/parallel.bats
Expand Up @@ -218,3 +218,10 @@ check_parallel_tests() { # <expected maximum parallelity>
(( SECONDS < 5 ))
[ "${lines[1]}" = 'Invalid number of jobs: -2' ]
}

@test "Negative jobs number does not run endlessly" {
unset BATS_NO_PARALLELIZE_ACROSS_FILES
run bats -j -3 "$FIXTURE_ROOT/../bats/passing.bats"
(( SECONDS < 5 ))
[ "${lines[1]}" = 'Invalid number of jobs: -3' ]
}

0 comments on commit cc22e67

Please sign in to comment.