aboutsummaryrefslogtreecommitdiff
path: root/test/test-lib.sh
diff options
context:
space:
mode:
authorJani Nikula <jani@nikula.org>2017-02-26 15:43:00 +0200
committerDavid Bremner <david@tethera.net>2017-03-09 09:01:21 -0400
commitd0cd253b37646d9364d046e1d3edb022a58c105a (patch)
treeff9af83a8bd1e3380e81c3e3d73389fc98d190a7 /test/test-lib.sh
parentb8f12bd3717aa446ef04197734af7a055e6909fe (diff)
test: require test_begin_subtest before test_expect_success
Unify the subtests by requiring test_begin_subtest before test_expect_success. (Similar change for test_expect_code will follow.) This increases clarity in the test scripts by having a separate line for the start of the subtest with the heading, and makes it possible to simplify the test infrastructure by making all subtests similar.
Diffstat (limited to 'test/test-lib.sh')
-rw-r--r--test/test-lib.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh
index f8c6e1e0..b68290c3 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -916,13 +916,17 @@ test_subtest_known_broken () {
}
test_expect_success () {
- test "$#" = 2 ||
- error "bug in the test script: not 2 parameters to test_expect_success"
- test_subtest_name="$1"
- test_reset_state_
- if ! test_skip "$@"
+ exec 1>&6 2>&7 # Restore stdout and stderr
+ if [ -z "$inside_subtest" ]; then
+ error "bug in the test script: test_expect_success without test_begin_subtest"
+ fi
+ inside_subtest=
+ test "$#" = 1 ||
+ error "bug in the test script: not 1 parameters to test_expect_success"
+
+ if ! test_skip "$test_subtest_name"
then
- test_run_ "$2"
+ test_run_ "$1"
run_ret="$?"
# test_run_ may update missing external prerequisites
test_check_missing_external_prereqs_ "$@" ||
@@ -930,7 +934,7 @@ test_expect_success () {
then
test_ok_
else
- test_failure_ "$2"
+ test_failure_ "$1"
fi
fi
}