-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathout.sh
46 lines (46 loc) · 1.15 KB
/
out.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
path=$(pwd)/test
cd $path
echo "Running tests in $path"
echo $(ls)
row_count=0
pass_count=0
fail_count=0
for entry in $(ls); do
if [[ $entry == *".cpp" ]]; then
echo "Compiling $entry into ${entry%.*}.out"
g++ $entry -o ${entry%.*}.out -Wfatal-errors -std=c++20
./${entry%.*}.out
rm -rf ${entry%.*}.out
if [ -f $path/test.txt ]; then
echo "-----------------------------------"
row_count=$((row_count+1))
echo "Querying $entry"
value=$(<"$path/test.txt")
out=()
IFS=',' read -ra out <<< "$value"
pass_count=$((pass_count+${out[0]}))
fail_count=$((fail_count+${out[1]}))
rm -rf $path/test.txt
else
echo "got error while compiling $entry"
exit 1
fi
echo "Done"
echo ""
fi
done
echo "-----------------------------------"
echo "Test results"
echo "-----------------------------------"
echo ""
echo "total categories: $row_count"
total=$(expr $pass_count + $fail_count)
echo "Total tests: $total"
echo "Passed: $pass_count"
echo "Failed: $fail_count"
if [[ $fail_count -eq 0 ]]; then
echo "All tests passed"
else
echo "Sorry, some tests failed!"
exit 1
fi