#!/bin/sh

necho() {
   if [ "`echo -n`" = "-n" ]; then
      echo "${@}\c"
   else
      echo -n "${@}"
   fi
}

echo "Testing the SWIG C/C++ parser..."

# Make some of the larger files
perl makelarge.pl >large_comment.i
perl makeheader.pl >large_header.i

IFILE='
addmethods array code conditional constant cpp_const cpp_data cpp_func
cpp_inherit cpp_misc defarg doc enum_cond except extern function graph inline
library macro modlist multiline multinherit native nested new objc opengl ref
reference rename struct template test0.1a typedef typemap unsigned value
variable vector_ex void zero
large_comment
large_header'

LOGFILE='../../test.log'

rm -f ${LOGFILE}

echo "\nPerforming parser/regression tests on Python module..."
for i in ${IFILE}; do 
necho "    Testing (Python) : ${i}.i"; 
if ../../swig -I../../swig_lib -python -dnone -c++ -objc ${i}.i >${i}.python.output 2>&1; then 
# Look for a regression testing file
    if test -f ${i}_regr.python.c; then
         if diff ${i}_regr.python.c ${i}_wrap.c > ${i}.python.diff; then
             echo " ....... passed"
             rm -f ${i}.python.diff
         else
              echo " ....... FAILED COMPARE (see ${i}.python.diff) ***";
              echo "${i}.i (Python) ....... FAILED COMPARE (see ${i}.python.diff) ***" >> ${LOGFILE}
         fi;
    else
# Regression testing file doesn't exist, create it
         echo " ....... passed (creating ${i}_regr.python.c)"
         mv ${i}_wrap.c ${i}_regr.python.c
    fi;
rm -f ${i}_wrap*
else 
    echo " ....... FAILED (INTERNAL ERROR) ***";
    echo "${i}.i (Python) ....... FAILED (INTERNAL ERROR) ***" >> ${LOGFILE}
fi;
done


echo "\nPerforming parser/regression tests on Python shadow classes..."
for i in ${IFILE}; do 
necho "    Testing (Python shadow) : ${i}.i"; 
if ../../swig -I../../swig_lib -python -shadow -dnone -c++ -objc ${i}.i >${i}.pythons.output 2>&1; then 
# Look for a regression testing file
    if test -f ${i}_regr.pythons.c; then
         if diff ${i}_regr.pythons.c ${i}_wrap.c > ${i}.pythons.diff; then
             echo " ....... passed"
             rm -f ${i}.pythons.diff
         else
              echo " ....... FAILED COMPARE (see ${i}.pythons.diff) ***";
              echo "${i}.i (Python shadow) ....... FAILED COMPARE (see ${i}.pythons.diff) ***" >> ${LOGFILE}
         fi;
    else
# Regression testing file doesn't exist, create it
         echo " ....... passed (creating ${i}_regr.pythons.c)"
         mv ${i}_wrap.c ${i}_regr.pythons.c
    fi;

rm -f ${i}_wrap*
else 
    echo " ....... FAILED (INTERNAL ERROR) ***";
    echo "${i}.i (Python shadow) ....... FAILED (INTERNAL ERROR) ***" >> ${LOGFILE}
fi;
done





syntax highlighted by Code2HTML, v. 0.9.1