From 6fe07c096109d5f3832e83ad0b6ec8241fd2e967 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 27 Oct 2015 11:55:36 +0200 Subject: [PATCH] 'make test': Fix breakage introduced by 4d3da30f8b726c6e0eeb3adda06adc9eaa329b3b: test failure would not be reflected by the exit code of 'make'. Setting a shell parameter in the left-hand side of a pipe is not visible to commands after the pipe, because the left-hand side forks. (That's true both in 'sh' used by 'make' and in 'zsh' that runs tests/test-highlighting.zsh, at least on my system.) Therefore, move the colorizing hook to where it doesn't interfere with setting the $something_failed (in tests/test-highlighting.zsh) and $result (in Makefile) parameters. --- Makefile | 2 +- tests/tap-colorizer.zsh | 0 tests/test-highlighting.zsh | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) mode change 100644 => 100755 tests/tap-colorizer.zsh diff --git a/Makefile b/Makefile index cc4e57b..e4fa163 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ test: $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \ : $$(( result |= $$? )); \ fi \ - done | $(ZSH) -f tests/tap-colorizer.zsh; \ + done; \ exit $$result perf: diff --git a/tests/tap-colorizer.zsh b/tests/tap-colorizer.zsh old mode 100644 new mode 100755 diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index a67229a..1eed974 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -59,6 +59,8 @@ run_test() { local -a highlight_zone local unused_highlight='bg=red,underline' # a style unused by anything else, for tests to use + echo "# ${1:t:r}" + # Load the data and prepare checking it. PREBUFFER= BUFFER= ; . "$1" @@ -109,8 +111,7 @@ run_test() { # Process each test data file in test data directory. integer something_failed=0 for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do - echo "# ${data_file:t:r}" - (run_test "$data_file") | tee >(cat) | grep -v '^not ok.*# TODO' | grep -q '^not ok\|^ok.*# TODO' && (( something_failed=1 )) + (run_test "$data_file") | tee >(${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -q '^not ok\|^ok.*# TODO' && (( something_failed=1 )) (( $pipestatus[1] )) && exit 2 done