X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib.sh;h=e4729a61cd8ec634847eabca8fa37609cf7b7bde;hp=77879c258219a1ff9c7f59748ea20025a87ce492;hb=1db3244bf1b271633976cb74952367e530d27d3d;hpb=a3ee732c522947a17329704aef2a099946420f52 diff --git a/test/test-lib.sh b/test/test-lib.sh index 77879c25..e4729a61 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -55,9 +55,15 @@ export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' # Keep the original TERM for say_color and test_emacs ORIGINAL_TERM=$TERM -# dtach(1) provides more capable terminal environment to anything -# that requires more than dumb terminal... -[ x"${TERM:-dumb}" = xdumb ] && SMART_TERM=vt100 || SMART_TERM=$TERM +# Set SMART_TERM to vt100 for known dumb/unknown terminal. +# Otherwise use whatever TERM is currently used so that +# users' actual TERM environments are being used in tests. +case ${TERM-} in + '' | dumb | unknown ) + SMART_TERM=vt100 ;; + *) + SMART_TERM=$TERM ;; +esac # For repeatability, reset the environment to known value. LANG=C @@ -74,6 +80,7 @@ if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \ fi TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}} TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient} +TEST_GDB=${TEST_GDB:-gdb} TEST_CC=${TEST_CC:-cc} TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"} @@ -86,15 +93,6 @@ unset GREP_OPTIONS # For emacsclient unset ALTERNATE_EDITOR -# Convenience -# -# A regexp to match 5 and 40 hexdigits -_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05" - -_x04='[0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -_x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04" - # Each test should start with something like this, after copyright notices: # # test_description='Description of this test... @@ -264,6 +262,8 @@ die () { GIT_EXIT_OK= # Note: TEST_TMPDIR *NOT* exported! TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX") +# Put GNUPGHOME in TMPDIR to avoid problems with long paths. +export GNUPGHOME="${TEST_TMPDIR}/gnupg" trap 'trap_exit' EXIT trap 'trap_signal' HUP INT TERM @@ -618,15 +618,15 @@ test_expect_equal_file () error "bug in the test script: not 2 or 3 parameters to test_expect_equal" file1="$1" - basename1=`basename "$file1"` file2="$2" - basename2=`basename "$file2"` if ! test_skip "$test_subtest_name" then if diff -q "$file1" "$file2" >/dev/null ; then test_ok_ else testname=$this_test.$test_count + basename1=`basename "$file1"` + basename2=`basename "$file2"` cp "$file1" "$testname.$basename1" cp "$file2" "$testname.$basename2" test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")" @@ -651,7 +651,7 @@ test_expect_equal_json () { # Sort the top-level list of JSON data from stdin. test_sort_json () { - PYTHONIOENCODING=utf-8 python -c \ + PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c \ "import sys, json; json.dump(sorted(json.load(sys.stdin)),sys.stdout)" } @@ -729,8 +729,9 @@ notmuch_json_show_sanitize () -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \ -e 's|"Date": "Fri, 05 Jan 2001 [^"]*0000"|"Date": "GENERATED_DATE"|g' \ -e 's|"filename": "signature.asc",||g' \ - -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g' \ - -e 's|"timestamp": 97.......|"timestamp": 42|g' + -e 's|"filename": \["/[^"]*"\],|"filename": \["YYYYY"\],|g' \ + -e 's|"timestamp": 97.......|"timestamp": 42|g' \ + -e 's|"content-length": [1-9][0-9]*|"content-length": "NONZERO"|g' } notmuch_emacs_error_sanitize () @@ -841,12 +842,12 @@ test_ok_ () { } test_failure_ () { + print_test_description if test "$test_subtest_known_broken_" = "t"; then test_known_broken_failure_ "$@" return fi test_failure=$(($test_failure + 1)) - print_test_description test_failure_message_ "FAIL" "$test_subtest_name" "$@" test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } return 1 @@ -856,7 +857,9 @@ test_failure_message_ () { say_color error "%-6s" "$1" echo " $2" shift 2 - echo "$@" | sed -e 's/^/ /' + if [ "$#" != "0" ]; then + echo "$@" | sed -e 's/^/ /' + fi if test "$verbose" != "t"; then cat test.output; fi } @@ -870,7 +873,11 @@ test_known_broken_ok_ () { test_known_broken_failure_ () { test_reset_state_ test_broken=$(($test_broken+1)) - test_failure_message_ "BROKEN" "$test_subtest_name" "$@" + if [ -z "$NOTMUCH_TEST_QUIET" ]; then + test_failure_message_ "BROKEN" "$test_subtest_name" "$@" + else + test_failure_message_ "BROKEN" "$test_subtest_name" + fi return 1 } @@ -1168,8 +1175,8 @@ test_emacs () { fi server_name="notmuch-test-suite-$$" # start a detached session with an emacs server - # user's TERM (or 'vt100' in case user's TERM is unset, empty - # or 'dumb') is given to dtach which assumes a minimally + # user's TERM (or 'vt100' in case user's TERM is known dumb + # or unknown) is given to dtach which assumes a minimally # VT100-compatible terminal -- and emacs inherits that TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \ sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \ @@ -1372,7 +1379,7 @@ esac test_declare_external_prereq dtach test_declare_external_prereq emacs test_declare_external_prereq ${TEST_EMACSCLIENT} -test_declare_external_prereq gdb +test_declare_external_prereq ${TEST_GDB} test_declare_external_prereq gpg test_declare_external_prereq openssl test_declare_external_prereq gpgsm