forked from Ezhil-Language-Foundation/Ezhil-Lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunittest
executable file
·62 lines (52 loc) · 1.23 KB
/
unittest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# run unit tests when previous bits passed
cd tests/unit/
# use python3 for testing if passed an arg
PYTHON=python3
#echo "Using Interpreter $PYTHON"
if [ -e success.txt ];
then
rm success.txt
fi
if [ -e failed.txt ];
then
rm failed.txt
fi
touch success.txt
touch failed.txt
for i in `ls *.py`
do
echo Running test $i
$PYTHON $i
if [ $? -eq 0 ]
then
echo $i >> success.txt
else
echo $i >> failed.txt
fi
done
echo ""
echo "***********Summary of UnitTests******************"
echo "Passed = "`wc -l success.txt`", Failed = "`wc -l failed.txt`
echo "*************************************************"
NFAIL=0 #ideally no unittests should fail
TOTFAIL=`wc -l failed.txt | cut -d'f' -f1`
echo "from sys import exit; exit( $TOTFAIL != $NFAIL )" | python
if [ $? -eq 0 ]
then
echo "Testing Successful!"
exitcode=0 # success
# cleanup only on success
rm failed.txt
rm success.txt
else
echo "Expecting $NFAIL failures, but found $TOTFAIL failures"
echo ""
echo "######### LIST OF FAILED FILES ###########"
cat failed.txt
echo " "
echo "Too few/many failures; some negative tests may have failed"
exitcode=255 #failed failures != $NFAIL
fi
cd ../../
exit $exitcode