#!/bin/bash

## exclusion list for faust and C++ errors
XLIST1="faust2md faust2atomsnippets"
XLIST2="faust2md faust2atomsnippets faust2eps faust2firefox faust2graph faust2graphviewer faust2mathdoc faust2mathviewer faust2sig faust2sigviewer faust2svg faust2juce"

## test exclusion : notinlist "toto" "a b c d e" -> true
notinlist() {
  for word in $2; do
    if [ $word = $1 ]; then
        return 1
    fi
  done
  return 0
}

PATH=../../build/bin:$PATH
faust --version
echo location $(which faust)

######################################################
## Test all scripts for faust errors and c++ errors ##
######################################################
# All scripts must correctly detect and report faust 
# errors and C++ errors.
#
echo
echo "Check Faust errors are correctly detected/reported"
echo
for S in ../../tools/faust2appls/faust2*; do
    scriptname=`basename $S .in`
    if notinlist $scriptname "$XLIST1"; then
	    ($scriptname badfaust.dsp &> LOG)&&(echo "ERROR $scriptname shouldnt have succeeded !")||(echo "OK $scriptname correctly failed")
	fi
done

echo
echo "Check C++ errors are correctly detected/reported"
echo
for S in ../../tools/faust2appls/faust2*; do
    scriptname=`basename $S .in`
    if notinlist $scriptname "$XLIST2"; then
	    ($scriptname badcpp.dsp &> LOG)&&(echo "ERROR $scriptname shouldnt have succeeded !")||(echo "OK $scriptname correctly failed")
	fi
done


