Updated GNU parallel detection

Thanks to @rico-chet for the detection code!
pull/1559/head
Nils Winkler 2020-04-20 08:59:06 +02:00
parent 9269c4445d
commit 543e49b759
No known key found for this signature in database
GPG Key ID: 317C6E70C88A89B1
1 changed files with 8 additions and 1 deletions

View File

@ -16,7 +16,13 @@ else
test_dirs=( "$1" )
fi
if command -v parallel &> /dev/null
# Make sure that the `parallel` command is installed,
# AND that it is the GNU version of `parallel`.
# If that is the case, try to guess the number of CPU cores,
# so we can run `bats` in parallel processing mode, which is a lot faster.
if command -v parallel &> /dev/null \
&& parallel -V &> /dev/null \
&& { parallel -V 2> /dev/null | grep -q '^GNU\>'; }
then
# Expect to run at least on a dual-core CPU; slightly degraded performance
# shouldn't matter otherwise.
@ -37,5 +43,6 @@ then
exec "$bats_executable" ${CI:+--tap} --jobs ${test_jobs_effective} \
"${test_dirs[@]}"
else
# Run `bats` in single-threaded mode.
exec "$bats_executable" ${CI:+--tap} "${test_dirs[@]}"
fi