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
|
|
|
|
|
2016-05-06 17:41:57 +02:00
|
|
|
cd "$(dirname "$0")"
|
2010-09-17 21:10:54 +02:00
|
|
|
|
2016-06-09 21:20:56 +02:00
|
|
|
TESTS=${NOTMUCH_TESTS:-T[0-9][0-9][0-9]-*.sh}
|
2010-09-18 00:58:39 +02:00
|
|
|
|
2010-09-17 21:10:54 +02:00
|
|
|
# Clean up any results from a previous run
|
2016-06-09 21:20:56 +02:00
|
|
|
rm -rf 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
|
2011-11-08 17:02:25 +01:00
|
|
|
$TEST_TIMEOUT_CMD ./$test "$@" &
|
|
|
|
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=$?
|
|
|
|
if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then
|
|
|
|
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
|
2010-09-18 00:58:39 +02:00
|
|
|
./aggregate-results.sh test-results/*
|
2013-09-08 17:53:30 +02:00
|
|
|
ev=$?
|
2010-09-17 21:10:54 +02:00
|
|
|
|
|
|
|
# Clean up
|
2017-08-17 02:41:09 +02:00
|
|
|
rm -rf test-results corpora.mail
|
2013-09-08 17:53:30 +02:00
|
|
|
|
|
|
|
exit $ev
|