-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_compile.sh
executable file
·64 lines (59 loc) · 1.71 KB
/
test_compile.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
59
60
61
62
63
64
#!/bin/bash
echo "Running test cases for codegen analysis..."
echo -e "----------------------------------------------\n"
test_dir="./test/"
count=1
correct=0
correct_run=0
wrong=()
wrong_run=()
for testfile in "$test_dir"*.tony
do
# get expected result and name
res=$(awk -v line=3 -v field=3 'NR==line{print $field}' "$testfile")
name=$(awk -v line=2 -v field=4 'NR==line{print $field}' "$testfile")
expectsInput=$(awk -v line=4 -v field=2 'NR==line{print $field}' "$testfile")
if [[ -n $expectsInput ]]; then
continue
fi
if [ $res = "Pass" ]; then
output=$(./tonyc $testfile 2>/dev/null)
outputerr=$(./tonyc $testfile 2>&1 > /dev/null)
if [[ -z $outputerr ]]; then
# program has beeen compiled succesfully
let correct+=1
# try to run it
name_noext=${name%.tony}
output_run=$(./test/${name_noext}.out 2>/dev/null)
outputerr_run=$(./test/${name_noext}.out 2>&1 > /dev/null)
if [[ -n $outputerr_run ]]; then
# if running it produces error then append to wrong2
echo $name
wrong_run+=(${name_noext})
else
let correct_run+=1
fi
echo "Test case ${count}: ${name} - Success"
else
wrong+=(${name})
echo "Test case ${count}: ${name} - Error"
fi
let count+=1
echo "*********************************"
fi
done
let count-=1
echo -e "----------------------------------------------\n"
echo "Correct: ${correct}/${count}"
echo -e "----------------------------------------------\n"
echo "Wrong:"
for value in "${wrong[@]}"
do
echo "$value"
done
echo -e "----------------------------------------------\n"
echo "Runtime errors: ${runtime_erros/${count}}"
for value in "${wrong_run[@]}"
do
echo "$value"
done