-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_lexer.sh
executable file
·58 lines (47 loc) · 1.34 KB
/
test_lexer.sh
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
#!/bin/bash
echo "========================================"
echo " Testing lexer"
echo "========================================"
if which dos2unix ; then
DOS2UNIX="dos2unix"
elif which fromdos ; then
DOS2UNIX="fromdos"
else
>&2 echo "warning: dos2unix is not installed."
DOS2UNIX="tr -d \r"
fi
echo "========================================"
echo " Cleaning the temporaries and outputs"
#Go up level to read makefile
cd ../
make clean
echo " Force building lexer"
make lexertest -B
if [[ "$?" -ne 0 ]]; then
echo "Build failed.";
fi
echo ""
#Go down to test directory
cd test_lexer
mkdir -p test_lexer/out
echo "========================================="
PASSED=0
CHECKED=0
#for i in test_lexer/in/*.txt; do - TODO fix the parser
i = "test_lexer/in/01-expr.txt";
echo "==========================="
echo ""
echo "Input file : ${i}"
BASENAME=$(basename $i .txt);
cat $i | ${DOS2UNIX} | ./bin/lexer > test_lexer/out/$BASENAME.stdout.txt 2> test_lexer/out/$BASENAME.stderr.txt
diff <(cat test_lexer/ref/$BASENAME.stdout.txt | ${DOS2UNIX}) <(cat test_lexer/out/$BASENAME.stdout.txt) > test_lexer/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 ""