aboutsummaryrefslogtreecommitdiff
path: root/test/notmuch-test
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@finestructure.net>2019-05-04 20:57:43 +0000
committerDavid Bremner <david@tethera.net>2019-05-07 06:54:09 -0300
commit908d930d221413633ab7541f97eb7cf07bfc4a91 (patch)
tree6fd70ee5b7d71a47fda4e1abf5750f13a7827aa3 /test/notmuch-test
parent591388ccd1d7c631d1f98694543d1a80fc521d9f (diff)
tests: run all tests in parallel, if available
If either the moreutils or GNU parallel utility are available, run all tests in parallel. On my eight core machine this makes for a ~x7 speed-up in the full test suite (1m24s -> 12s). The design of the test suite makes this parallelization trivial.
Diffstat (limited to 'test/notmuch-test')
-rwxr-xr-xtest/notmuch-test30
1 files changed, 20 insertions, 10 deletions
diff --git a/test/notmuch-test b/test/notmuch-test
index 1a1ae811..a4b7a1eb 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -40,17 +40,27 @@ fi
trap 'e=$?; kill $!; exit $e' HUP INT TERM
# Run the tests
-for test in $TESTS; do
- $TEST_TIMEOUT_CMD $test "$@" &
- wait $!
- # If the test failed without producing results, then it aborted,
- # so we should abort, too.
- RES=$?
- testname=$(basename $test .sh)
- if [[ $RES != 0 && ! -e "$NOTMUCH_BUILDDIR/test/test-results/$testname" ]]; then
- exit $RES
+if command -v parallel >/dev/null ; then
+ if parallel -h | grep -q GNU ; then
+ echo "INFO: running tests with GNU parallel"
+ printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel
+ else
+ echo "INFO: running tests with moreutils parallel"
+ $TEST_TIMEOUT_CMD parallel -- $TESTS
fi
-done
+else
+ for test in $TESTS; do
+ $TEST_TIMEOUT_CMD $test "$@" &
+ wait $!
+ # If the test failed without producing results, then it aborted,
+ # so we should abort, too.
+ RES=$?
+ testname=$(basename $test .sh)
+ if [[ $RES != 0 && ! -e "$NOTMUCH_BUILDDIR/test/test-results/$testname" ]]; then
+ exit $RES
+ fi
+ done
+fi
trap - HUP INT TERM
# Report results