function failed() {
  echo "*** FAILED $1";
  failed="$failed $1";
}

function compile_test() {
  base=$1
  f=test/$base.res
  o=test/$base.out
  if [ -e $f ] 
  then
    gcc a.out.c
    ./a.out > $o
    diff -u $f $o
  else
    gcc -fsyntax-only a.out.c
  fi
}

if [ "$#" -gt 0 ]; then
    tests="$@"
else
    tests=`cat test/basic_tests.txt`;
fi

for f in $tests
do 
    base=`basename $f .c`
    echo $f 1>&2
    ( ./zl test/$f > test/$base.log && compile_test $base ) \
    || failed $f
done

if [ -n "$failed" ]; then 
    echo FAILED TESTS: $failed
else
    echo ALL TEST PASSED
fi


function failed() {
  echo "*** FAILED $1";
  failed="$failed $1";
}

function compile_test() {
  base=$1
  f=test/$base.res
  o=test/$base.out
  if [ -e $f ] 
  then
    gcc a.out.c
    ./a.out > $o
    diff -u $f $o
  else
    gcc -fsyntax-only a.out.c
  fi
}

if [ "$#" -gt 0 ]; then
    tests="$@"
else
    tests=`cat test/basic_tests.txt`;
fi

LOG_CMD="| tee"

for f in $tests
do 
    base=`basename $f .c`
    echo $f 1>&2
    ( ./zl test/$f $LOG_CMD test/$base.log && compile_test $base ) \
    || failed $f
done

if [ -n "$failed" ]; then 
    echo FAILED TESTS: $failed
else
    echo ALL TEST PASSED
fi


Add ability to display output to stdout as well as capture it.
Add ability to display output to stdout as well as capture it.

svn-id: 00ff020da1e0a0c4c4e17a784c0ef3be7a7fbac0@131
