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 9720840DDC9
\r
6 for <notmuch@notmuchmail.org>; Sun, 14 Nov 2010 13:54:54 -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 B8M0rVVqMv-0 for <notmuch@notmuchmail.org>;
\r
16 Sun, 14 Nov 2010 13:54:42 -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 B81C440DDF7
\r
19 for <notmuch@notmuchmail.org>; Sun, 14 Nov 2010 13:54:41 -0800 (PST)
\r
20 Received: from localhost (unknown [192.168.200.4])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id 175533CFE74;
\r
22 Sun, 14 Nov 2010 22:54:41 +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 o6lj5FZRmmI4; Sun, 14 Nov 2010 22:54:39 +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 6FA0F19F331D;
\r
30 Sun, 14 Nov 2010 22:54:39 +0100 (CET)
\r
31 Received: from steelpick.2x.cz (unknown [213.29.198.144])
\r
32 (Authenticated sender: sojkam1)
\r
33 by imap.feld.cvut.cz (Postfix) with ESMTPSA id 51E4DFA004;
\r
34 Sun, 14 Nov 2010 22:54:39 +0100 (CET)
\r
35 Received: from wsh by steelpick.2x.cz with local (Exim 4.72)
\r
36 (envelope-from <sojkam1@fel.cvut.cz>)
\r
37 id 1PHkX0-0002Oy-W7; Sun, 14 Nov 2010 22:54:39 +0100
\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 1/5] test: Better handling of stdout and stderr
\r
41 Date: Sun, 14 Nov 2010 22:54:28 +0100
\r
42 Message-Id: <1289771672-9204-1-git-send-email-sojkam1@fel.cvut.cz>
\r
43 X-Mailer: git-send-email 1.7.2.3
\r
44 In-Reply-To: <87hbfjr2sr.fsf@steelpick.2x.cz>
\r
45 References: <87hbfjr2sr.fsf@steelpick.2x.cz>
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Sun, 14 Nov 2010 21:54:54 -0000
\r
60 Git-style tests (test_expect_success etc.) suppress stdout and stderr
\r
61 unless -v is given. Notmuch-style tests (created by test_begin_subtest
\r
62 and test_expect_equal) do not have this behavior so implement it the
\r
65 Additionally, for both test styles, the test-lib.sh is changed so that
\r
66 the content of suppressed stdout and stderr is shown in case of failed
\r
69 Finally a test for this functionality is added to basic tests.
\r
71 test/basic | 21 ++++++++++++++++++++-
\r
72 test/test-lib.sh | 21 +++++++++++++++------
\r
73 test/test-verbose | 27 +++++++++++++++++++++++++++
\r
74 test/test.expected-output/test-verbose-no | 20 ++++++++++++++++++++
\r
75 test/test.expected-output/test-verbose-yes | 24 ++++++++++++++++++++++++
\r
76 5 files changed, 106 insertions(+), 7 deletions(-)
\r
77 create mode 100755 test/test-verbose
\r
78 create mode 100644 test/test.expected-output/test-verbose-no
\r
79 create mode 100644 test/test.expected-output/test-verbose-yes
\r
81 diff --git a/test/basic b/test/basic
\r
82 index 725c753..309779c 100755
\r
85 @@ -52,9 +52,28 @@ test_expect_code 2 'failure to clean up causes the test to fail' '
\r
86 # Ensure that all tests are being run
\r
87 test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
\r
88 tests_in_suite=$(grep TESTS= ../notmuch-test | sed -e "s/TESTS=\"\(.*\)\"/\1/" | tr " " "\n" | sort)
\r
89 -available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*|emacs.expected-output|smtp-dummy|smtp-dummy.c)" | sort)
\r
90 +available=$(ls -1 ../ | grep -v -E "^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test|README|test-lib.sh|test-results|tmp.*|valgrind|corpus*|emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|test.expected-output)" | sort)
\r
91 test_expect_equal "$tests_in_suite" "$available"
\r
93 +EXPECTED=../test.expected-output
\r
94 +suppress_diff_date() {
\r
95 + sed -e 's/\(.*\-\-\- test-verbose\.4\.\expected\).*/\1/' \
\r
96 + -e 's/\(.*\+\+\+ test-verbose\.4\.\output\).*/\1/'
\r
99 +test_begin_subtest "Ensure that test output is suppressed unless the test fails"
\r
100 +output=$(cd ..; ./test-verbose 2>&1 | suppress_diff_date)
\r
101 +expected=$(cat $EXPECTED/test-verbose-no | suppress_diff_date)
\r
102 +test_expect_equal "$output" "$expected"
\r
104 +test_begin_subtest "Ensure that -v does not suppress test output"
\r
105 +output=$(cd ..; ./test-verbose -v 2>&1 | suppress_diff_date)
\r
106 +expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)
\r
107 +# Do not include the results of test-verbose in totals
\r
108 +rm $TEST_DIRECTORY/test-results/test-verbose-*
\r
109 +test_expect_equal "$output" "$expected"
\r
112 ################################################################
\r
113 # Test mail store prepared in test-lib.sh
\r
115 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
116 index 418eaa7..68c9cf8 100644
\r
117 --- a/test/test-lib.sh
\r
118 +++ b/test/test-lib.sh
\r
119 @@ -165,12 +165,6 @@ fi
\r
120 echo $(basename "$0"): "Testing ${test_description}"
\r
123 -if test "$verbose" = "t"
\r
127 - exec 4>/dev/null 3>/dev/null
\r
132 @@ -403,6 +397,11 @@ add_email_corpus ()
\r
133 test_begin_subtest ()
\r
135 test_subtest_name="$1"
\r
136 + # Remember stdout and stderr file descriptios and redirect test
\r
137 + # output to the previously prepared file descriptors 3 and 4 (see
\r
139 + if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
\r
140 + exec 6>&1 7>&2 >&3 2>&4
\r
143 # Pass test if two arguments match
\r
144 @@ -413,6 +412,7 @@ test_begin_subtest ()
\r
146 test_expect_equal ()
\r
148 + exec 1>&6 2>&7 # Restore stdout and stderr
\r
149 test "$#" = 3 && { prereq=$1; shift; } || prereq=
\r
151 error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
\r
152 @@ -508,6 +508,7 @@ test_failure_ () {
\r
155 echo "$@" | sed -e 's/^/ /'
\r
156 + if test "$verbose" != "t"; then cat test.output; fi
\r
157 test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
\r
160 @@ -529,6 +530,7 @@ test_debug () {
\r
164 + if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
\r
167 eval >&3 2>&4 "$test_cleanup"
\r
168 @@ -918,6 +920,13 @@ EOF
\r
169 # in subprocesses like git equals our $PWD (for pathname comparisons).
\r
170 cd -P "$test" || error "Cannot setup test environment"
\r
172 +if test "$verbose" = "t"
\r
176 + exec 4>test.output 3>&4
\r
180 for skp in $NOTMUCH_SKIP_TESTS
\r
182 diff --git a/test/test-verbose b/test/test-verbose
\r
183 new file mode 100755
\r
184 index 0000000..f29a9c7
\r
186 +++ b/test/test-verbose
\r
190 +test_description='the verbosity options of the test framework itself.'
\r
194 +test_expect_success 'print something in test_expect_success and pass' '
\r
195 + echo "hello stdout" &&
\r
196 + echo "hello stderr" >&2 &&
\r
199 +test_expect_success 'print something in test_expect_success and fail' '
\r
200 + echo "hello stdout" &&
\r
201 + echo "hello stderr" >&2 &&
\r
204 +test_begin_subtest 'print something between test_begin_subtest and test_expect_equal and pass'
\r
205 +echo "hello stdout"
\r
206 +echo "hello stderr" >&2
\r
207 +test_expect_equal "a" "a"
\r
209 +test_begin_subtest 'print something test_begin_subtest and test_expect_equal and fail'
\r
210 +echo "hello stdout"
\r
211 +echo "hello stderr" >&2
\r
212 +test_expect_equal "a" "b"
\r
215 diff --git a/test/test.expected-output/test-verbose-no b/test/test.expected-output/test-verbose-no
\r
216 new file mode 100644
\r
217 index 0000000..0bca754
\r
219 +++ b/test/test.expected-output/test-verbose-no
\r
221 +test-verbose: Testing the verbosity options of the test framework itself.
\r
222 + PASS print something in test_expect_success and pass
\r
223 + FAIL print something in test_expect_success and fail
\r
225 + echo "hello stdout" &&
\r
226 + echo "hello stderr" >&2 &&
\r
231 + PASS print something between test_begin_subtest and test_expect_equal and pass
\r
232 + FAIL print something test_begin_subtest and test_expect_equal and fail
\r
233 + --- test-verbose.4.expected 2010-11-14 21:41:12.738189710 +0000
\r
234 + +++ test-verbose.4.output 2010-11-14 21:41:12.738189710 +0000
\r
241 diff --git a/test/test.expected-output/test-verbose-yes b/test/test.expected-output/test-verbose-yes
\r
242 new file mode 100644
\r
243 index 0000000..ebe5187
\r
245 +++ b/test/test.expected-output/test-verbose-yes
\r
247 +test-verbose: Testing the verbosity options of the test framework itself.
\r
250 + PASS print something in test_expect_success and pass
\r
253 + FAIL print something in test_expect_success and fail
\r
255 + echo "hello stdout" &&
\r
256 + echo "hello stderr" >&2 &&
\r
261 + PASS print something between test_begin_subtest and test_expect_equal and pass
\r
264 + FAIL print something test_begin_subtest and test_expect_equal and fail
\r
265 + --- test-verbose.4.expected 2010-11-14 21:41:06.650023289 +0000
\r
266 + +++ test-verbose.4.output 2010-11-14 21:41:06.650023289 +0000
\r