-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest2.sh
More file actions
57 lines (48 loc) · 1.87 KB
/
Copy pathtest2.sh
File metadata and controls
57 lines (48 loc) · 1.87 KB
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
#!/bin/bash
# --------------------------------------
# Setup CLASSPATH
# --------------------------------------
export CLASSPATH=$CLASSPATH:$(pwd)
export CLASSPATH=$CLASSPATH:$(pwd)/.solution/
export CLASSPATH=$CLASSPATH:$(pwd)/bin/
export CLASSPATH=$CLASSPATH:$(pwd)/lib/*
# --------------------------------------
# Build once
# --------------------------------------
echo "Building lexer..."
rm -rf bin
rm -rf Parse/antlr_build
# Generate lexer code
java -jar ./lib/antlr-4.13.2-complete.jar Parse/gLexer.g4 -o ./Parse/antlr_build
# Compile all Java sources
find . -name "*.java" > sources.txt
javac -d bin @sources.txt
rm sources.txt
echo "Build complete."
# --------------------------------------
# Run all tests
# --------------------------------------
echo "Running tests..."
testfiles=($(find ./tests/ -type f))
# Clean report
echo "################################################################################" > report.txt
for testfile in "${testfiles[@]}"; do
echo "################################################################################" >> report.txt
cat "$testfile" >> report.txt
echo -e "\n" >> report.txt
echo "$testfile" >> report.txt
java Parse.LexerDriver "$testfile" >> report.txt 2>&1
done
# Optional: run solution if you want to compare
echo "Running solution..."
echo "################################################################################" > solution_report.txt
for testfile in "${testfiles[@]}"; do
echo "################################################################################" >> solution_report.txt
cat "$testfile" >> solution_report.txt
echo -e "\n" >> solution_report.txt
echo "$testfile" >> solution_report.txt
./run_solution.sh "$testfile" >> solution_report.txt 2>&1
done
# Compare
diff -u report.txt solution_report.txt >> final_report.txt
echo "Tests complete. Check report.txt and final_report.txt."