Admin/isatest-check
author wenzelm
Tue Jul 05 16:49:15 2005 +0200 (2005-07-05)
changeset 16693 75f39d66425d
parent 16559 2916415680b9
child 17847 5d5cada76409
permissions -rwxr-xr-x
fixed regexp grouping;
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 # Author: Gerwin Klein, TU Muenchen
     5 #
     6 # DESCRIPTION: sends email for failed tests, checks for error.log,
     7 #              generates development snapshot if test ok
     8 
     9 ## global settings
    10 . ~/admin/isatest-settings
    11 
    12 # produce empty list for patterns like isatest-*.log if no 
    13 # such file exists 
    14 shopt -s nullglob
    15 
    16 # mail program
    17 MAIL=$HOME/bin/pmail
    18 
    19 # tmp file for sending mail
    20 TMP=/tmp/isatest-makedist.$$
    21 
    22 export DISTPREFIX
    23 
    24 
    25 ## diagnostics
    26 
    27 PRG="$(basename "$0")"
    28 
    29 function usage()
    30 {
    31   echo
    32   echo "Usage: $PRG"
    33   echo
    34   echo "   sends email for failed tests, checks for error.log,"
    35   echo "   generates development snapshot if test ok."
    36   echo "   To be called by cron."
    37   echo
    38   exit 1
    39 }
    40 
    41 function fail()
    42 {
    43   echo "$1" >&2
    44   exit 2
    45 }
    46 
    47 ## main
    48 
    49 # check if tests are still running, wait for them to finish for max 5h
    50 i=0
    51 while [ -n "$(ls $RUNNING)" -a $i -lt 5 ]; do 
    52     sleep 3600
    53     let "i = i+1"
    54 done
    55 
    56 # still running -> give up
    57 if [ -n "$(ls $RUNNING)" ]; then
    58     echo "Giving up waiting for test to finish at $(date)." > $TMP
    59     echo "Attaching all error logs collected so far." >> $TMP
    60     echo >> $TMP
    61 
    62     if [ -e $ERRORLOG ]; then
    63         cat $ERRORLOG >> $TMP
    64     fi
    65 
    66     echo "Have a nice day," >> $TMP
    67     echo "  isatest" >> $TMP
    68 
    69     for R in $MAILTO; do
    70         LOGS=$ERRORDIR/isatest*.log
    71         $MAIL "isabelle test taking too long" $R $TMP $LOGS
    72     done
    73     
    74     exit 1
    75 fi
    76 
    77 # no tests running, check if there were errors
    78 if [ -e $ERRORLOG ]; then
    79     cat $ERRORLOG > $TMP
    80     echo "Have a nice day," >> $TMP
    81     echo "  isatest" >> $TMP
    82 
    83     for R in $MAILTO; do
    84         LOGS=$ERRORDIR/isatest*.log
    85         $MAIL "isabelle test failed" $R $TMP $LOGS
    86     done
    87 
    88     rm $TMP
    89     exit 1
    90 fi
    91 
    92 # generate development snapshot page only for successful tests
    93 (cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
    94 echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
    95 
    96 exit 0
    97 ## end