Admin/isatest-check
author wenzelm
Thu Jan 19 21:22:08 2006 +0100 (2006-01-19 ago)
changeset 18708 4b3dadb4fe33
parent 18329 221d47d17a81
child 21038 c7b041a6bbfe
permissions -rwxr-xr-x
setup: theory -> theory;
     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 a couple of hours
    50 i=0
    51 while [ -n "$(ls $RUNNING)" -a $i -lt 8 ]; 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 >> $TMP
    60     echo "Sessions still running:" >> $TMP
    61     echo "$(ls $RUNNING)" >> $TMP
    62     echo >> $TMP
    63     echo "Attaching all error logs collected so far." >> $TMP
    64     echo >> $TMP
    65 
    66     if [ -e $ERRORLOG ]; then
    67         cat $ERRORLOG >> $TMP
    68     fi
    69 
    70     echo "Have a nice day," >> $TMP
    71     echo "  isatest" >> $TMP
    72 
    73     for R in $MAILTO; do
    74         LOGS=$ERRORDIR/isatest*.log
    75         $MAIL "isabelle test taking too long" $R $TMP $LOGS
    76     done
    77     
    78     exit 1
    79 fi
    80 
    81 # no tests running, check if there were errors
    82 if [ -e $ERRORLOG ]; then
    83     cat $ERRORLOG > $TMP
    84     echo "Have a nice day," >> $TMP
    85     echo "  isatest" >> $TMP
    86 
    87     for R in $MAILTO; do
    88         LOGS=$ERRORDIR/isatest*.log
    89         $MAIL "isabelle test failed" $R $TMP $LOGS
    90     done
    91 
    92     rm $TMP
    93     exit 1
    94 fi
    95 
    96 # generate development snapshot page only for successful tests
    97 (cd $HOME/devel-page; env DISTNAME=`$DISTPREFIX/Isabelle/bin/isatool version` make)
    98 echo "$(date) $HOSTNAME $PRG: generated development snapshot web page." >> $MASTERLOG
    99 
   100 exit 0
   101 ## end