diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.gitignore | 10 | ||||
-rw-r--r-- | test/Makefile.local | 35 | ||||
-rwxr-xr-x | test/T010-help-test.sh | 2 | ||||
-rwxr-xr-x | test/T020-compact.sh | 2 | ||||
-rwxr-xr-x | test/T150-tagging.sh | 4 | ||||
-rwxr-xr-x | test/T260-thread-order.sh | 86 | ||||
-rwxr-xr-x | test/T380-atomicity.sh | 2 | ||||
-rw-r--r-- | test/emacs.expected-output/notmuch-hello | 2 | ||||
-rw-r--r-- | test/emacs.expected-output/notmuch-hello-long-names | 2 | ||||
-rw-r--r-- | test/gen-threads.py | 33 | ||||
-rw-r--r-- | test/test-databases/Makefile.local | 2 | ||||
-rw-r--r-- | test/test-lib-common.sh | 4 | ||||
-rw-r--r-- | test/test-lib.el | 11 | ||||
-rw-r--r-- | test/test-lib.sh | 2 |
14 files changed, 139 insertions, 58 deletions
diff --git a/test/.gitignore b/test/.gitignore index 97e02487..b3b706d8 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,9 +1,9 @@ -test-results -corpus.mail -smtp-dummy -symbol-test arg-test +corpus.mail hex-xcode -random-corpus parse-time +random-corpus +smtp-dummy +symbol-test +test-results tmp.* diff --git a/test/Makefile.local b/test/Makefile.local index d622eafe..916dd0bd 100644 --- a/test/Makefile.local +++ b/test/Makefile.local @@ -35,30 +35,19 @@ $(dir)/symbol-test: $(dir)/symbol-test.o lib/$(LINKER_NAME) $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o $(call quiet,CC) $^ -o $@ -$(dir)/have-compact: Makefile.config -ifeq ($(HAVE_XAPIAN_COMPACT),1) - ln -sf /bin/true $@ -else - ln -sf /bin/false $@ -endif - -$(dir)/have-man: Makefile.config -ifeq ($(HAVE_SPHINX)$(HAVE_RST2MAN),00) - ln -sf /bin/false $@ -else - ln -sf /bin/true $@ -endif - .PHONY: test check -TEST_BINARIES=$(dir)/arg-test \ - $(dir)/have-compact \ - $(dir)/have-man \ - $(dir)/hex-xcode \ - $(dir)/random-corpus \ - $(dir)/parse-time \ - $(dir)/smtp-dummy \ - $(dir)/symbol-test +test_main_srcs=$(dir)/arg-test.c \ + $(dir)/hex-xcode.c \ + $(dir)/random-corpus.c \ + $(dir)/parse-time.c \ + $(dir)/smtp-dummy.c \ + $(dir)/symbol-test.cc \ + +test_srcs=$(test_main_srcs) $(dir)/database-test.c + +TEST_BINARIES := $(test_main_srcs:.c=) +TEST_BINARIES := $(TEST_BINARIES:.cc=) test-binaries: $(TEST_BINARIES) @@ -67,7 +56,7 @@ test: all test-binaries check: test -SRCS := $(SRCS) $(smtp_dummy_srcs) +SRCS := $(SRCS) $(test_srcs) CLEAN += $(TEST_BINARIES) $(addsuffix .o,$(TEST_BINARIES)) \ $(dir)/database-test.o \ $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.* diff --git a/test/T010-help-test.sh b/test/T010-help-test.sh index 77410bc5..caf8bdb0 100755 --- a/test/T010-help-test.sh +++ b/test/T010-help-test.sh @@ -7,7 +7,7 @@ test_expect_success 'notmuch --help' 'notmuch --help' test_expect_success 'notmuch help' 'notmuch help' test_expect_success 'notmuch --version' 'notmuch --version' -if ${TEST_DIRECTORY}/have-man; then +if [ $NOTMUCH_HAVE_MAN -eq 1 ]; then test_expect_success 'notmuch --help tag' 'notmuch --help tag' test_expect_success 'notmuch help tag' 'notmuch help tag' else diff --git a/test/T020-compact.sh b/test/T020-compact.sh index 77bb9632..507f7698 100755 --- a/test/T020-compact.sh +++ b/test/T020-compact.sh @@ -10,7 +10,7 @@ notmuch tag +tag1 \* notmuch tag +tag2 subject:Two notmuch tag -tag1 +tag3 subject:Three -if ! ${TEST_DIRECTORY}/have-compact; then +if [ $NOTMUCH_HAVE_XAPIAN_COMPACT -eq 0 ]; then test_begin_subtest "Compact unsupported: error message" output=$(notmuch compact --quiet 2>&1) test_expect_equal "$output" "notmuch was compiled against a xapian version lacking compaction support. diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh index dc118f33..45471ac8 100755 --- a/test/T150-tagging.sh +++ b/test/T150-tagging.sh @@ -247,8 +247,8 @@ ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \ notmuch dump --format=batch-tag | sed 's/^.* -- /+common_tag -- /' | \ sort > EXPECTED -notmuch dump --format=batch-tag | sed 's/^.* -- / -- /' | \ - notmuch restore --format=batch-tag +notmuch dump --format=batch-tag | sed 's/^.* -- / -- /' > INTERMEDIATE_STEP +notmuch restore --format=batch-tag < INTERMEDIATE_STEP notmuch tag --batch < EXPECTED diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh index 6c3a4b3f..b435d79f 100755 --- a/test/T260-thread-order.sh +++ b/test/T260-thread-order.sh @@ -2,31 +2,75 @@ test_description="threading when messages received out of order" . ./test-lib.sh -test_begin_subtest "Adding initial child message" -generate_message [body]=foo "[in-reply-to]=\<parent-id\>" [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' -output=$(NOTMUCH_NEW) -test_expect_equal "$output" "Added 1 new message to the database." +# Generate all single-root four message thread structures. We'll use +# this for multiple tests below. +THREADS=$(python ${TEST_DIRECTORY}/gen-threads.py 4) +nthreads=$(wc -l <<< "$THREADS") -test_begin_subtest "Searching returns the message" -output=$(notmuch search foo | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)" +test_begin_subtest "Messages with one parent get linked in all delivery orders" +# In the first variant, this delivers messages that reference only +# their immediate parent. Hence, we should only expect threads to be +# fully joined at the end. +for ((n = 0; n < 4; n++)); do + # Deliver the n'th message of every thread + thread=0 + while read -a parents; do + parent=${parents[$n]} + generate_message \ + [id]=m$n@t$thread [in-reply-to]="\<m$parent@t$thread\>" \ + [subject]=p$thread [from]=m$n + thread=$((thread + 1)) + done <<< "$THREADS" + notmuch new > /dev/null +done +output=$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize) +expected=$(for ((i = 0; i < $nthreads; i++)); do + echo "thread:XXX 2001-01-05 [4/4] m3, m2, m1, m0; p$i (inbox unread)" + done) +test_expect_equal "$output" "$expected" -test_begin_subtest "Adding second child message" -generate_message [body]=foo "[in-reply-to]=\<parent-id\>" [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' -output=$(NOTMUCH_NEW) -test_expect_equal "$output" "Added 1 new message to the database." +test_begin_subtest "Messages with all parents get linked in all delivery orders" +test_subtest_known_broken +# Here we do the same thing as the previous test, but each message +# references all of its parents. Since every message references the +# root of the thread, each thread should always be fully joined. This +# is currently broken because of the bug detailed in +# id:8738h7kv2q.fsf@qmul.ac.uk. +rm ${MAIL_DIR}/* +notmuch new > /dev/null +output="" +expected="" +for ((n = 0; n < 4; n++)); do + # Deliver the n'th message of every thread + thread=0 + while read -a parents; do + references="" + parent=${parents[$n]} + while [[ $parent != None ]]; do + references="<m$parent@t$thread> $references" + parent=${parents[$parent]} + done -test_begin_subtest "Searching returns both messages in one thread" -output=$(notmuch search foo | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)" + generate_message \ + [id]=m$n@t$thread [references]="'$references'" \ + [subject]=p$thread [from]=m$n + thread=$((thread + 1)) + done <<< "$THREADS" + notmuch new > /dev/null -test_begin_subtest "Adding parent message" -generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' -output=$(NOTMUCH_NEW) -test_expect_equal "$output" "Added 1 new message to the database." + output="$output +$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)" -test_begin_subtest "Searching returns all three messages in one thread" -output=$(notmuch search foo | notmuch_search_sanitize) -test_expect_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)" + # Construct expected output + template="thread:XXX 2001-01-05 [$((n+1))/$((n+1))]" + for ((m = n; m > 0; m--)); do + template="$template m$m," + done + expected="$expected +$(for ((i = 0; i < $nthreads; i++)); do + echo "$template m0; p$i (inbox unread)" + done)" +done +test_expect_equal "$output" "$expected" test_done diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh index 1c786fa2..2daef906 100755 --- a/test/T380-atomicity.sh +++ b/test/T380-atomicity.sh @@ -64,7 +64,7 @@ if test_require_external_prereq gdb; then # -tty /dev/null works around a conflict between the 'timeout' wrapper # and gdb's attempt to control the TTY. export MAIL_DIR - gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.gdb notmuch >/dev/null 2>/dev/null + gdb -tty /dev/null -batch -x $TEST_DIRECTORY/atomicity.gdb notmuch 1>gdb.out 2>&1 # Get the final, golden output notmuch search '*' > expected diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello index 2d698917..9ba4cfc1 100644 --- a/test/emacs.expected-output/notmuch-hello +++ b/test/emacs.expected-output/notmuch-hello @@ -2,7 +2,7 @@ Saved searches: [edit] - 52 inbox 52 unread + 52 inbox 52 unread 52 all mail Search: . diff --git a/test/emacs.expected-output/notmuch-hello-long-names b/test/emacs.expected-output/notmuch-hello-long-names index 486d0d9a..1c8d6eb6 100644 --- a/test/emacs.expected-output/notmuch-hello-long-names +++ b/test/emacs.expected-output/notmuch-hello-long-names @@ -2,7 +2,7 @@ Saved searches: [edit] - 52 inbox 52 unread + 52 inbox 52 unread 52 all mail Search: . diff --git a/test/gen-threads.py b/test/gen-threads.py new file mode 100644 index 00000000..9fbb8474 --- /dev/null +++ b/test/gen-threads.py @@ -0,0 +1,33 @@ +# Generate all possible single-root message thread structures of size +# argv[1]. Each output line is a thread structure, where the n'th +# field is either a number giving the parent of message n or "None" +# for the root. + +import sys +from itertools import chain, combinations + +def subsets(s): + return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) + +nodes = set(range(int(sys.argv[1]))) + +# Queue of (tree, free, to_expand) where tree is a {node: parent} +# dictionary, free is a set of unattached nodes, and to_expand is +# itself a queue of nodes in the tree that need to be expanded. +# The queue starts with all single-node trees. +queue = [({root: None}, nodes - {root}, (root,)) for root in nodes] + +# Process queue +while queue: + tree, free, to_expand = queue.pop() + + if len(to_expand) == 0: + # Only print full-sized trees + if len(free) == 0: + print(" ".join(map(str, [msg[1] for msg in sorted(tree.items())]))) + else: + # Expand node to_expand[0] with each possible set of children + for children in subsets(free): + ntree = dict(tree, **{child: to_expand[0] for child in children}) + nfree = free.difference(children) + queue.append((ntree, nfree, to_expand[1:] + tuple(children))) diff --git a/test/test-databases/Makefile.local b/test/test-databases/Makefile.local index 0572e784..ff333a1d 100644 --- a/test/test-databases/Makefile.local +++ b/test/test-databases/Makefile.local @@ -11,4 +11,4 @@ test_databases := $(dir)/database-v1.tar.xz download-test-databases: ${test_databases} -DISTCLEAN := $(DISTCLEAN) ${test_databases} +DATACLEAN := $(DATACLEAN) ${test_databases} diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh index 892991e2..4903038d 100644 --- a/test/test-lib-common.sh +++ b/test/test-lib-common.sh @@ -38,6 +38,10 @@ find_notmuch_path () # test/ subdirectory and are run in 'trash directory' subdirectory. TEST_DIRECTORY=$(pwd) notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"` + +# configure output +. $notmuch_path/sh.config + if test -n "$valgrind" then make_symlink () { diff --git a/test/test-lib.el b/test/test-lib.el index 437f83f4..36afe630 100644 --- a/test/test-lib.el +++ b/test/test-lib.el @@ -52,11 +52,13 @@ (defun test-output (&optional filename) "Save current buffer to file FILENAME. Default FILENAME is OUTPUT." + (notmuch-post-command) (write-region (point-min) (point-max) (or filename "OUTPUT"))) (defun test-visible-output (&optional filename) "Save visible text in current buffer to file FILENAME. Default FILENAME is OUTPUT." + (notmuch-post-command) (let ((text (visible-buffer-string))) (with-temp-file (or filename "OUTPUT") (insert text)))) @@ -166,6 +168,15 @@ nothing." (t (notmuch-test-report-unexpected output expected))))) +(defun notmuch-post-command () + (run-hooks 'post-command-hook)) + +(defmacro notmuch-test-progn (&rest body) + (cons 'progn + (mapcar + (lambda (x) `(prog1 ,x (notmuch-post-command))) + body))) + ;; For historical reasons, we hide deleted tags by default in the test ;; suite (setq notmuch-tag-deleted-formats diff --git a/test/test-lib.sh b/test/test-lib.sh index 17deaaba..b9b8fe8c 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -1138,7 +1138,7 @@ test_emacs () { rm -f OUTPUT touch OUTPUT - ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(progn $@)" + ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(notmuch-test-progn $@)" } test_python() { |