From c969a1f26a7ade7f30ae2ca3ffdf52d3beaeb099 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 12 Jan 2018 14:28:08 +0000 Subject: [PATCH] tests: Include the filename in error messages. The new failure mode is: . Running test main Bail out! On './highlighters/main/test-data/glob.zsh': Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank Bail out! On './highlighters/main/test-data/glob.zsh': output on stderr Running test pattern Fixes #478. --- tests/test-highlighting.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index 2f4d3c3..11fb66d 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -92,7 +92,7 @@ run_test_internal() { local tests_tempdir="$1"; shift local srcdir="$PWD" - builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! cd failed: $?"; return 1 } + builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! On ${(qq)1}: cd failed: $?"; return 1 } echo "# ${1:t:r}" @@ -104,9 +104,9 @@ run_test_internal() { (( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; } # Check the data declares $PREBUFFER or $BUFFER. - [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; } + [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! On ${(qq)1}: Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; } # Check the data declares $expected_region_highlight. - (( ${#expected_region_highlight} == 0 )) && { echo >&2 "Bail out! 'expected_region_highlight' is not declared or empty."; return 1; } + (( ${#expected_region_highlight} == 0 )) && { echo >&2 "Bail out! On ${(qq)1}: 'expected_region_highlight' is not declared or empty."; return 1; } # Set sane defaults for ZLE variables : ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget} @@ -184,7 +184,7 @@ run_test() { local ret=$pipestatus[1] stderr=$pipestatus[2] if (( ! stderr )); then # stdout will become stderr - echo "Bail out! output on stderr"; return 1 + echo "Bail out! On ${(qq)1}: output on stderr"; return 1 else return $ret fi