From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/3] test: improve known broken tests support
Date: Mon, 4 Jul 2011 05:59:02 +0400 [thread overview]
Message-ID: <1309744743-8556-2-git-send-email-dmitry.kurochkin@gmail.com> (raw)
In-Reply-To: <1309744743-8556-1-git-send-email-dmitry.kurochkin@gmail.com>
There is existing support for broken tests. But it is not convenient
to use. The primary issue is that we have to maintain a set of
test_expect_*_failure functions which are equivalent to the normal
test_expect_* counterparts except for what functions are called for
result reporting. The patch adds test_subtest_known_broken function
which marks a subset as broken, making the normal test_expect_*
functions behave as test_expect_*_failure. All test_expect_*_failure
functions are removed. Test_known_broken_failure_ is changed to
format details the same way as test_failure_ does.
Another benefit of this change is that the diff when a broken test is
fixed would be small and nice.
Documentation is updated accordingly.
---
test/README | 17 ++++++++---------
test/test-lib.sh | 53 +++++++++++++++--------------------------------------
2 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/test/README b/test/README
index a245bf1..f926b9f 100644
--- a/test/README
+++ b/test/README
@@ -132,20 +132,19 @@ library for your script to use.
<script>. If it yields success, test is considered
successful. <message> should state what it is testing.
- test_expect_failure <message> <script>
-
- This is NOT the opposite of test_expect_success, but is used
- to mark a test that demonstrates a known breakage. Unlike
- the usual test_expect_success tests, which say "ok" on
- success and "FAIL" on failure, this will say "FIXED" on
- success and "still broken" on failure. Failures from these
- tests won't cause -i (immediate) to stop.
-
test_begin_subtest <message>
Set the test description message for a subsequent test_expect_equal
invocation (see below).
+ test_subtest_known_broken
+
+ Mark the current test as broken. Such tests are expected to fail.
+ Unlike the normal tests, which say "PASS" on success and "FAIL" on
+ failure, these will say "FIXED" on success and "BROKEN" on failure.
+ Failures from these tests won't cause -i (immediate) to stop. This
+ must be called before any test_expect_* function.
+
test_expect_equal <output> <expected>
This is an often-used convenience function built on top of
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 22e387e..0cd4170 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -424,6 +424,7 @@ test_begin_subtest ()
error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}"
fi
test_subtest_name="$1"
+ test_subtest_known_broken_=
# Remember stdout and stderr file descriptors and redirect test
# output to the previously prepared file descriptors 3 and 4 (see
# below)
@@ -484,29 +485,6 @@ test_expect_equal_file ()
fi
}
-test_expect_equal_failure ()
-{
- exec 1>&6 2>&7 # Restore stdout and stderr
- inside_subtest=
- test "$#" = 3 && { prereq=$1; shift; } || prereq=
- test "$#" = 2 ||
- error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
-
- output="$1"
- expected="$2"
- if ! test_skip "$@"
- then
- if [ "$output" = "$expected" ]; then
- test_known_broken_ok_ "$test_subtest_name"
- else
- test_known_broken_failure_ "$test_subtest_name"
- testname=$this_test.$test_count
- echo "$expected" > $testname.expected
- echo "$output" > $testname.output
- fi
- fi
-}
-
NOTMUCH_NEW ()
{
notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
@@ -568,12 +546,20 @@ test_have_prereq () {
# the text_expect_* functions instead.
test_ok_ () {
+ if [ "$test_subtest_known_broken_" = 1 ]; then
+ test_known_broken_ok_ "$@"
+ return
+ fi
test_success=$(($test_success + 1))
say_color pass "%-6s" "PASS"
echo " $@"
}
test_failure_ () {
+ if [ "$test_subtest_known_broken_" = 1 ]; then
+ test_known_broken_failure_ "$@"
+ return
+ fi
test_failure=$(($test_failure + 1))
say_color error "%-6s" "FAIL"
echo " $1"
@@ -592,7 +578,10 @@ test_known_broken_ok_ () {
test_known_broken_failure_ () {
test_broken=$(($test_broken+1))
say_color pass "%-6s" "BROKEN"
- echo " $@"
+ echo " $1"
+ shift
+ echo "$@" | sed -e 's/^/ /'
+ if test "$verbose" != "t"; then cat test.output; fi
}
test_debug () {
@@ -636,20 +625,8 @@ test_skip () {
esac
}
-test_expect_failure () {
- test "$#" = 3 && { prereq=$1; shift; } || prereq=
- test "$#" = 2 ||
- error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
- if ! test_skip "$@"
- then
- test_run_ "$2"
- if [ "$?" = 0 -a "$eval_ret" = 0 ]
- then
- test_known_broken_ok_ "$1"
- else
- test_known_broken_failure_ "$1"
- fi
- fi
+test_subtest_known_broken () {
+ test_subtest_known_broken_=1
}
test_expect_success () {
--
1.7.5.4
next prev parent reply other threads:[~2011-07-04 2:00 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-04 1:59 [PATCH 1/3] test: update documentation for test_emacs in test/README Dmitry Kurochkin
2011-07-04 1:59 ` Dmitry Kurochkin [this message]
2011-07-04 3:42 ` [PATCH 2/3] test: improve known broken tests support Austin Clements
2011-07-04 3:46 ` Dmitry Kurochkin
2011-07-04 1:59 ` [PATCH 3/3] test: add emacs test for hiding a message following an HTML part Dmitry Kurochkin
2011-09-26 11:01 ` David Bremner
2011-09-26 17:25 ` Dmitry Kurochkin
2011-10-01 11:51 ` David Bremner
2011-10-02 1:45 ` Dmitry Kurochkin
2011-10-03 12:39 ` Thomas Jost
2011-10-03 13:38 ` Dmitry Kurochkin
2011-10-03 14:27 ` David Bremner
2011-10-03 16:47 ` [PATCH 00/13] Test prereqs and screen-based Emacs tests Thomas Jost
2011-11-01 19:54 ` Pieter Praet
2011-11-13 17:46 ` David Bremner
2011-11-16 13:03 ` Pieter Praet
2011-10-03 16:47 ` [PATCH 01/13] test: define a helper function for defining prereqs on executables Thomas Jost
2011-10-03 16:47 ` [PATCH 02/13] test: add 'GnuPG' prereq to dependent 'crypto' tests Thomas Jost
2011-10-03 16:47 ` [PATCH 03/13] test: add 'Emacs' " Thomas Jost
2011-11-01 19:56 ` Pieter Praet
2011-11-01 20:15 ` Pieter Praet
2011-10-03 16:47 ` [PATCH 04/13] test: add 'Emacs' prereq to dependent 'emacs' tests Thomas Jost
2011-11-01 19:57 ` Pieter Praet
2011-11-01 20:08 ` Pieter Praet
2011-10-03 16:47 ` [PATCH 05/13] test: add 'Emacs' prereq to dependent 'emacs-large-search-buffer' tests Thomas Jost
2011-10-03 16:47 ` [PATCH 06/13] test: run emacs inside screen Thomas Jost
2011-11-10 7:36 ` Jameson Graef Rollins
2011-11-10 8:10 ` Thomas Jost
2011-10-03 16:47 ` [PATCH 07/13] test: avoid using screen(1) configuration files Thomas Jost
2011-10-03 16:47 ` [PATCH 08/13] test: do not set frame width in emacs Thomas Jost
2011-10-03 16:47 ` [PATCH 09/13] test: `notmuch-show-advance-and-archive' with invisible signature Thomas Jost
2011-10-03 16:47 ` [PATCH 10/13] emacs: improve hidden signatures handling in notmuch-show-advance-and-archive Thomas Jost
2011-10-03 16:47 ` [PATCH 11/13] emacs: remove no longer used functions from notmuch-show.el Thomas Jost
2011-10-03 16:47 ` [PATCH 12/13] emacs: remove unused `point-invisible-p' function Thomas Jost
2011-10-03 16:47 ` [PATCH 13/13] test: make smtp-dummy work with Emacs 24 Thomas Jost
2011-11-13 19:09 ` David Bremner
2011-12-15 12:14 ` [PATCH 3/3] test: add emacs test for hiding a message following an HTML part David Bremner
2011-12-15 17:27 ` Tom Prince
2011-12-16 18:51 ` Dmitry Kurochkin
2011-07-04 4:07 ` [PATCH v2 0/3] improved broken tests support and test for a bug Dmitry Kurochkin
2011-07-04 4:07 ` [PATCH v2 1/3] test: update documentation for test_emacs in test/README Dmitry Kurochkin
2011-07-04 4:07 ` [PATCH v2 2/3] test: improve known broken tests support Dmitry Kurochkin
2011-09-11 23:11 ` [PATCH] test: reset known_broken status in test_expect_equal and test_expect_equal_file david
2011-09-11 23:30 ` Dmitry Kurochkin
2011-09-11 23:51 ` David Bremner
2011-09-12 0:26 ` Dmitry Kurochkin
2011-09-13 2:41 ` [PATCH] test: reset test_subtest_known_broken_ after each success/failure david
2011-09-13 10:19 ` Dmitry Kurochkin
2011-09-13 11:39 ` David Bremner
2011-07-04 4:07 ` [PATCH v2 3/3] test: add emacs test for hiding a message following an HTML part Dmitry Kurochkin
2011-09-10 18:08 ` [PATCH v2 0/3] improved broken tests support and test for a bug David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1309744743-8556-2-git-send-email-dmitry.kurochkin@gmail.com \
--to=dmitry.kurochkin@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).