X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib.sh;h=f8c6e1e074037b92141e8315481adb8d93c76200;hp=b03f6a53668ac670034366346b76bf88323e83b0;hb=b8f12bd3717aa446ef04197734af7a055e6909fe;hpb=de66230b460c5ee2eb32d9fa33fe8247e3b5dec0 diff --git a/test/test-lib.sh b/test/test-lib.sh index b03f6a53..f8c6e1e0 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -113,15 +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 ;; - -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 ;; @@ -130,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 @@ -559,10 +559,12 @@ 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 || - 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" @@ -583,10 +585,12 @@ 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 || - 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" @@ -627,9 +631,11 @@ 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 # Run the test. if ! test_skip "$test_subtest_name" @@ -741,12 +747,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). @@ -881,11 +883,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_ "$@" @@ -919,9 +916,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 "$@" @@ -940,9 +936,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 "$@"