diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/README | 8 | ||||
-rwxr-xr-x | test/basic | 4 | ||||
-rwxr-xr-x | test/emacs-tree | 38 | ||||
-rwxr-xr-x | test/insert | 10 | ||||
-rwxr-xr-x | test/notmuch-test | 1 | ||||
-rw-r--r-- | test/test-lib.sh | 29 | ||||
-rw-r--r-- | test/test.expected-output/test-verbose-no | 1 | ||||
-rw-r--r-- | test/test.expected-output/test-verbose-yes | 1 |
8 files changed, 56 insertions, 36 deletions
diff --git a/test/README b/test/README index d12cff24..79a9b1b2 100644 --- a/test/README +++ b/test/README @@ -76,6 +76,14 @@ the tests in one of the following ways. TEST_EMACS=my-special-emacs TEST_EMACSCLIENT=my-emacsclient ./emacs make test TEST_EMACS=my-special-emacs TEST_EMACSCLIENT=my-emacsclient +Quiet Execution +--------------- + +Normally, when new script starts and when test PASSes you get a message +printed on screen. This printing can be disabled by setting the +NOTMUCH_TEST_QUIET variable to a non-null value. Message on test +failures and skips are still printed. + Skipping Tests -------------- If, for any reason, you need to skip one or more tests, you can do so @@ -74,12 +74,12 @@ suppress_diff_date() { } test_begin_subtest "Ensure that test output is suppressed unless the test fails" -output=$(cd $TEST_DIRECTORY; ./test-verbose 2>&1 | suppress_diff_date) +output=$(cd $TEST_DIRECTORY; NOTMUCH_TEST_QUIET= ./test-verbose 2>&1 | suppress_diff_date) 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" -output=$(cd $TEST_DIRECTORY; ./test-verbose -v 2>&1 | suppress_diff_date) +output=$(cd $TEST_DIRECTORY; NOTMUCH_TEST_QUIET= ./test-verbose -v 2>&1 | suppress_diff_date) expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date) # Do not include the results of test-verbose in totals rm $TEST_DIRECTORY/test-results/test-verbose diff --git a/test/emacs-tree b/test/emacs-tree index 4bdfddd2..8e9f37cb 100755 --- a/test/emacs-tree +++ b/test/emacs-tree @@ -8,16 +8,14 @@ EXPECTED=$TEST_DIRECTORY/tree.expected-output add_email_corpus test_begin_subtest "Basic notmuch-tree view in emacs" -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (notmuch-tree "tag:inbox") +test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (test-output) (delete-other-windows)' test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox test_begin_subtest "Refreshed notmuch-tree view in emacs" -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (notmuch-tree "tag:inbox") +test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (notmuch-tree-refresh-view) (notmuch-test-wait) @@ -30,8 +28,7 @@ test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-tag-inbox # correctly. test_begin_subtest "Tag message in notmuch tree view (display)" -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (notmuch-tree "tag:inbox") +test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (forward-line) (notmuch-tree-tag (list "+test_tag")) @@ -44,8 +41,7 @@ output=$(notmuch search --output=messages 'tag:test_tag') test_expect_equal "$output" "id:877h1wv7mg.fsf@inf-8657.int-evry.fr" test_begin_subtest "Untag message in notmuch tree view" -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (notmuch-tree "tag:inbox") +test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (forward-line) (notmuch-tree-tag (list "-test_tag")) @@ -58,8 +54,7 @@ output=$(notmuch search --output=messages 'tag:test_tag') test_expect_equal "$output" "" test_begin_subtest "Tag thread in notmuch tree view" -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (notmuch-tree "tag:inbox") +test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) ;; move to a sizable thread (forward-line 26) @@ -80,8 +75,7 @@ id:87iqd9rn3l.fsf@vertex.dottedmag id:20091117190054.GU3165@dottiness.seas.harvard.edu" test_begin_subtest "Untag thread in notmuch tree view" -test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (notmuch-tree "tag:inbox") +test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) ;; move to the same sizable thread as above (forward-line 26) @@ -147,26 +141,20 @@ cp OUTPUT /tmp/mjwout test_expect_equal_file OUTPUT $EXPECTED/notmuch-tree-show-window test_begin_subtest "Stash id" -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (require (quote notmuch-tree)) - (notmuch-tree "id:1258498485-sup-142@elly") +output=$(test_emacs '(notmuch-tree "id:1258498485-sup-142@elly") (notmuch-test-wait) (notmuch-show-stash-message-id)') test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142@elly\"" test_begin_subtest "Move to next matching message" -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (require (quote notmuch-tree)) - (notmuch-tree "from:cworth") +output=$(test_emacs '(notmuch-tree "from:cworth") (notmuch-test-wait) (notmuch-tree-next-matching-message) (notmuch-show-stash-message-id)') test_expect_equal "$output" "\"Stashed: id:878we4qdqf.fsf@yoom.home.cworth.org\"" test_begin_subtest "Move to next thread" -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (require (quote notmuch-tree)) - (notmuch-tree "tag:inbox") +output=$(test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (forward-line 26) (notmuch-tree-next-thread) @@ -174,9 +162,7 @@ output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") test_expect_equal "$output" "\"Stashed: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net\"" test_begin_subtest "Move to previous thread" -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (require (quote notmuch-tree)) - (notmuch-tree "tag:inbox") +output=$(test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (forward-line 26) (notmuch-tree-prev-thread) @@ -184,9 +170,7 @@ output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") test_expect_equal "$output" "\"Stashed: id:20091117190054.GU3165@dottiness.seas.harvard.edu\"" test_begin_subtest "Move to previous previous thread" -output=$(test_emacs '(add-to-list (quote load-path) "'$PICK_DIR'") - (require (quote notmuch-tree)) - (notmuch-tree "tag:inbox") +output=$(test_emacs '(notmuch-tree "tag:inbox") (notmuch-test-wait) (forward-line 26) (notmuch-tree-prev-thread) diff --git a/test/insert b/test/insert index 550b4132..e8dc4c09 100755 --- a/test/insert +++ b/test/insert @@ -113,6 +113,16 @@ output=$(notmuch search --output=files id:$gen_msg_id) dirname=$(dirname "$output") test_expect_equal "$dirname" "$MAIL_DIR/cur" +test_begin_subtest "Insert message with maildir sync off goes to new/" +OLDCONFIG=$(notmuch config get maildir.synchronize_flags) +notmuch config set maildir.synchronize_flags false +gen_insert_msg +notmuch insert +flagged < "$gen_msg_filename" +output=$(notmuch search --output=files id:$gen_msg_id) +dirname=$(dirname "$output") +notmuch config set maildir.synchronize_flags $OLDCONFIG +test_expect_equal "$dirname" "$MAIL_DIR/new" + test_begin_subtest "Insert message into folder" gen_insert_msg notmuch insert --folder=Drafts < "$gen_msg_filename" diff --git a/test/notmuch-test b/test/notmuch-test index 18593f61..d6fdd3a5 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -98,6 +98,7 @@ done trap - HUP INT TERM # Report results +echo ./aggregate-results.sh test-results/* ev=$? diff --git a/test/test-lib.sh b/test/test-lib.sh index efa9fb6f..2fcaba65 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -25,6 +25,9 @@ fi # Make sure echo builtin does not expand backslash-escape sequences by default. shopt -u xpg_echo +this_test=${0##*/} +this_test=${this_test%.sh} + # if --tee was passed, write the output not only to the terminal, but # additionally to the file test-results/$BASENAME.out, too. case "$GIT_TEST_TEE_STARTED, $* " in @@ -33,7 +36,7 @@ done,*) ;; *' --tee '*|*' --va'*) mkdir -p test-results - BASE=test-results/$(basename "$0" .sh) + BASE=test-results/$this_test (GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1; echo $? > $BASE.exit) | tee $BASE.out test "$(cat $BASE.exit)" = 0 @@ -187,7 +190,18 @@ then exit 0 fi -echo $(basename "$0"): "Testing ${test_description}" +test_description_printed= +print_test_description () +{ + test -z "$test_description_printed" || return 0 + echo + echo $this_test: "Testing ${test_description}" + test_description_printed=1 +} +if [ -z "$NOTMUCH_TEST_QUIET" ] +then + print_test_description +fi exec 5>&1 @@ -748,6 +762,9 @@ test_ok_ () { return fi test_success=$(($test_success + 1)) + if test -n "$NOTMUCH_TEST_QUIET"; then + return 0 + fi say_color pass "%-6s" "PASS" echo " $test_subtest_name" } @@ -758,6 +775,7 @@ test_failure_ () { return fi test_failure=$(($test_failure + 1)) + print_test_description test_failure_message_ "FAIL" "$test_subtest_name" "$@" test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } return 1 @@ -1009,7 +1027,7 @@ test_done () { GIT_EXIT_OK=t test_results_dir="$TEST_DIRECTORY/test-results" mkdir -p "$test_results_dir" - test_results_path="$test_results_dir/${0%.sh}" + test_results_path="$test_results_dir/$this_test" echo "total $test_count" >> $test_results_path echo "success $test_success" >> $test_results_path @@ -1018,8 +1036,6 @@ test_done () { echo "failed $test_failure" >> $test_results_path echo "" >> $test_results_path - echo - [ -n "$EMACS_SERVER" ] && test_emacs '(kill-emacs)' if [ "$test_failure" = "0" ]; then @@ -1068,7 +1084,7 @@ test_emacs () { test -z "$missing_dependencies" || return if [ -z "$EMACS_SERVER" ]; then - emacs_tests="$(basename $0).el" + emacs_tests="${this_test}.el" if [ -f "$TEST_DIRECTORY/$emacs_tests" ]; then load_emacs_tests="--eval '(load \"$emacs_tests\")'" else @@ -1182,7 +1198,6 @@ else exec 4>test.output 3>&4 fi -this_test=${0##*/} for skp in $NOTMUCH_SKIP_TESTS do to_skip= diff --git a/test/test.expected-output/test-verbose-no b/test/test.expected-output/test-verbose-no index 0bca7540..1a2ff619 100644 --- a/test/test.expected-output/test-verbose-no +++ b/test/test.expected-output/test-verbose-no @@ -1,3 +1,4 @@ + test-verbose: Testing the verbosity options of the test framework itself. PASS print something in test_expect_success and pass FAIL print something in test_expect_success and fail diff --git a/test/test.expected-output/test-verbose-yes b/test/test.expected-output/test-verbose-yes index ebe51874..d25466e9 100644 --- a/test/test.expected-output/test-verbose-yes +++ b/test/test.expected-output/test-verbose-yes @@ -1,3 +1,4 @@ + test-verbose: Testing the verbosity options of the test framework itself. hello stdout hello stderr |