1 Return-Path: <sojkam1@fel.cvut.cz>
\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 D373040DF1D
\r
6 for <notmuch@notmuchmail.org>; Sun, 21 Nov 2010 04:08:28 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\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 8UQWKIisO9yL for <notmuch@notmuchmail.org>;
\r
16 Sun, 21 Nov 2010 04:08:18 -0800 (PST)
\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 312B440DF1C
\r
19 for <notmuch@notmuchmail.org>; Sun, 21 Nov 2010 04:08:18 -0800 (PST)
\r
20 Received: from localhost (unknown [192.168.200.4])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id 2344719F3340;
\r
22 Sun, 21 Nov 2010 13:08:17 +0100 (CET)
\r
23 X-Virus-Scanned: IMAP AMAVIS
\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])
\r
25 by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,
\r
27 with ESMTP id p+QNtAy490Gi; Sun, 21 Nov 2010 13:08:15 +0100 (CET)
\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])
\r
29 by max.feld.cvut.cz (Postfix) with ESMTP id E417919F30E1;
\r
30 Sun, 21 Nov 2010 13:08:15 +0100 (CET)
\r
31 Received: from wsheee.2x.cz (unknown [213.29.198.144])
\r
32 (Authenticated sender: sojkam1)
\r
33 by imap.feld.cvut.cz (Postfix) with ESMTPSA id A395FFA003;
\r
34 Sun, 21 Nov 2010 13:08:14 +0100 (CET)
\r
35 Received: from wsh by wsheee.2x.cz with local (Exim 4.72)
\r
36 (envelope-from <sojkam1@fel.cvut.cz>)
\r
37 id 1PK8iM-0004K4-81; Sun, 21 Nov 2010 13:08:14 +0100
\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH] test: Detect when some command unexpectedly fails
\r
41 Date: Sun, 21 Nov 2010 13:08:12 +0100
\r
42 Message-Id: <1290341292-16589-1-git-send-email-sojkam1@fel.cvut.cz>
\r
43 X-Mailer: git-send-email 1.7.1.90.g94d6d4
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Sun, 21 Nov 2010 12:08:29 -0000
\r
58 When some command in between test_begin_subtest and test_expect_equal
\r
59 fails, the test suite does not detect it unless the failure leads to
\r
60 difference in the strings compared by test_expect_equal.
\r
62 This patch sets shell -e option which switches on the detection of
\r
63 failed commands (thise with non-zero exit status). If some command fails
\r
64 the test script exits with exit code of 1 and prints the failed command.
\r
65 It might be better to print the line number of the failed command but it
\r
66 seems that inside traps, the BASH_LINENO variable does not contain the
\r
70 test/test-lib.sh | 5 ++++-
\r
71 2 files changed, 5 insertions(+), 2 deletions(-)
\r
73 diff --git a/test/raw b/test/raw
\r
74 index 4ed237c..87e18b1 100755
\r
77 @@ -10,7 +10,7 @@ output=$(NOTMUCH_NEW)
\r
78 test_expect_equal "$output" "Added 2 new messages to the database."
\r
80 test_begin_subtest "Attempt to show multiple raw messages"
\r
81 -output=$(notmuch show --format=raw "*" 2>&1)
\r
82 +output=$(notmuch show --format=raw "*" 2>&1 || :)
\r
83 test_expect_equal "$output" "Error: search term did not match precisely one message."
\r
85 test_begin_subtest "Show a raw message"
\r
86 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
87 index 04a4c14..1ad0da6 100644
\r
88 --- a/test/test-lib.sh
\r
89 +++ b/test/test-lib.sh
\r
90 @@ -178,7 +178,7 @@ die () {
\r
94 - echo >&5 "FATAL: Unexpected exit with code $code"
\r
95 + echo >&5 "FATAL: Unexpected exit with code $code: $BASH_COMMAND"
\r
99 @@ -407,6 +407,7 @@ test_begin_subtest ()
\r
100 if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
\r
101 exec 6>&1 7>&2 >&3 2>&4
\r
106 # Pass test if two arguments match
\r
107 @@ -418,6 +419,7 @@ test_begin_subtest ()
\r
108 test_expect_equal ()
\r
110 exec 1>&6 2>&7 # Restore stdout and stderr
\r
113 test "$#" = 3 && { prereq=$1; shift; } || prereq=
\r
115 @@ -440,6 +442,7 @@ test_expect_equal ()
\r
117 test_expect_equal_failure ()
\r
120 test "$#" = 3 && { prereq=$1; shift; } || prereq=
\r
122 error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
\r