test: allow tests to be skipped

This commit is contained in:
Miroslav Lichvar 2014-08-14 17:58:59 +02:00
parent 474b2af1a6
commit f8af299321
2 changed files with 14 additions and 3 deletions

View file

@ -2,19 +2,25 @@
. test.common . test.common
passed=() failed=() passed=() failed=() skipped=()
[ $# -gt 0 ] && tests=($@) || tests=([0-9]*-*[^_]) [ $# -gt 0 ] && tests=($@) || tests=([0-9]*-*[^_])
for test in "${tests[@]}"; do for test in "${tests[@]}"; do
echo "$test ($[${#passed[@]} + ${#failed[@]} + 1]/${#tests[@]})" echo "$test ($[${#passed[@]} + ${#failed[@]} + 1]/${#tests[@]})"
./$test && passed=(${passed[@]} $test) || failed=(${failed[@]} $test) ./$test
case $? in
0) passed=(${passed[@]} $test);;
9) skipped=(${skipped[@]} $test);;
*) failed=(${failed[@]} $test);;
esac
echo echo
done done
echo "SUMMARY:" echo "SUMMARY:"
echo " TOTAL $[${#passed[@]} + ${#failed[@]}]" echo " TOTAL $[${#passed[@]} + ${#failed[@]} + ${#skipped[@]}]"
echo " PASSED ${#passed[@]}" echo " PASSED ${#passed[@]}"
echo " FAILED ${#failed[@]} (${failed[@]})" echo " FAILED ${#failed[@]} (${failed[@]})"
echo " SKIPPED ${#skipped[@]} (${skipped[@]})"
[ ${#failed} -eq 0 ] [ ${#failed} -eq 0 ]

View file

@ -101,6 +101,11 @@ test_fail() {
exit 1 exit 1
} }
test_skip() {
echo "SKIP"
exit 9
}
test_ok() { test_ok() {
pad_line pad_line
echo -e "\tOK" echo -e "\tOK"