# Ensure that all tests are being run
test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
tests_in_suite=$(grep TESTS= ../notmuch-test | sed -e "s/TESTS=\"\(.*\)\"/\1/" | tr " " "\n" | sort)
-available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind)" | sort)
+available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*)" | sort)
test_expect_equal "$tests_in_suite" "$available"
################################################################
test_description="\"notmuch dump\" and \"notmuch restore\""
. ./test-lib.sh
+add_email_corpus
+
test_expect_success "Dumping all tags" "generate_message &&
notmuch new &&
notmuch dump dump.expected"
test_description='"notmuch search" in several variations'
. ./test-lib.sh
+add_email_corpus
+
test_begin_subtest "Search body"
add_message '[subject]="body search"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [body]=bodysearchtest
output=$(notmuch search bodysearchtest | notmuch_search_sanitize)
increment_mtime "$(dirname "${gen_msg_filename}")"
}
-# Generate a new message and add it to the index.
+# Generate a new message and add it to the database.
#
# All of the arguments and return values supported by generate_message
# are also supported here, so see that function for details.
notmuch new > /dev/null
}
+# Generate a corpus of email and add it to the database.
+#
+# This corpus is fixed, (it happens to be 50 messages from early in
+# the history of the notmuch mailing list), which allows for reliably
+# testing commands that need to operate on a not-totally-trivial
+# number of messages.
+add_email_corpus ()
+{
+ rm -rf ${MAIL_DIR}
+ if [ -d ../corpus.mail ]; then
+ cp -a ../corpus.mail ${MAIL_DIR}
+ else
+ cp -a ../corpus ${MAIL_DIR}
+ notmuch new
+ cp -a ${MAIL_DIR} ../corpus.mail
+ fi
+}
+
test_begin_subtest ()
{
test_subtest_name="$1"
export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
mkdir -p "${test}"
-mkdir "$MAIL_DIR"
+mkdir -p "${MAIL_DIR}"
cat <<EOF >"${NOTMUCH_CONFIG}"
[database]