From f6471dbec33e60d452abbb27ecdb36c59b4db05a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 11 Jun 2020 08:14:07 +0000 Subject: [PATCH] tests: Fix a wrong value of $PREBUFFER in a test, and add checks to prevent this from recurring. Discussed: https://github.com/zsh-users/zsh-syntax-highlighting/pull/706#issuecomment-642072978 --- highlighters/main/test-data/path_prefix3.zsh | 2 +- tests/test-highlighting.zsh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/highlighters/main/test-data/path_prefix3.zsh b/highlighters/main/test-data/path_prefix3.zsh index f4a0189..9f34f94 100644 --- a/highlighters/main/test-data/path_prefix3.zsh +++ b/highlighters/main/test-data/path_prefix3.zsh @@ -30,7 +30,7 @@ # Assumes that '/bin/sh' exists and '/bin/s' does not exist. # Related to path_prefix.zsh -PREBUFFER='ls \' +PREBUFFER=$'ls \\\n' BUFFER='/bin/s' expected_region_highlight=( diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index c30d571..0e8e03e 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -145,6 +145,7 @@ run_test_internal() { # Check the data declares $PREBUFFER or $BUFFER. [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! On ${(qq)ARG}: Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return ${RETURN:=1}; } + [[ $PREBUFFER == (''|*$'\n') ]] || { echo >&2 "Bail out! On ${(qq)ARG}: PREBUFFER=${(qqqq)PREBUFFER} doesn't end with a newline"; return ${RETURN:=1}; } # Set sane defaults for ZLE variables : ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget}