From f4d37b74ccc6c840ff11de41be28088846dd2ed5 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Mon, 6 Nov 2017 07:08:53 -0600 Subject: [PATCH] tests: Add ability to skip tests --- tests/README.md | 2 ++ tests/test-highlighting.zsh | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 11c35fc..78433c3 100644 --- a/tests/README.md +++ b/tests/README.md @@ -17,6 +17,8 @@ that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints. highlighting should be observed. If `$todo` exists, the test point is marked as TODO (the failure of that test point will not fail the test), and `$todo` is used as the explanation. +If a test sets `$skip_test` to a non-empty string, the test will be skipped +with the provided string as the reason. **Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but interprets the indexes differently. diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index 9731d8d..a7b98a5 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -97,10 +97,12 @@ run_test_internal() { echo "# ${1:t:r}" # Load the data and prepare checking it. - local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET + local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET skip_test local -a expected_region_highlight region_highlight . "$srcdir"/"$1" + (( $#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; } # Check the data declares $expected_region_highlight.