#!/bin/bash
DIRECTORY='/home/seb/zope/Products'
export USER=seb
rm -f $DIRECTORY/../unit_test/tests/zLOG.log
rm -f $DIRECTORY/test_output
touch $DIRECTORY/test_output
rm -f $DIRECTORY/test_full_output
touch $DIRECTORY/test_full_output
$DIRECTORY/update_cvs

if [ -d ${DIRECTORY}/ERP5/.svn ]
then
  svn info ${DIRECTORY}/ERP5 | grep -e '^R.vision[ \t]*:' \
      >> ${DIRECTORY}/test_output
fi

# Excluded tests must be separated by whitespaces
excluded_test_list="testCatalogSecurity"

test_list=`/bin/ls -1 $DIRECTORY/*/tests/test*.py`

for test in $test_list
do
  skip_test=0
  test_name=`basename $test .py`
  for excluded_test_name in $excluded_test_list
  do
    [ $test_name = $excluded_test_name ] && skip_test=1 && break
  done
  [ $skip_test -eq 1 ] && continue
  $DIRECTORY/ERP5Type/tests/runUnitTest.py $test_name \
      >> $DIRECTORY/test_full_output 2>&1
done

cat $DIRECTORY/test_full_output | grep '\(^OK\|^FAILED\|^Ran\)' | \
    sed "/^FAILED.*\|^OK.*/s/.*/\0\n/g" >> $DIRECTORY/test_output

$DIRECTORY/sendMailToList
