From 0ec3619426f51f01e45e07e07dab5c8a6374b570 Mon Sep 17 00:00:00 2001 From: Martin Schulze Date: Wed, 5 Oct 2022 23:51:36 +0200 Subject: [PATCH] Add test --- test/parallel.bats | 10 ++++++++++ test/timeout.bats | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/test/parallel.bats b/test/parallel.bats index 8d140caad2..6bc94d2fc9 100644 --- a/test/parallel.bats +++ b/test/parallel.bats @@ -5,6 +5,9 @@ bats_require_minimum_version 1.5.0 load test_helper fixtures parallel +# shellcheck disable=SC2034 +BATS_TEST_TIMEOUT=10 # only intended for the "short form ..."" test + setup() { type -p parallel &>/dev/null || skip "--jobs requires GNU parallel" (type -p flock &>/dev/null || type -p shlock &>/dev/null) || skip "--jobs requires flock/shlock" @@ -208,3 +211,10 @@ check_parallel_tests() { # @test "BATS_NO_PARALLELIZE_WITHIN_FILE does not work from inside test function" { DISABLE_IN_TEST_FUNCTION=1 reentrant_run ! bats --jobs 2 "$FIXTURE_ROOT/must_not_parallelize_within_file.bats" } + +@test "Short form typo does not run endlessly" { + unset BATS_NO_PARALLELIZE_ACROSS_FILES + run bats -j2 "$FIXTURE_ROOT/../bats/passing.bats" + (( SECONDS < 5 )) + [ "${lines[1]}" = 'Invalid number of jobs: -2' ] +} diff --git a/test/timeout.bats b/test/timeout.bats index 1932c21e4c..79d10e42a2 100644 --- a/test/timeout.bats +++ b/test/timeout.bats @@ -23,3 +23,7 @@ bats_require_minimum_version 1.5.0 [ "${lines[3]}" == "# \`sleep \"\${SLEEP?}\"' failed due to timeout" ] ((SECONDS < 10)) || false } + +@test "sleep in run" { + run sleep 10 +}