'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.
This commit is contained in:
Daniel Shahaf 2015-10-27 11:55:36 +02:00
parent 4513eaea71
commit 6fe07c0961
3 changed files with 4 additions and 3 deletions

View File

@ -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:

0
tests/tap-colorizer.zsh Normal file → Executable file
View File

View File

@ -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