X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=test%2Ftest-lib.sh;h=6e475452805524193a9900c7a1b418fa13753c93;hb=5985438e057b51404208458fceadd03aae13eb80;hp=ffab1bb509c400e15948b7fbe5df83d6294187d2;hpb=f0dfda5c7797f9db81ce35d270fe0ac406c7fca1;p=notmuch diff --git a/test/test-lib.sh b/test/test-lib.sh index ffab1bb5..6e475452 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -22,6 +22,12 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then exit 1 fi +# Make sure echo builtin does not expand backslash-escape sequences by default. +shopt -u xpg_echo + +this_test=${0##*/} +this_test=${this_test%.sh} + # if --tee was passed, write the output not only to the terminal, but # additionally to the file test-results/$BASENAME.out, too. case "$GIT_TEST_TEE_STARTED, $* " in @@ -30,7 +36,7 @@ done,*) ;; *' --tee '*|*' --va'*) mkdir -p test-results - BASE=test-results/$(basename "$0" .sh) + BASE=test-results/$this_test (GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1; echo $? > $BASE.exit) | tee $BASE.out test "$(cat $BASE.exit)" = 0 @@ -184,7 +190,7 @@ then exit 0 fi -echo $(basename "$0"): "Testing ${test_description}" +echo $this_test: "Testing ${test_description}" exec 5>&1 @@ -442,6 +448,7 @@ emacs_deliver_message () test_emacs \ "(let ((message-send-mail-function 'message-smtpmail-send-it) + (mail-host-address \"example.com\") (smtpmail-smtp-server \"localhost\") (smtpmail-smtp-service \"25025\")) (notmuch-hello) @@ -624,6 +631,17 @@ notmuch_json_show_sanitize () -e 's|"filename": "/[^"]*",|"filename": "YYYYY",|g' } +notmuch_emacs_error_sanitize () +{ + local command=$1 + shift + for file in "$@"; do + echo "=== $file ===" + cat "$file" + done | sed \ + -e 's/^\[.*\]$/[XXX]/' \ + -e "s|^\(command: \)\{0,1\}/.*/$command|\1YYY/$command|" +} # End of notmuch helper functions # Use test_set_prereq to tell that a particular prerequisite is available. @@ -952,7 +970,7 @@ test_done () { GIT_EXIT_OK=t test_results_dir="$TEST_DIRECTORY/test-results" mkdir -p "$test_results_dir" - test_results_path="$test_results_dir/${0%.sh}" + test_results_path="$test_results_dir/$this_test" echo "total $test_count" >> $test_results_path echo "success $test_success" >> $test_results_path @@ -1011,7 +1029,7 @@ test_emacs () { test -z "$missing_dependencies" || return if [ -z "$EMACS_SERVER" ]; then - emacs_tests="$(basename $0).el" + emacs_tests="${this_test}.el" if [ -f "$TEST_DIRECTORY/$emacs_tests" ]; then load_emacs_tests="--eval '(load \"$emacs_tests\")'" else @@ -1125,7 +1143,6 @@ else exec 4>test.output 3>&4 fi -this_test=${0##*/} for skp in $NOTMUCH_SKIP_TESTS do to_skip=