Allow skipping test cases

This defines a skip() function in the tests preamble which can
be used to skip tests. Skipped tests are counted, and a reason
for them being skipped printed after running the tests.
pull/93/head
Adrian Perez de Castro 2018-07-03 02:01:06 +03:00 committed by Adrian Perez
parent 501f9bc63c
commit 60f09e450d
2 changed files with 29 additions and 4 deletions

View File

@ -72,13 +72,19 @@ function fetch () {
wget "${opts[@]}" -O- "http://localhost:8888${1:-/}" 2>&1
}
function skip () {
printf '(--) '
printf "$@"
exit 111
} 1>&2
function fail () {
printf "(FF) "
printf '(FF) '
printf "$@"
exit 1
} 1>&2
function warn () {
printf "(WW)"
printf '(WW) '
printf "$@"
} 1>&2

23
t/run
View File

@ -25,6 +25,7 @@ readonly dynamic
declare -a t_pass=( )
declare -a t_fail=( )
declare -a t_skip=( )
for t in `ls "$T"/*.test | sort -R` ; do
name="t/${t##*/}"
@ -43,6 +44,9 @@ for t in `ls "$T"/*.test | sort -R` ; do
if bash -e "${shfile}" > "${outfile}" 2> "${errfile}" ; then
t_pass+=( "${name}" )
printf 'passed\n'
elif [[ $? -eq 111 ]] ; then
t_skip+=( "${name}" )
printf 'skipped\n'
else
t_fail+=( "${name}" )
printf 'failed\n'
@ -59,8 +63,23 @@ for name in "${t_fail[@]}" ; do
echo
done
printf '=== passed/failed/total: %d/%d/%d\n' \
${#t_pass[@]} ${#t_fail[@]} $(( ${#t_pass[@]} + ${#t_fail[@]} ))
if [[ ${#t_skip[@]} -gt 0 ]] ; then
echo
printf 'Skipped tests:\n'
for name in "${t_skip[@]}" ; do
reason=$(grep '^(\-\-) ' "${name}.err" | head -1)
if [[ -z ${reason} ]] ; then
reason='No reason given'
else
reason=${reason:5}
fi
printf ' - %s: %s\n' "${name}" "${reason:-No reason given}"
done
echo
fi
printf '=== passed/skipped/failed/total: %d/%d/%d/%d\n' \
${#t_pass[@]} ${#t_skip[@]} ${#t_fail[@]} $(( ${#t_pass[@]} + ${#t_fail[@]} ))
if [[ ${#t_fail[@]} -gt 0 ]] ; then
exit 1