2010-12-01 21:27:52 +01:00
|
|
|
#!/usr/bin/env bash
|
2010-01-23 19:36:39 +01:00
|
|
|
|
2010-09-17 21:10:54 +02:00
|
|
|
# Run tests
|
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Junio C Hamano
|
2016-05-06 17:41:57 +02:00
|
|
|
# Copyright (c) 2010 Notmuch Developers
|
2010-09-17 21:10:54 +02:00
|
|
|
#
|
|
|
|
# Adapted from a Makefile to a shell script by Carl Worth (2010)
|
|
|
|
|
2010-10-28 21:07:42 +02:00
|
|
|
if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
|
|
|
|
echo "Error: The notmuch test suite requires a bash version >= 4.0"
|
|
|
|
echo "due to use of associative arrays within the test suite."
|
|
|
|
echo "Please try again with a newer bash (or help us fix the"
|
|
|
|
echo "test suite to be more portable). Thanks."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-09-25 22:38:27 +02:00
|
|
|
# Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
|
|
|
|
. $(dirname "$0")/export-dirs.sh || exit 1
|
2010-09-17 21:10:54 +02:00
|
|
|
|
2017-09-25 22:38:27 +02:00
|
|
|
TESTS=
|
|
|
|
for test in $NOTMUCH_TESTS; do
|
|
|
|
TESTS="$TESTS $NOTMUCH_SRCDIR/test/$test"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ -z "$TESTS" ]]; then
|
|
|
|
TESTS="$NOTMUCH_SRCDIR/test/T[0-9][0-9][0-9]-*.sh"
|
|
|
|
fi
|
2010-09-18 00:58:39 +02:00
|
|
|
|
2010-09-17 21:10:54 +02:00
|
|
|
# Clean up any results from a previous run
|
2017-09-25 22:38:27 +02:00
|
|
|
rm -rf $NOTMUCH_BUILDDIR/test/test-results
|
2010-09-17 21:10:54 +02:00
|
|
|
|
2016-06-09 21:20:56 +02:00
|
|
|
# Test for timeout utility
|
2011-05-28 11:50:11 +02:00
|
|
|
if command -v timeout >/dev/null; then
|
2016-06-09 21:20:56 +02:00
|
|
|
TEST_TIMEOUT_CMD="timeout 2m"
|
2011-05-28 11:50:11 +02:00
|
|
|
echo "INFO: using 2 minute timeout for tests"
|
|
|
|
else
|
|
|
|
TEST_TIMEOUT_CMD=""
|
|
|
|
fi
|
|
|
|
|
2011-11-08 17:02:25 +01:00
|
|
|
trap 'e=$?; kill $!; exit $e' HUP INT TERM
|
2010-09-17 21:10:54 +02:00
|
|
|
# Run the tests
|
2010-09-18 00:58:39 +02:00
|
|
|
for test in $TESTS; do
|
2017-09-25 22:38:27 +02:00
|
|
|
$TEST_TIMEOUT_CMD $test "$@" &
|
2011-11-08 17:02:25 +01:00
|
|
|
wait $!
|
2012-11-28 05:13:16 +01:00
|
|
|
# If the test failed without producing results, then it aborted,
|
|
|
|
# so we should abort, too.
|
|
|
|
RES=$?
|
2017-09-25 22:38:27 +02:00
|
|
|
testname=$(basename $test .sh)
|
|
|
|
if [[ $RES != 0 && ! -e "$NOTMUCH_BUILDDIR/test/test-results/$testname" ]]; then
|
2012-11-28 05:13:16 +01:00
|
|
|
exit $RES
|
|
|
|
fi
|
2010-09-17 21:10:54 +02:00
|
|
|
done
|
2011-11-08 17:02:25 +01:00
|
|
|
trap - HUP INT TERM
|
2010-09-17 21:10:54 +02:00
|
|
|
|
|
|
|
# Report results
|
2013-11-25 18:08:18 +01:00
|
|
|
echo
|
2017-09-25 22:38:27 +02:00
|
|
|
$NOTMUCH_SRCDIR/test/aggregate-results.sh $NOTMUCH_BUILDDIR/test/test-results/*
|
2013-09-08 17:53:30 +02:00
|
|
|
ev=$?
|
2010-09-17 21:10:54 +02:00
|
|
|
|
|
|
|
# Clean up
|
2019-05-04 22:57:43 +02:00
|
|
|
rm -rf $NOTMUCH_BUILDDIR/test/test-results
|
2013-09-08 17:53:30 +02:00
|
|
|
|
|
|
|
exit $ev
|