]> git.notmuchmail.org Git - notmuch/commitdiff
test: implement and document NOTMUCH_TEST_QUIET variable usage
authorTomi Ollila <tomi.ollila@iki.fi>
Thu, 5 Dec 2013 12:46:00 +0000 (14:46 +0200)
committerDavid Bremner <david@tethera.net>
Mon, 9 Dec 2013 15:29:11 +0000 (23:29 +0800)
When NOTMUCH_TEST_QUIET environment variable is set to non-null value
messages when new test script starts and when test PASSes are disabled.
This eases picking the cases when tests FAIL (as those are still printed).

test/README
test/basic
test/test-lib.sh

index d12cff24e2bd7a0796446e76c9e1559da46db1d4..79a9b1b2f9a15aba7466e4e5b1b308663dd1296c 100644 (file)
@@ -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
index 64eb7d74eac5163483a199b0add3f59432a2a299..f7eed320a04509ff43eb5b03df2c9664fc5cf490 100755 (executable)
@@ -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
index 34e0db68d36cf08e286570cc6e71e75cf4f58287..d8e0d9115a69fa754e3318d978d105bcc282963e 100644 (file)
@@ -198,7 +198,10 @@ print_test_description ()
        echo $this_test: "Testing ${test_description}"
        test_description_printed=1
 }
-print_test_description
+if [ -z "$NOTMUCH_TEST_QUIET" ]
+then
+       print_test_description
+fi
 
 exec 5>&1
 
@@ -717,6 +720,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"
 }
@@ -727,6 +733,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