X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=test%2Faggregate-results.sh;h=6845fcf0b2ae06b55e8a94e926c1f30484e3f14d;hp=d5bab75d7da49ebb53e368d67f6b867f5417a125;hb=a06b76b9b3c1212b17d2bb170bdd511711f578f8;hpb=0083854b1204f077e98b1d9c4ecfa2a4844ee716 diff --git a/test/aggregate-results.sh b/test/aggregate-results.sh index d5bab75d..6845fcf0 100755 --- a/test/aggregate-results.sh +++ b/test/aggregate-results.sh @@ -1,34 +1,99 @@ -#!/bin/sh +#!/usr/bin/env bash + +set -eu fixed=0 success=0 failed=0 broken=0 total=0 +all_skipped=0 +rep_failed=0 for file do + if [ ! -f "$file" ]; then + echo "'$file' does not exist!" + rep_failed=$((rep_failed + 1)) + continue + fi + has_total=0 while read type value do case $type in - '') - continue ;; fixed) - fixed=$(($fixed + $value)) ;; + fixed=$((fixed + value)) ;; success) - success=$(($success + $value)) ;; + success=$((success + value)) ;; failed) - failed=$(($failed + $value)) ;; + failed=$((failed + value)) ;; broken) - broken=$(($broken + $value)) ;; + broken=$((broken + value)) ;; total) - total=$(($total + $value)) ;; + total=$((total + value)) + has_total=1 + if [ "$value" -eq 0 ]; then + all_skipped=$((all_skipped + 1)) + fi esac done <"$file" + if [ "$has_total" -eq 0 ]; then + echo "'$file' lacks 'total ...'; results may be inconsistent." + failed=$((failed + 1)) + fi done -printf "%-8s%d\n" fixed $fixed -printf "%-8s%d\n" success $success -printf "%-8s%d\n" failed $failed -printf "%-8s%d\n" broken $broken -printf "%-8s%d\n" total $total +pluralize_s () { [ "$1" -eq 1 ] && s='' || s='s'; } + +echo "Notmuch test suite complete." + +if [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ] && [ "$rep_failed" -eq 0 ]; then + pluralize_s "$total" + printf "All $total test$s " + if [ "$broken" -eq 0 ]; then + echo "passed." + else + pluralize_s "$broken" + echo "behaved as expected ($broken expected failure$s)." + fi +else + echo "$success/$total tests passed." + if [ "$broken" -ne 0 ]; then + pluralize_s "$broken" + echo "$broken broken test$s failed as expected." + fi + if [ "$fixed" -ne 0 ]; then + pluralize_s "$fixed" + echo "$fixed broken test$s now fixed." + fi + if [ "$failed" -ne 0 ]; then + pluralize_s "$failed" + echo "$failed test$s failed." + fi +fi + +skipped=$((total - fixed - success - failed - broken)) +if [ "$skipped" -ne 0 ]; then + pluralize_s "$skipped" + echo "$skipped test$s skipped." +fi +if [ "$all_skipped" -ne 0 ]; then + pluralize_s "$all_skipped" + echo "All tests in $all_skipped file$s skipped." +fi + +if [ "$rep_failed" -ne 0 ]; then + pluralize_s "$rep_failed" + echo "$rep_failed test$s failed to report results." +fi + +# Note that we currently do not consider skipped tests as failing the +# build. + +if [ "$success" -gt 0 ] && [ "$fixed" -eq 0 ] && + [ "$failed" -eq 0 ] && [ "$rep_failed" -eq 0 ] +then + exit 0 +else + exit 1 +fi