Skip to content

Commit

Permalink
Merge branch 'cb/test-bash-lineno-fix'
Browse files Browse the repository at this point in the history
Recent change to show files and line numbers of a breakage during
test (only available when running the tests with bash) were hurting
other shells with syntax errors, which has been corrected.

* cb/test-bash-lineno-fix:
  t/test_lib: avoid naked bash arrays in file_lineno
  • Loading branch information
gitster committed May 8, 2020
2 parents 41eae3e + 303775a commit 282ce92
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -677,14 +677,16 @@ die () {

file_lineno () {
test -z "$GIT_TEST_FRAMEWORK_SELFTEST" && test -n "$BASH" || return 0
local i
for i in ${!BASH_SOURCE[*]}
do
case $i,"${BASH_SOURCE[$i]##*/}" in
0,t[0-9]*.sh) echo "t/${BASH_SOURCE[$i]}:$LINENO: ${1+$1: }"; return;;
*,t[0-9]*.sh) echo "t/${BASH_SOURCE[$i]}:${BASH_LINENO[$(($i-1))]}: ${1+$1: }"; return;;
esac
done
eval '
local i
for i in ${!BASH_SOURCE[*]}
do
case $i,"${BASH_SOURCE[$i]##*/}" in
0,t[0-9]*.sh) echo "t/${BASH_SOURCE[$i]}:$LINENO: ${1+$1: }"; return;;
*,t[0-9]*.sh) echo "t/${BASH_SOURCE[$i]}:${BASH_LINENO[$(($i-1))]}: ${1+$1: }"; return;;
esac
done
'
}

GIT_EXIT_OK=
Expand Down

0 comments on commit 282ce92

Please sign in to comment.