From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 7/9] test: drop the implicit prereq check mechanism from test_expect_*
Date: Sun, 26 Feb 2017 15:42:59 +0200 [thread overview]
Message-ID: <2f0c300015a1c65db2e2ef7c3204fc75929ae17d.1488116461.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1488116461.git.jani@nikula.org>
In-Reply-To: <cover.1488116461.git.jani@nikula.org>
The only place where we use the implicit prereq check is T000-basic.sh
where we check that it works. It's an added complication that we don't
use. Remove it.
The test_have_prereq function can still be used for the same effect in
subtests that use test_begin_subtest. For now, this will make it
impossible to have prereqs in one-line subtests that don't require
test_begin_subtest. This will be fixed in follow-up work.
---
test/T000-basic.sh | 2 +-
test/test-lib.sh | 26 ++++++--------------------
2 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/test/T000-basic.sh b/test/T000-basic.sh
index 0a8d6cdf40fc..78e183361e7d 100755
--- a/test/T000-basic.sh
+++ b/test/T000-basic.sh
@@ -23,7 +23,7 @@ test_expect_success 'success is reported like this' '
'
test_set_prereq HAVEIT
haveit=no
-test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
+test_expect_success 'test runs if prerequisite is satisfied' '
test_have_prereq HAVEIT &&
haveit=yes
'
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 056483c47c0a..3a69c399f6eb 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -570,9 +570,8 @@ test_expect_equal ()
error "bug in the test script: test_expect_equal without test_begin_subtest"
fi
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"
+ error "bug in the test script: not 2 parameters to test_expect_equal"
output="$1"
expected="$2"
@@ -597,9 +596,8 @@ test_expect_equal_file ()
error "bug in the test script: test_expect_equal_file without test_begin_subtest"
fi
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"
+ error "bug in the test script: not 2 parameters to test_expect_equal_file"
file1="$1"
file2="$2"
@@ -640,9 +638,8 @@ test_sort_json () {
}
test_emacs_expect_t () {
- test "$#" = 2 && { prereq=$1; shift; } || prereq=
test "$#" = 1 ||
- error "bug in the test script: not 1 or 2 parameters to test_emacs_expect_t"
+ error "bug in the test script: not 1 parameter to test_emacs_expect_t"
if [ -z "$inside_subtest" ]; then
error "bug in the test script: test_emacs_expect_t without test_begin_subtest"
fi
@@ -757,12 +754,8 @@ notmuch_config_sanitize ()
# End of notmuch helper functions
# Use test_set_prereq to tell that a particular prerequisite is available.
-# The prerequisite can later be checked for in two ways:
#
-# - Explicitly using test_have_prereq.
-#
-# - Implicitly by specifying the prerequisite tag in the calls to
-# test_expect_{success,failure,code}.
+# The prerequisite can later be checked for by using test_have_prereq.
#
# The single parameter is the prerequisite tag (a simple word, in all
# capital letters by convention).
@@ -891,11 +884,6 @@ test_skip () {
break
esac
done
- if test -z "$to_skip" && test -n "$prereq" &&
- ! test_have_prereq "$prereq"
- then
- to_skip=t
- fi
case "$to_skip" in
t)
test_report_skip_ "$@"
@@ -929,9 +917,8 @@ test_subtest_known_broken () {
}
test_expect_success () {
- test "$#" = 3 && { prereq=$1; shift; } || prereq=
test "$#" = 2 ||
- error "bug in the test script: not 2 or 3 parameters to test-expect-success"
+ error "bug in the test script: not 2 parameters to test_expect_success"
test_subtest_name="$1"
test_reset_state_
if ! test_skip "$@"
@@ -950,9 +937,8 @@ test_expect_success () {
}
test_expect_code () {
- test "$#" = 4 && { prereq=$1; shift; } || prereq=
test "$#" = 3 ||
- error "bug in the test script: not 3 or 4 parameters to test-expect-code"
+ error "bug in the test script: not 3 parameters to test_expect_code"
test_subtest_name="$2"
test_reset_state_
if ! test_skip "$@"
--
2.11.0
next prev parent reply other threads:[~2017-02-26 13:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-26 13:42 [PATCH 0/9] test: cleanup and refactoring Jani Nikula
2017-02-26 13:42 ` [PATCH 1/9] test: remove unused regexp convenience variables Jani Nikula
2017-02-26 13:42 ` [PATCH 2/9] test: remove unused filter functions Jani Nikula
2017-02-26 13:42 ` [PATCH 3/9] test: remove unused test_external and test_external_without_stderr Jani Nikula
2017-02-26 13:42 ` [PATCH 4/9] test: remove unused and no-op --long-tests parameter Jani Nikula
2017-02-26 13:42 ` [PATCH 5/9] test: only accept short and long options, not silly in-betweens Jani Nikula
2017-02-26 13:42 ` [PATCH 6/9] test: ensure test_begin_subtest has been called before test_expect_* Jani Nikula
2017-02-26 13:42 ` Jani Nikula [this message]
2017-02-26 13:43 ` [PATCH 8/9] test: require test_begin_subtest before test_expect_success Jani Nikula
2017-02-26 13:43 ` [PATCH 9/9] test: require test_begin_subtest before test_expect_code Jani Nikula
2017-03-10 11:45 ` [PATCH 0/9] test: cleanup and refactoring 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=2f0c300015a1c65db2e2ef7c3204fc75929ae17d.1488116461.git.jani@nikula.org \
--to=jani@nikula.org \
--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).