From: Junio C Hamano Date: Wed, 23 May 2018 05:38:17 +0000 (+0900) Subject: Merge branch 'js/test-unset-prereq' X-Git-Tag: v2.18.0-rc0~55 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5002702e487dc501702b29e768b78d5c22114425?ds=inline;hp=-c Merge branch 'js/test-unset-prereq' Test debugging aid. * js/test-unset-prereq: tests: introduce test_unset_prereq, for debugging --- 5002702e487dc501702b29e768b78d5c22114425 diff --combined t/test-lib-functions.sh index c55ef099c3,dfe99b080f..2b2181dca0 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@@ -145,28 -145,12 +145,28 @@@ test_pause () "$SHELL_PATH" <&6 >&5 2>&7 } -# Wrap git in gdb. Adding this to a command can make it easier to -# understand what is going on in a failing test. +# Wrap git with a debugger. Adding this to a command can make it easier +# to understand what is going on in a failing test. # -# Example: "debug git checkout master". +# Examples: +# debug git checkout master +# debug --debugger=nemiver git $ARGS +# debug -d "valgrind --tool=memcheck --track-origins=yes" git $ARGS debug () { - GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7 + case "$1" in + -d) + GIT_DEBUGGER="$2" && + shift 2 + ;; + --debugger=*) + GIT_DEBUGGER="${1#*=}" && + shift 1 + ;; + *) + GIT_DEBUGGER=1 + ;; + esac && + GIT_DEBUGGER="${GIT_DEBUGGER}" "$@" <&6 >&5 2>&7 } # Call test_commit with the arguments @@@ -294,8 -278,20 +294,20 @@@ write_script () # The single parameter is the prerequisite tag (a simple word, in all # capital letters by convention). + test_unset_prereq () { + ! test_have_prereq "$1" || + satisfied_prereq="${satisfied_prereq% $1 *} ${satisfied_prereq#* $1 }" + } + test_set_prereq () { - satisfied_prereq="$satisfied_prereq$1 " + case "$1" in + !*) + test_unset_prereq "${1#!}" + ;; + *) + satisfied_prereq="$satisfied_prereq$1 " + ;; + esac } satisfied_prereq=" " lazily_testable_prereq= lazily_tested_prereq= @@@ -798,8 -794,11 +810,8 @@@ verbose () # otherwise. test_must_be_empty () { - if ! test -f "$1" - then - echo "'$1' is missing" - return 1 - elif test -s "$1" + test_path_is_file "$1" && + if test -s "$1" then echo "'$1' is not empty, it contains:" cat "$1"