-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_programs.sh
43 lines (36 loc) · 995 Bytes
/
test_programs.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
#!/bin/bash
# Declare counter of total, correct and erroneous programs
totalCounter=0
errorCounter=0
correctCounter=0
# Iterate through each file in the directories given
for directory in "$@"
do
for file in "$directory"*.grc
do
if [ -f "$file" ]; then
((++totalCounter))
# Extracting the file name without the directory path
filename=$(basename "$file")
# Remove any previously created executable
if [ -f "./a.out" ]; then
rm ./a.out
fi
# Print a start message
echo "$filename:"
# Run the file
./grace "$file"
# If compilation was successful, run the executable
if [ -f "./a.out" ]; then
./a.out
(( $? == 0 ? ++correctCounter : ++errorCounter))
else
((++errorCounter))
fi
# Add a newline for better output separation
echo
fi
done
done
echo "Correct programs: $correctCounter/$totalCounter"
echo "Erroneous programs: $errorCounter/$totalCounter"