aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Michal Sojka <sojkam1@fel.cvut.cz>2010-11-14 22:54:31 +0100
committerGravatar Carl Worth <cworth@cworth.org>2010-11-16 11:28:06 -0800
commit556986511c010b72e31c8778a2a5a514586c9fed (patch)
treea356760f912decb0a32ca6efcaa21a237ca35227 /test
parentf22a7ec1e28d1264cf9d67d78796b8ab22e09a35 (diff)
test: Detect unfinished subsets
When test_begin_subtest is not followed by corresponding test_expect_equal, the output of the rest of the test script is errornously suppressed. Add code to detect these bugs in test scripts.
Diffstat (limited to 'test')
-rw-r--r--test/test-lib.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh
index dce9077d..04a4c144 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -396,12 +396,17 @@ add_email_corpus ()
test_begin_subtest ()
{
+ if [ -n "$inside_subtest" ]; then
+ exec 1>&6 2>&7 # Restore stdout and stderr
+ error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}"
+ fi
test_subtest_name="$1"
# Remember stdout and stderr file descriptios and redirect test
# output to the previously prepared file descriptors 3 and 4 (see
# bellow)
if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi
exec 6>&1 7>&2 >&3 2>&4
+ inside_subtest=t
}
# Pass test if two arguments match
@@ -413,6 +418,7 @@ test_begin_subtest ()
test_expect_equal ()
{
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"