-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.sh
58 lines (50 loc) · 1.49 KB
/
tester.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/sh
numTests=17 # UPDATE THIS TO THE NUMBER OF TESTS
sucesses=0
getInput() {
echo "Enter which test case you would like to run, or \"ALL\" to run all tests: "
read -r num
}
runTest() {
echo "Running test case $1"
# java -cp ../../.. com.craftinginterpreters.lox.Lox < tester/tests/test"$1".lox > tester/tests/test"$1".out # if in tester directory
java -cp ./tester/build/java com.craftinginterpreters.lox.Lox tester/tests/test"$1".lox > tester/tests/test"$1".out
# ./tester/kamincpp < tester/tests/test"$1".lisp > tester/tests/test"$1".out
# python3 src/project1.py < tester/tests/test"$1".lisp > tester/tests/test"$1".ans
mono ./bin/Debug/LoxInterpreter.exe tester/tests/test"$1".lox > tester/tests/test"$1".ans
matchedLines=$(diff -w -y --suppress-common-lines "tester/tests/test$1.ans" "tester/tests/test$1.out" | wc -l | tr -d '[:space:]')
if [ "$matchedLines" -eq "0" ]; then
echo "Test case $1 passed"
sucesses=$((sucesses+1))
else
echo "Test case $1 failed"
fi
}
test() {
if [ "$1" = "ALL" ]; then
for i in $(seq 1 $numTests); do
runTest "$i"
done
else
runTest "$1"
numTests=1
fi
echo "Number of tests passed: $sucesses/$numTests"
}
makeLox() {
msbuild LoxInterpreter.csproj
}
makeJLox() {
cd tester || return
make jlox
cd ..
}
cleanTests() {
rm -rf tester/tests/*.out
rm -rf tester/tests/*.ans
}
cleanTests
getInput
makeLox
makeJLox
test "$num"