diff --git a/test/.gitignore b/test/.gitignore index 87364a27..1cda9961 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1 +1,2 @@ test-results +corpus.mail diff --git a/test/basic b/test/basic index dada2824..fd89e9e4 100755 --- a/test/basic +++ b/test/basic @@ -52,7 +52,7 @@ test_expect_code 2 'failure to clean up causes the test to fail' ' # 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" ################################################################ diff --git a/test/dump-restore b/test/dump-restore index 466f363d..0d78f014 100755 --- a/test/dump-restore +++ b/test/dump-restore @@ -2,6 +2,8 @@ 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" diff --git a/test/notmuch-test b/test/notmuch-test index fc1a66bf..13c5d806 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -22,4 +22,4 @@ done ./aggregate-results.sh test-results/* # Clean up -rm -r test-results +rm -r test-results corpus.mail diff --git a/test/search b/test/search index 32799c40..91325552 100755 --- a/test/search +++ b/test/search @@ -2,6 +2,8 @@ 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) diff --git a/test/test-lib.sh b/test/test-lib.sh index 559a5435..5f7fa141 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -354,7 +354,7 @@ EOF 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. @@ -364,6 +364,24 @@ add_message () 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" @@ -801,7 +819,7 @@ MAIL_DIR="${TMP_DIRECTORY}/mail" export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config" mkdir -p "${test}" -mkdir "$MAIL_DIR" +mkdir -p "${MAIL_DIR}" cat <"${NOTMUCH_CONFIG}" [database]