#/bin/sh # -*- Mode: sh -*-
# File: $CVSROOT/Idea3/TestTools/report-errors-in-log
# Info: $CVSROOT/Idea3/Copyright.txt
#  CVS: $Id: report-errors-in-log,v 1.1 2005/06/21 21:53:06 rijsman Exp $

echo " "

if [ $# != 1 ];
then
  echo "usage: report-errors-in-log <log-file-name>"
  echo " "
  exit
fi

if [ ! -e $1 ];
then
  echo "log file ($1) not found."
  echo " "
  exit
fi

error_regexp="ERROR|WARNING|_err|execution_complete"

#log_name=`pwd | sed -e 's/\//\n/g' | tail -1`
error_log=`echo $1 | sed -e 's/.log//'`.error.log
egrep $error_regexp $1 > $error_log

errors_found=`wc $error_log | awk '{ print $1 }'`

if [[ $errors_found != "0" ]];
then
  if [[ $errors_found == "1" ]];
  then
    plural=""
  else
    plural="s"
  fi
  echo "writing error log to $error_log."
  echo "$errors_found error$plural/warning$plural found."
else
  echo "no well-known errors found."
  rm $error_log
fi

echo " "

#  EOF
