X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib.sh;h=988b00afde86b7ff306c2b0812d9b7e6fa0a0428;hp=f8c6e1e074037b92141e8315481adb8d93c76200;hb=936c35da86aebf76b14f4ba198f760403455cfe0;hpb=b8f12bd3717aa446ef04197734af7a055e6909fe diff --git a/test/test-lib.sh b/test/test-lib.sh index f8c6e1e0..988b00af 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,19 +934,23 @@ test_expect_success () { then test_ok_ else - test_failure_ "$2" + test_failure_ "$1" fi fi } test_expect_code () { - test "$#" = 3 || - error "bug in the test script: not 3 parameters to test_expect_code" - test_subtest_name="$2" - 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_code without test_begin_subtest" + fi + inside_subtest= + test "$#" = 2 || + error "bug in the test script: not 2 parameters to test_expect_code" + + if ! test_skip "$test_subtest_name" then - test_run_ "$3" + test_run_ "$2" run_ret="$?" # test_run_ may update missing external prerequisites, test_check_missing_external_prereqs_ "$@" || @@ -950,7 +958,7 @@ test_expect_code () { then test_ok_ else - test_failure_ "exit code $eval_ret, expected $1" "$3" + test_failure_ "exit code $eval_ret, expected $1" "$2" fi fi } @@ -1113,7 +1121,7 @@ test_emacs () { test_python() { # Note: if there is need to print debug information from python program, # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w') - PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \ + PYTHONPATH="$NOTMUCH_SRCDIR/bindings/python${PYTHONPATH:+:$PYTHONPATH}" \ $NOTMUCH_PYTHON -B - > OUTPUT } @@ -1125,7 +1133,7 @@ test_C () { exec_file="test${test_count}" test_file="${exec_file}.c" cat > ${test_file} - ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY} -I${TEST_DIRECTORY}/../lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc + ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY} -I${NOTMUCH_SRCDIR}/lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc echo "== stdout ==" > OUTPUT.stdout echo "== stderr ==" > OUTPUT.stderr ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr