]> git.notmuchmail.org Git - notmuch/commitdiff
test: Fix the search and dump-restore tests to operator on non-empty mail store.
authorCarl Worth <cworth@cworth.org>
Mon, 20 Sep 2010 23:40:35 +0000 (16:40 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 20 Sep 2010 23:40:35 +0000 (16:40 -0700)
We do this with a new add_email_corpus function that establishes a
mail store with 50 messages from the notmuch mailing list.

test/.gitignore
test/basic
test/dump-restore
test/notmuch-test
test/search
test/test-lib.sh

index 87364a273f79c79c30a3b5a247d9f82d84c3cee2..1cda9961af8d2a4e2fa569c5b7f0ee27d0f9c794 100644 (file)
@@ -1 +1,2 @@
 test-results
 test-results
+corpus.mail
index dada2824bc40b2a7027c9a9502230c50d4606e4d..fd89e9e415677fe064f66aa70b40453c36243fe9 100755 (executable)
@@ -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)
 # 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_expect_equal "$tests_in_suite" "$available"
 
 ################################################################
index 466f363d3c462380a53f45028bc21814a42c1ba2..0d78f014bb41977ab63d2b1d394766e7784ed8a6 100755 (executable)
@@ -2,6 +2,8 @@
 test_description="\"notmuch dump\" and \"notmuch restore\""
 . ./test-lib.sh
 
 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_expect_success "Dumping all tags" "generate_message &&
 notmuch new &&
 notmuch dump dump.expected"
index fc1a66bfaf976c1ba48a62395a5957060165ff5a..13c5d80686bf6c2fb28ca9f4d65e9cf1a8fcfefa 100755 (executable)
@@ -22,4 +22,4 @@ done
 ./aggregate-results.sh test-results/*
 
 # Clean up
 ./aggregate-results.sh test-results/*
 
 # Clean up
-rm -r test-results
+rm -r test-results corpus.mail
index 32799c40eb9737a89d0798a7b898e97dd024bc97..91325552995ccb8100e968e6bf0272cacf4be162 100755 (executable)
@@ -2,6 +2,8 @@
 test_description='"notmuch search" in several variations'
 . ./test-lib.sh
 
 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)
 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)
index 559a5435985f60dfb3b86257a5a8c622b74603e6..5f7fa14172efc7a01d5c337540f9e771f84811f9 100644 (file)
@@ -354,7 +354,7 @@ EOF
     increment_mtime "$(dirname "${gen_msg_filename}")"
 }
 
     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.
 #
 # 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
 }
 
     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"
 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}"
 export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
 
 mkdir -p "${test}"
-mkdir "$MAIL_DIR"
+mkdir -p "${MAIL_DIR}"
 
 cat <<EOF >"${NOTMUCH_CONFIG}"
 [database]
 
 cat <<EOF >"${NOTMUCH_CONFIG}"
 [database]