]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test: ensure test_begin_subtest has been called before test_expect_*
[notmuch] / test / test-lib.sh
index 51c01866d64cee07b78002edf0493e4c6f275ace..e7458c92f320d2b634ffed042e909c2324782f1a 100644 (file)
@@ -113,17 +113,15 @@ unset ALTERNATE_EDITOR
 while test "$#" -ne 0
 do
        case "$1" in
-       -d|--d|--de|--deb|--debu|--debug)
+       -d|--debug)
                debug=t; shift ;;
-       -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
+       -i|--immediate)
                immediate=t; shift ;;
-       -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)
-               GIT_TEST_LONG=t; export GIT_TEST_LONG; shift ;;
-       -h|--h|--he|--hel|--help)
+       -h|--help)
                help=t; shift ;;
-       -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
+       -v|--verbose)
                verbose=t; shift ;;
-       -q|--q|--qu|--qui|--quie|--quiet)
+       -q|--quiet)
                quiet=t; shift ;;
        --with-dashes)
                with_dashes=t; shift ;;
@@ -132,7 +130,7 @@ do
        --no-python)
                # noop now...
                shift ;;
-       --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
+       --valgrind)
                valgrind=t; verbose=t; shift ;;
        --tee)
                shift ;; # was handled already
@@ -561,6 +559,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 ||
@@ -585,6 +586,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 ||
@@ -632,6 +636,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"