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 5129D431FB6
\r
6 for <notmuch@notmuchmail.org>; Sun, 20 Jan 2013 19:02:03 -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 XUsXVkNrAHZ9 for <notmuch@notmuchmail.org>;
\r
16 Sun, 20 Jan 2013 19:02:01 -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 4E70A431FAF
\r
19 for <notmuch@notmuchmail.org>; Sun, 20 Jan 2013 19:02:01 -0800 (PST)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id EF1E7100093; Mon, 21 Jan 2013 05:01:47 +0200 (EET)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: notmuch@notmuchmail.org
\r
24 Subject: [PATCH 1/2] test/test-lib.sh: use $test_subtest_name in all tests
\r
25 Date: Mon, 21 Jan 2013 05:01:45 +0200
\r
26 Message-Id: <1358737306-21744-1-git-send-email-tomi.ollila@iki.fi>
\r
27 X-Mailer: git-send-email 1.8.0
\r
28 In-Reply-To: <id:1358717493-11231-1-git-send-email-tomi.ollila@iki.fi>
\r
29 References: <id:1358717493-11231-1-git-send-email-tomi.ollila@iki.fi>
\r
30 Cc: tomi.ollila@iki.fi
\r
31 X-BeenThere: notmuch@notmuchmail.org
\r
32 X-Mailman-Version: 2.1.13
\r
34 List-Id: "Use and development of the notmuch mail system."
\r
35 <notmuch.notmuchmail.org>
\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
37 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
39 List-Post: <mailto:notmuch@notmuchmail.org>
\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
43 X-List-Received-Date: Mon, 21 Jan 2013 03:02:03 -0000
\r
45 Set the variable '$test_subtest_name' in all functions which starts
\r
46 a new test and use that variable in all functions that output
\r
49 Additionally output the latest '$test_subtest_name' in case of
\r
50 abnormal exit, to avoid confusion.
\r
53 This obsoletes id:1358717806-11376-1-git-send-email-tomi.ollila@iki.fi
\r
54 which had fd:s in function 'die' wrong order in 'exec [1]>&5' line.
\r
55 I did plenty of (ad hoc) hand-testing for this but failed to notice that
\r
56 messages weren't always as verbose as those should have been. The wip
\r
57 patch set mentioned below has it right but this was hand-rewritten as
\r
58 this is somewhat different here...
\r
60 The main reason to do this change is to get latest '$test_subtest_name'
\r
61 printed in case of abnormal exit. I cherry-picked this change from a
\r
62 larger work-in-progress patch set that adds 'set -e -o pipefail' support...
\r
64 I am pretty sure I got all the cases covered. If not, we'll notice
\r
65 it later when some test fail in a way I could not anticipate.
\r
66 Anyway, tests success & fail as they used to be.
\r
68 test/test-lib.sh | 52 +++++++++++++++++++++++++++++-----------------------
\r
69 1 file changed, 29 insertions(+), 23 deletions(-)
\r
71 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
72 index 6ce3b31..0098bfd 100644
\r
73 --- a/test/test-lib.sh
\r
74 +++ b/test/test-lib.sh
\r
75 @@ -197,7 +197,11 @@ die () {
\r
79 - echo >&5 "FATAL: Unexpected exit with code $code"
\r
81 + say_color error '%-6s' FATAL
\r
82 + echo " $test_subtest_name"
\r
84 + echo "Unexpected exit while executing $0. Exit code $code."
\r
88 @@ -494,12 +498,12 @@ test_expect_equal ()
\r
89 if ! test_skip "$test_subtest_name"
\r
91 if [ "$output" = "$expected" ]; then
\r
92 - test_ok_ "$test_subtest_name"
\r
95 testname=$this_test.$test_count
\r
96 echo "$expected" > $testname.expected
\r
97 echo "$output" > $testname.output
\r
98 - test_failure_ "$test_subtest_name" "$(diff -u $testname.expected $testname.output)"
\r
99 + test_failure_ "$(diff -u $testname.expected $testname.output)"
\r
103 @@ -520,12 +524,12 @@ test_expect_equal_file ()
\r
104 if ! test_skip "$test_subtest_name"
\r
106 if diff -q "$file1" "$file2" >/dev/null ; then
\r
107 - test_ok_ "$test_subtest_name"
\r
110 testname=$this_test.$test_count
\r
111 cp "$file1" "$testname.$basename1"
\r
112 cp "$file2" "$testname.$basename2"
\r
113 - test_failure_ "$test_subtest_name" "$(diff -u "$testname.$basename1" "$testname.$basename2")"
\r
114 + test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")"
\r
118 @@ -563,9 +567,9 @@ test_emacs_expect_t () {
\r
119 result=$(cat OUTPUT)
\r
120 if [ "$result" = t ]
\r
122 - test_ok_ "$test_subtest_name"
\r
125 - test_failure_ "$test_subtest_name" "${result}"
\r
126 + test_failure_ "${result}"
\r
129 # Restore state after the (non) test.
\r
130 @@ -666,12 +670,12 @@ test_require_external_prereq () {
\r
133 if test "$test_subtest_known_broken_" = "t"; then
\r
134 - test_known_broken_ok_ "$@"
\r
135 + test_known_broken_ok_
\r
138 test_success=$(($test_success + 1))
\r
139 say_color pass "%-6s" "PASS"
\r
141 + echo " $test_subtest_name"
\r
145 @@ -680,7 +684,7 @@ test_failure_ () {
\r
148 test_failure=$(($test_failure + 1))
\r
149 - test_failure_message_ "FAIL" "$@"
\r
150 + test_failure_message_ "FAIL" "$test_subtest_name" "$@"
\r
151 test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
\r
154 @@ -697,13 +701,13 @@ test_known_broken_ok_ () {
\r
156 test_fixed=$(($test_fixed+1))
\r
157 say_color pass "%-6s" "FIXED"
\r
159 + echo " $test_subtest_name"
\r
162 test_known_broken_failure_ () {
\r
164 test_broken=$(($test_broken+1))
\r
165 - test_failure_message_ "BROKEN" "$@"
\r
166 + test_failure_message_ "BROKEN" "$test_subtest_name" "$@"
\r
170 @@ -771,6 +775,7 @@ test_expect_success () {
\r
171 test "$#" = 3 && { prereq=$1; shift; } || prereq=
\r
173 error "bug in the test script: not 2 or 3 parameters to test-expect-success"
\r
174 + test_subtest_name="$1"
\r
176 if ! test_skip "$@"
\r
178 @@ -780,9 +785,9 @@ test_expect_success () {
\r
179 test_check_missing_external_prereqs_ "$@" ||
\r
180 if [ "$run_ret" = 0 -a "$eval_ret" = 0 ]
\r
185 - test_failure_ "$@"
\r
186 + test_failure_ "$2"
\r
190 @@ -791,6 +796,7 @@ test_expect_code () {
\r
191 test "$#" = 4 && { prereq=$1; shift; } || prereq=
\r
193 error "bug in the test script: not 3 or 4 parameters to test-expect-code"
\r
194 + test_subtest_name="$2"
\r
196 if ! test_skip "$@"
\r
198 @@ -800,9 +806,9 @@ test_expect_code () {
\r
199 test_check_missing_external_prereqs_ "$@" ||
\r
200 if [ "$run_ret" = 0 -a "$eval_ret" = "$1" ]
\r
205 - test_failure_ "$@"
\r
206 + test_failure_ "exit code $eval_ret, expected $1" "$3"
\r
210 @@ -819,10 +825,10 @@ test_external () {
\r
211 test "$#" = 4 && { prereq=$1; shift; } || prereq=
\r
213 error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
\r
215 + test_subtest_name="$1"
\r
218 - if ! test_skip "$descr" "$@"
\r
219 + if ! test_skip "$test_subtest_name" "$@"
\r
221 # Announce the script to reduce confusion about the
\r
222 # test output that follows.
\r
223 @@ -833,9 +839,9 @@ test_external () {
\r
227 - test_ok_ "$descr"
\r
230 - test_failure_ "$descr" "$@"
\r
231 + test_failure_ "$@"
\r
235 @@ -849,11 +855,11 @@ test_external_without_stderr () {
\r
236 stderr="$tmp/git-external-stderr.$$.tmp"
\r
237 test_external "$@" 4> "$stderr"
\r
238 [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
\r
239 - descr="no stderr: $1"
\r
240 + test_subtest_name="no stderr: $1"
\r
242 if [ ! -s "$stderr" ]; then
\r
244 - test_ok_ "$descr"
\r
247 if [ "$verbose" = t ]; then
\r
248 output=`echo; echo Stderr is:; cat "$stderr"`
\r
249 @@ -862,7 +868,7 @@ test_external_without_stderr () {
\r
251 # rm first in case test_failure exits.
\r
253 - test_failure_ "$descr" "$@" "$output"
\r
254 + test_failure_ "$@" "$output"
\r