diff --git a/test/run b/test/run index cf71259b..88202916 100755 --- a/test/run +++ b/test/run @@ -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