fate-recv: create summary and record last passed rev of tests
authorMans Rullgard <mans@mansr.com>
Fri, 30 Jul 2010 20:33:51 +0000 (21:33 +0100)
committerMans Rullgard <mans@mansr.com>
Fri, 30 Jul 2010 20:35:16 +0000 (21:35 +0100)
fate-recv.sh

index 8b9e57b..cdbf563 100755 (executable)
@@ -20,6 +20,7 @@ tar xzk
 header=$(head -n1 report)
 date=$(expr "$header" : 'fate:0:\([0-9]*\):')
 slot=$(expr "$header" : 'fate:0:[0-9]*:\([A-Za-z0-9_.-]*\):')
+rev=$(expr "$header" : "fate:0:$date:$slot:\([A-Za-z0-9_.-]*\):")
 
 test -n "$date" && test -n "$slot" || die "Invalid report header"
 
@@ -33,10 +34,49 @@ else
     echo "$FATE_USER" >"$slotdir/owner"
 fi
 
+exec <report
+head -n2 >summary
+
+ntest=0
+npass=0
+IFS=:
+
+exec >pass
+while read name status rest; do
+    if [ "$status" = 0 ]; then
+        echo "$name:$date:$rev"
+        npass=$(($npass+1))
+    fi
+    ntest=$(($ntest+1))
+done
+exec <&- >&-
+
+sort -o pass pass
+lastpass=$slotdir/lastpass
+
+if [ -r $lastpass ]; then
+    exec <$lastpass
+    while read pname pdate prev; do
+        while read lname ldate lrev; do
+            test "$lname" = "$pname" && break
+            echo "$lname:$ldate:$lrev"
+        done
+        echo "$pname:$pdate:$prev"
+    done <pass >lastpass
+    exec <&-
+else
+    mv pass lastpass
+fi
+
+unset IFS
+
+echo "stats:$ntest:$npass" >>summary
+
 repdir=$slotdir/$date
 mkdir $repdir
 gzip -9 *.log
 xz report
-cp -p report.xz *.log.gz $repdir
+cp -p summary report.xz *.log.gz $repdir
 rm -f $slotdir/latest
 ln -s $date $slotdir/latest
+cp lastpass ${lastpass}.new && mv ${lastpass}.new $lastpass