tests: Add a 'print failures only' mode to 'make test', called 'make quiet-test'.

Fixes zsh-users/zsh-syntax-highlighting#262.

Currently, 'make quiet-test' uses Perl.  However, since it is considered a development
tool rather than a user-facing tool, users and downstream packages needn't install Perl.
Furthermore, even this dev-only dependency may be dropped in the future.

The only difference between tests/tap-filter here and the one in the issue is using
a `cat` subshell v. using 'undef $/; <STDIN>'.
This commit is contained in:
Daniel Shahaf
2016-01-02 21:22:01 +00:00
parent 936e2e9314
commit 9b64ad750f
4 changed files with 65 additions and 1 deletions

View File

@@ -132,10 +132,23 @@ run_test() {
}
}
# Set up results_filter
local results_filter
if [[ $QUIET == y ]]; then
if type -w perl >/dev/null; then
results_filter=${0:A:h}/tap-filter
else
echo >&2 "Bail out! quiet mode not supported: perl not found"; exit 2
fi
else
results_filter=cat
fi
[[ -n $results_filter ]] || { echo >&2 "Bail out! BUG setting \$results_filter"; exit 2 }
# 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
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 ))
run_test "$data_file" | tee >($results_filter | ${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