2010-12-01 21:27:52 +01:00
|
|
|
#!/usr/bin/env bash
|
2010-06-10 08:48:00 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
2010-09-17 22:53:47 +02:00
|
|
|
test_description='the test framework itself.'
|
2017-09-25 22:38:19 +02:00
|
|
|
. $(dirname "$0")/test-lib.sh || exit 1
|
2010-06-10 08:48:00 +02:00
|
|
|
|
|
|
|
################################################################
|
|
|
|
# Test harness
|
2017-02-26 14:43:00 +01:00
|
|
|
test_begin_subtest 'success is reported like this'
|
|
|
|
test_expect_success ':'
|
|
|
|
|
|
|
|
test_begin_subtest 'test runs if prerequisite is satisfied'
|
2010-06-10 08:48:00 +02:00
|
|
|
test_set_prereq HAVEIT
|
2017-08-11 20:31:22 +02:00
|
|
|
test_expect_success 'test_have_prereq HAVEIT'
|
2010-06-10 08:48:00 +02:00
|
|
|
|
2017-02-26 14:43:00 +01:00
|
|
|
test_begin_subtest 'tests clean up after themselves'
|
2010-06-10 08:48:00 +02:00
|
|
|
clean=no
|
2017-02-26 14:43:00 +01:00
|
|
|
test_expect_success 'test_when_finished clean=yes'
|
2010-06-10 08:48:00 +02:00
|
|
|
|
2017-02-26 14:43:01 +01:00
|
|
|
test_begin_subtest 'tests clean up even after a failure'
|
2010-06-10 08:48:00 +02:00
|
|
|
cleaner=no
|
2017-02-26 14:43:01 +01:00
|
|
|
test_expect_code 1 'test_when_finished cleaner=yes && (exit 1)'
|
2010-06-10 08:48:00 +02:00
|
|
|
|
|
|
|
if test $clean$cleaner != yesyes
|
|
|
|
then
|
|
|
|
say "bug in test framework: cleanup commands do not work reliably"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-02-26 14:43:01 +01:00
|
|
|
test_begin_subtest 'failure to clean up causes the test to fail'
|
|
|
|
test_expect_code 2 'test_when_finished "(exit 2)"'
|
2010-06-10 08:48:00 +02:00
|
|
|
|
2017-09-25 22:38:28 +02:00
|
|
|
EXPECTED=$NOTMUCH_SRCDIR/test/test.expected-output
|
2021-05-15 22:47:39 +02:00
|
|
|
suppress_diff_date () {
|
2010-11-14 22:54:28 +01:00
|
|
|
sed -e 's/\(.*\-\-\- test-verbose\.4\.\expected\).*/\1/' \
|
|
|
|
-e 's/\(.*\+\+\+ test-verbose\.4\.\output\).*/\1/'
|
|
|
|
}
|
|
|
|
|
|
|
|
test_begin_subtest "Ensure that test output is suppressed unless the test fails"
|
2017-09-25 22:38:28 +02:00
|
|
|
output=$(cd $TEST_DIRECTORY; NOTMUCH_TEST_QUIET= $NOTMUCH_SRCDIR/test/test-verbose 2>&1 | suppress_diff_date)
|
2010-11-14 22:54:28 +01:00
|
|
|
expected=$(cat $EXPECTED/test-verbose-no | suppress_diff_date)
|
|
|
|
test_expect_equal "$output" "$expected"
|
|
|
|
|
|
|
|
test_begin_subtest "Ensure that -v does not suppress test output"
|
2017-09-25 22:38:28 +02:00
|
|
|
output=$(cd $TEST_DIRECTORY; NOTMUCH_TEST_QUIET= $NOTMUCH_SRCDIR/test/test-verbose -v 2>&1 | suppress_diff_date)
|
2010-11-14 22:54:28 +01:00
|
|
|
expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)
|
|
|
|
# Do not include the results of test-verbose in totals
|
2012-11-28 05:13:16 +01:00
|
|
|
rm $TEST_DIRECTORY/test-results/test-verbose
|
2010-12-07 23:24:00 +01:00
|
|
|
rm -r $TEST_DIRECTORY/tmp.test-verbose
|
2010-11-14 22:54:28 +01:00
|
|
|
test_expect_equal "$output" "$expected"
|
|
|
|
|
|
|
|
|
2010-09-18 00:28:53 +02:00
|
|
|
################################################################
|
|
|
|
# Test mail store prepared in test-lib.sh
|
|
|
|
|
2017-02-26 14:43:00 +01:00
|
|
|
test_begin_subtest 'test that mail store was created'
|
|
|
|
test_expect_success 'test -d "${MAIL_DIR}"'
|
2010-09-18 00:28:53 +02:00
|
|
|
|
2017-02-26 14:43:00 +01:00
|
|
|
test_begin_subtest 'mail store should be empty'
|
2010-09-18 00:28:53 +02:00
|
|
|
find "${MAIL_DIR}" -type f -print >should-be-empty
|
2017-02-26 14:43:00 +01:00
|
|
|
test_expect_success 'cmp -s /dev/null should-be-empty'
|
2010-09-18 00:28:53 +02:00
|
|
|
|
2017-02-26 14:43:00 +01:00
|
|
|
test_begin_subtest 'NOTMUCH_CONFIG is set and points to an existing file'
|
|
|
|
test_expect_success 'test -f "${NOTMUCH_CONFIG}"'
|
2010-09-18 00:28:53 +02:00
|
|
|
|
2014-04-13 14:42:49 +02:00
|
|
|
test_begin_subtest 'PATH is set to build directory'
|
2023-04-09 16:26:26 +02:00
|
|
|
test_subtest_broken_for_installed
|
2014-04-13 14:42:49 +02:00
|
|
|
test_expect_equal \
|
|
|
|
"$(dirname ${TEST_DIRECTORY})" \
|
|
|
|
"$(echo $PATH|cut -f1 -d: | sed -e 's,/test/valgrind/bin$,,')"
|
2010-09-18 00:28:53 +02:00
|
|
|
|
2014-10-03 22:22:09 +02:00
|
|
|
test_begin_subtest 'notmuch is compiled with debugging symbols'
|
2016-10-09 20:48:29 +02:00
|
|
|
readelf --sections $(command -v notmuch) | grep \.debug
|
2014-10-03 22:22:09 +02:00
|
|
|
test_expect_equal 0 $?
|
|
|
|
|
2010-06-10 08:48:00 +02:00
|
|
|
test_done
|