[PATCH 6/9] test: ensure test_begin_subtest has been called before test_expect_*

Jani Nikula jani at nikula.org
Sun Feb 26 05:42:58 PST 2017


This is the expectation, increase robustness of the test suite by
requiring it.
---
 test/test-lib.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 0a486f4cde9a..056483c47c0a 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -566,6 +566,9 @@ test_begin_subtest ()
 test_expect_equal ()
 {
 	exec 1>&6 2>&7		# Restore stdout and stderr
+	if [ -z "$inside_subtest" ]; then
+		error "bug in the test script: test_expect_equal without test_begin_subtest"
+	fi
 	inside_subtest=
 	test "$#" = 3 && { prereq=$1; shift; } || prereq=
 	test "$#" = 2 ||
@@ -590,6 +593,9 @@ test_expect_equal ()
 test_expect_equal_file ()
 {
 	exec 1>&6 2>&7		# Restore stdout and stderr
+	if [ -z "$inside_subtest" ]; then
+		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 ||
@@ -637,6 +643,9 @@ 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"
+	if [ -z "$inside_subtest" ]; then
+		error "bug in the test script: test_emacs_expect_t without test_begin_subtest"
+	fi
 
 	# Run the test.
 	if ! test_skip "$test_subtest_name"
-- 
2.11.0



More information about the notmuch mailing list