1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 65690431FB6
\r
6 for <notmuch@notmuchmail.org>; Sun, 20 Jan 2013 13:31:49 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id RAWc-zT7a3OS for <notmuch@notmuchmail.org>;
\r
16 Sun, 20 Jan 2013 13:31:48 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 07912431FAF
\r
19 for <notmuch@notmuchmail.org>; Sun, 20 Jan 2013 13:31:48 -0800 (PST)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id A6949100093; Sun, 20 Jan 2013 23:31:36 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH 1/1] test/test-lib.sh: use $test_subtest_name in all tests
\r
25 Date: Sun, 20 Jan 2013 23:31:33 +0200
\r
26 Message-Id: <1358717493-11231-1-git-send-email-tomi.ollila@iki.fi>
\r
27 X-Mailer: git-send-email 1.8.0
\r
28 Cc: tomi.ollila@iki.fi
\r
29 X-BeenThere: notmuch@notmuchmail.org
\r
30 X-Mailman-Version: 2.1.13
\r
32 List-Id: "Use and development of the notmuch mail system."
\r
33 <notmuch.notmuchmail.org>
\r
34 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
35 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
36 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
37 List-Post: <mailto:notmuch@notmuchmail.org>
\r
38 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
39 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
41 X-List-Received-Date: Sun, 20 Jan 2013 21:31:49 -0000
\r
43 Set the variable '$test_subtest_name' in all functions which starts
\r
44 a new test and use that variable in all functions that output
\r
47 Additionally output the latest '$test_subtest_name' in case of
\r
48 abnormal exit, to avoid confusion.
\r
51 The main reason to do this change is to get latest '$test_subtest_name'
\r
52 printed in case of abnormal exit. I cherry-picked this change from a
\r
53 larger work-in-progress patch set that adds 'set -e -o pipefail' support...
\r
55 I am pretty sure I got all the cases covered. If not, we'll notice
\r
56 it later when some test fail in a way I could not anticipate.
\r
57 Anyway, tests success & fail as they used to be.
\r
59 test/test-lib.sh | 52 +++++++++++++++++++++++++++++-----------------------
\r
60 1 file changed, 29 insertions(+), 23 deletions(-)
\r
62 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
63 index 6ce3b31..58e7b93 100644
\r
64 --- a/test/test-lib.sh
\r
65 +++ b/test/test-lib.sh
\r
66 @@ -197,7 +197,11 @@ die () {
\r
70 - echo >&5 "FATAL: Unexpected exit with code $code"
\r
72 + say_color error '%-6s' FATAL
\r
73 + echo " $test_subtest_name"
\r
75 + echo "Unexpected exit while executing $0. Exit code $code."
\r
79 @@ -494,12 +498,12 @@ test_expect_equal ()
\r
80 if ! test_skip "$test_subtest_name"
\r
82 if [ "$output" = "$expected" ]; then
\r
83 - test_ok_ "$test_subtest_name"
\r
86 testname=$this_test.$test_count
\r
87 echo "$expected" > $testname.expected
\r
88 echo "$output" > $testname.output
\r
89 - test_failure_ "$test_subtest_name" "$(diff -u $testname.expected $testname.output)"
\r
90 + test_failure_ "$(diff -u $testname.expected $testname.output)"
\r
94 @@ -520,12 +524,12 @@ test_expect_equal_file ()
\r
95 if ! test_skip "$test_subtest_name"
\r
97 if diff -q "$file1" "$file2" >/dev/null ; then
\r
98 - test_ok_ "$test_subtest_name"
\r
101 testname=$this_test.$test_count
\r
102 cp "$file1" "$testname.$basename1"
\r
103 cp "$file2" "$testname.$basename2"
\r
104 - test_failure_ "$test_subtest_name" "$(diff -u "$testname.$basename1" "$testname.$basename2")"
\r
105 + test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")"
\r
109 @@ -563,9 +567,9 @@ test_emacs_expect_t () {
\r
110 result=$(cat OUTPUT)
\r
111 if [ "$result" = t ]
\r
113 - test_ok_ "$test_subtest_name"
\r
116 - test_failure_ "$test_subtest_name" "${result}"
\r
117 + test_failure_ "${result}"
\r
120 # Restore state after the (non) test.
\r
121 @@ -666,12 +670,12 @@ test_require_external_prereq () {
\r
124 if test "$test_subtest_known_broken_" = "t"; then
\r
125 - test_known_broken_ok_ "$@"
\r
126 + test_known_broken_ok_
\r
129 test_success=$(($test_success + 1))
\r
130 say_color pass "%-6s" "PASS"
\r
132 + echo " $test_subtest_name"
\r
136 @@ -680,7 +684,7 @@ test_failure_ () {
\r
139 test_failure=$(($test_failure + 1))
\r
140 - test_failure_message_ "FAIL" "$@"
\r
141 + test_failure_message_ "FAIL" "$test_subtest_name" "$@"
\r
142 test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
\r
145 @@ -697,13 +701,13 @@ test_known_broken_ok_ () {
\r
147 test_fixed=$(($test_fixed+1))
\r
148 say_color pass "%-6s" "FIXED"
\r
150 + echo " $test_subtest_name"
\r
153 test_known_broken_failure_ () {
\r
155 test_broken=$(($test_broken+1))
\r
156 - test_failure_message_ "BROKEN" "$@"
\r
157 + test_failure_message_ "BROKEN" "$test_subtest_name" "$@"
\r
161 @@ -771,6 +775,7 @@ test_expect_success () {
\r
162 test "$#" = 3 && { prereq=$1; shift; } || prereq=
\r
164 error "bug in the test script: not 2 or 3 parameters to test-expect-success"
\r
165 + test_subtest_name="$1"
\r
167 if ! test_skip "$@"
\r
169 @@ -780,9 +785,9 @@ test_expect_success () {
\r
170 test_check_missing_external_prereqs_ "$@" ||
\r
171 if [ "$run_ret" = 0 -a "$eval_ret" = 0 ]
\r
176 - test_failure_ "$@"
\r
177 + test_failure_ "$2"
\r
181 @@ -791,6 +796,7 @@ test_expect_code () {
\r
182 test "$#" = 4 && { prereq=$1; shift; } || prereq=
\r
184 error "bug in the test script: not 3 or 4 parameters to test-expect-code"
\r
185 + test_subtest_name="$2"
\r
187 if ! test_skip "$@"
\r
189 @@ -800,9 +806,9 @@ test_expect_code () {
\r
190 test_check_missing_external_prereqs_ "$@" ||
\r
191 if [ "$run_ret" = 0 -a "$eval_ret" = "$1" ]
\r
196 - test_failure_ "$@"
\r
197 + test_failure_ "exit code $eval_ret, expected $1" "$3"
\r
201 @@ -819,10 +825,10 @@ test_external () {
\r
202 test "$#" = 4 && { prereq=$1; shift; } || prereq=
\r
204 error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
\r
206 + test_subtest_name="$1"
\r
209 - if ! test_skip "$descr" "$@"
\r
210 + if ! test_skip "$test_subtest_name" "$@"
\r
212 # Announce the script to reduce confusion about the
\r
213 # test output that follows.
\r
214 @@ -833,9 +839,9 @@ test_external () {
\r
218 - test_ok_ "$descr"
\r
221 - test_failure_ "$descr" "$@"
\r
222 + test_failure_ "$@"
\r
226 @@ -849,11 +855,11 @@ test_external_without_stderr () {
\r
227 stderr="$tmp/git-external-stderr.$$.tmp"
\r
228 test_external "$@" 4> "$stderr"
\r
229 [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
\r
230 - descr="no stderr: $1"
\r
231 + test_subtest_name="no stderr: $1"
\r
233 if [ ! -s "$stderr" ]; then
\r
235 - test_ok_ "$descr"
\r
238 if [ "$verbose" = t ]; then
\r
239 output=`echo; echo Stderr is:; cat "$stderr"`
\r
240 @@ -862,7 +868,7 @@ test_external_without_stderr () {
\r
242 # rm first in case test_failure exits.
\r
244 - test_failure_ "$descr" "$@" "$output"
\r
245 + test_failure_ "$@" "$output"
\r