]> git.notmuchmail.org Git - notmuch/blobdiff - test/notmuch-test
tests: run all tests in parallel, if available
[notmuch] / test / notmuch-test
index 1a1ae811cada6264ba644d3a5c4c7f258ef3418d..a4b7a1eb0b54dfbbda2c24ce7603424e7ed887c3 100755 (executable)
@@ -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