summaryrefslogtreecommitdiff
path: root/math/qrupdate/patches/patch-test_report__results
blob: cffde256c3c8be381065ed2b16005664e992f3ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$NetBSD: patch-test_report__results,v 1.1 2021/05/29 09:55:14 thor Exp $

Drop awk usage and make the test script actually count and evaluate errors
itself so that the test target has a meaningful result as return value.

--- test/report_results.orig	2010-02-11 10:45:19.000000000 +0000
+++ test/report_results
@@ -1,22 +1,30 @@
 #!/bin/sh
 OUTS=$*
 passed_total=0
 failed_total=0
 cat $OUTS
 
-# if awk exists, use it to print total statistics
-if which awk > /dev/null ; then
-	awk '/total:/ { passed += $3; failed += $5; }
-	END { printf " TOTAL:     PASSED %3d     FAILED %3d\n", passed, failed; }' $OUTS
-fi
+ret=0
 for out in $OUTS ; do
 	if [ ! -s $out ] ; then
 		echo " $out file empty (test crashed)!"
+		ret=1
 	else
 		if grep -q WARNING $out ; then
 			echo " $out produced warnings:"
 			grep WARNING $out
+			ret=1
+		fi
+		passed=$(grep total: $out | (read a b num d; echo $num))
+		passed_total=$((passed_total+passed))
+		failed=$(grep total: $out | (read a b c d num f; echo $num))
+		failed_total=$((failed_total+failed))
+		if test "$failed" -gt 0; then
+			echo " $out has failures"
+			ret=1
 		fi
 	fi
 done
+printf "\n TOTAL:     PASSED %3d     FAILED %3d\n" "$passed_total" "$failed_total"
 
+exit $ret