1#!/bin/bash
2
3black='\E[30m'
4red='\E[31m'
5green='\E[32m'
6yellow='\E[33m'
7blue='\E[34m'
8magenta='\E[35m'
9cyan='\E[36m'
10white='\E[37m'
11
12if [ -f $2 ]; then
13  data=$2
14  if [ -f $1.summ ]; then rm $1.summ; fi
15  if [ -f $1.snap ]; then rm $1.snap; fi
16else
17  data=$1
18fi
19
20if ! ./$1 < $data > /dev/null 2> .runtest.log ; then
21  echo -e  $red Test $1 failed: $black
22  echo -e $blue
23  cat .runtest.log
24  echo -e $black
25  exit 1
26else
27  if [ -f $1.summ ]; then
28    if [ `grep "FATAL ERROR" $1.summ | wc -l` -gt 0 ]; then
29      echo -e  $red "Test $1 failed (FATAL ERROR, read the file $1.summ for details)" $black
30      echo -e $blue
31      cat .runtest.log
32      echo -e $black
33      exit 1;
34    fi
35
36    if [ `grep "FAILED THE TESTS OF ERROR-EXITS" $1.summ | wc -l` -gt 0 ]; then
37      echo -e  $red "Test $1 failed (FAILED THE TESTS OF ERROR-EXITS, read the file $1.summ for details)" $black
38      echo -e $blue
39      cat .runtest.log
40      echo -e $black
41      exit 1;
42    fi      
43  fi
44  echo -e $green Test $1 passed$black
45fi
46