[go: up one dir, main page]

Menu

[b00c83]: / test3  Maximize  Restore  History

Download this file

176 lines (160 with data), 4.5 kB

#!/bin/bash
# Tests for Ezhil language in Python 3
# (C) 2007, 2008, 2013-2015 முத்தையா அண்ணாமலை
MODEZHIL=`pwd`
if [ -e success3.txt ];
then
    rm success3.txt
fi
if [ -e failed3.txt ];
then
    rm failed3.txt
fi
if [ -e dump_file3 ];
then
    rm dump_file3
fi

touch success3.txt
touch failed3.txt
touch dump_file3

export EZHIL_DATA_PATH=`pwd`/tests/data
export EZHIL_TEST_PATH=`pwd`/tests/
# run tests for Ezhil as well
cd ./tests
# last space important before the \
for i in `cat ../test_cases | sort`
do
    echo "########## Testing Ezhil script $i" | tee -a ../dump_file3    
    PYTHONPATH=$MODEZHIL python3 -m ezhil  $i 2>&1 >> ../dump_file3
    if [ $? -eq 0 ];
    then
       echo $i >> ../success3.txt
    else
       echo $i >> ../failed3.txt
    fi;
    sleep 0
done
unset EZHIL_DATA_PATH

echo "**********Special TSCII Test**********"
    PYTHONPATH=$MODEZHIL python3 -m ezhil  -tamilencoding tscii  tscii_calc2.n |  tee -a ../dump_file3
	if [ $? -eq 0 ];
	then
	    echo "tscii_calc2.n" >> ../success3.txt
	else
	    echo "tscii_calc2.n" >> ../failed3.txt
	fi
echo "********************************************"

if [ -e names.txt ];
then
    rm names.txt
fi

cd ../

echo "**************************************************"
echo " Running Web tests" | tee -a dump_file3
echo "**************************************************"
# this test needs Ezhil to be installed via pip
python3 ./web/ezhil_web.py 2>&1 >> dump_file3
if [ $? -eq 0 ]
then
    echo "ezhil_web.py" >> success3.txt
else
    echo "ezhil_web.py" >> failed3.txt
fi

echo "**************************************************"
echo " Running API tests"
echo "**************************************************"

cd web/ulle_veliye/
pip3 install -r requirements.txt
python3 manage.py test

cd -
echo "**************************************************"
echo " Running interactive tests " | tee -a dump_file3
echo "***************************************************"
for i in `echo demos/ch2.n \
`
do
    echo "ezhil" | PYTHONPATH=$MODEZHIL python3 -m ezhil ./tests/$i  >>  dump_file3
    if [ $? -eq 0 ]
    then
	echo "passed ezhil interactive test for  $i" >> success3.txt
    else
	echo "failed ezhil interactive test for $i" >> failed3.txt
    fi
done

echo "**************************************************"
echo " Running all the failure programs, that must fail."
echo "**************************************************"
for i in `ls ./tests/*.fprog ./tests/typecheck/semantic_error*.n`;
do
    echo "Testing file $i" | tee -a dump_file3
    PYTHONPATH=$MODEZHIL python3 -m ezhil $i $1 -stacksize 10 2>&1 >> dump_file3
    if [ $? -eq 0 ]
    then
	echo $i >> failed3.txt
    else
	echo $i >> success3.txt
    fi
    sleep 0
done

echo "**********Successful Tests**********" 
cat success3.txt
echo "*************************************"
echo "***********Failed Tests**************" 
cat failed3.txt

echo "***********Summary******************"
echo "Passed = "`wc -l success3.txt`", Failed = "`wc -l failed3.txt`

# number of failures is always limited, and when you add
# failed tests you have to bump this up.

# Known $NFAIL failures
#    1	badlex.n
#    2	bitwiseops.n
#    3	boolean_demorgan.n
#    4	boolean_fcns.n
#    5	boolean.n
#    6	boolf.n
#    7	chaos.n
#    8	dict.n
#    9	dict_ta.n
#   10	eval1.n
#   11	ezhil_web.py
#   12	fact.n
#   13	full_adder.n
#   14	gcd.n
#   15	half_adder.n
#   16	isbalanced.n
#   17	logical_not.n
#   18	math_geomprogression.n
#   19	math_goldenratio.n
#   20	morse.n
#   21	nonexistent_file.n
#   22	predicates.n
#   23	py1.n
#   24	solo_return.n
#   25	staircase_light.n
#   26	strings.n
#   27	tamil2.n
#   28	tamil_months.n
#   29	temple.n
#   30	unaryop.n
#   31	yinyang.n
NFAIL=26 #11/28/15
TOTFAIL=`wc -l failed3.txt | cut -d'f' -f1`
echo "from sys import exit; ( $TOTFAIL <=  $NFAIL ) and exit(0) or exit(255)" | python
if [ $?  -eq 0 ]
then
   echo "########## Expected failures" | tee -a dump_file3
   exitcode=0 # success
else
   echo "Expecting $NFAIL failures, but found $TOTFAIL failures" | tee -a dump_file3
   echo "Too few/many failures; some negative tests may have failed" | tee -a dump_file3
   echo "" | tee -a dump_file3
   echo "######### LIST OF FAILED FILES ##############" | tee -a dump_file3
   cat failed3.txt | tee -a dump_file3
   echo " " | tee -a dump_file3
   exitcode=255 #failed failures != $NFAIL
   exit $exitcode
fi

# cleanup
rm failed3.txt
rm success3.txt
exit $exitcode