aboutsummaryrefslogtreecommitdiffstats
path: root/test_parser.sh
blob: cddc4911ef33ac8260236ffb8ff6bccc251723e1 (plain)
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
#!/bin/bash

# script to test the lexer

echo "========================================"
echo " Cleaning the temporaries and outputs"
make clean
echo " Force building lexer"
make -B bin/c_parser

if [[ "$?" -ne 0 ]]; then
    	echo "Build failed.";
fi

echo ""
echo ""
echo "========================================="
echo " Testing parser"

PASSED=0
CHECKED=0

for i in c_parser/test/in/*.c; do
	echo "==========================="
    	echo ""
    	echo "Input file : ${i}"
	BASENAME=$(basename $i .c);
    	cat $i | ./bin/c_parser > c_parser/test/out/$BASENAME.stdout.xml  2> c_parser/test/out/$BASENAME.stderr.txt
	tidy -xml -i -q -o c_parser/test/out/$BASENAME.pretty.xml c_parser/test/out/$BASENAME.stdout.xml

    	diff <(cat c_parser/test/ref/$BASENAME.stdout.xml | tidy -xml -i -q) <(cat c_parser/test/out/$BASENAME.stdout.xml | tidy -xml -i -q) > c_parser/test/out/$BASENAME.diff.txt
    	if [[ "$?" -ne "0" ]]; then
        	echo -e "\nERROR"
    	else
       		PASSED=$(( ${PASSED}+1 ));
    	fi
    	CHECKED=$(( ${CHECKED}+1 ));
done

echo "########################################"
echo "Passed ${PASSED} out of ${CHECKED}".
echo ""