-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathverify_submitty_examples.sh
executable file
·101 lines (81 loc) · 2.36 KB
/
verify_submitty_examples.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# Pre clean up of python build folders
find . -type d -name __pycache__ -prune -exec rm -rf {} \;
find . -type d -name .pytest_cache -prune -exec rm -rf {} \;
temp="tmp"
# Check each example
for example in ./examples/*;
do
echo "Checking ${example}";
[[ -d "$example" ]] || break
echo "Running ${example} example";
cd "${example}" || exit
# Run the submitty test for each submission
for submission in submissions/*/;
do
[[ -d "$submission" ]] || break
echo " - Check submission ${submission}";
# Copy over test files and submission
rm -rf ${temp}
mkdir ${temp}
cp "${submission}"* ${temp}/
cp config/test_input/* ${temp}/
if [[ -d "config/custom_validation_code" ]]
then
cp config/custom_validation_code/grader.py ${temp}/
cp config/custom_validation_code/custom_validator_input.json ${temp}/
fi
# Execute test
cd ${temp} || exit
export PIPENV_PIPFILE=../../../Pipfile
pipenv run python grade_submitty.py 1> STDOUT.txt 2> STDERR.txt
status=$?
if [[ $submission == *"failing"* ]]
then
# Expected failing submission
if [[ $status -ne 0 ]]
then
echo " * Successful - Found incorrect submission"
else
echo " --- Failed to find error ---"
cat STDOUT.txt
echo " --- Failed to find error ---"
exit 1
fi
else
# Expected successful submission
if [[ $status -eq 0 ]]
then
echo " * Successful - Confirmed solution"
else
echo " --- Failed solution ---"
cat STDOUT.txt
echo " --- Failed solution ---"
exit 1
fi
fi
# Custom validation output check
if [[ -f "grader.py" ]]
then
actual_file="validation_results.json"
expected_file="validation_results_expected.json"
pipenv run python grader.py 1> cv_output.txt 2> cv_error.txt
diff "$actual_file" "$expected_file"
status=$?
if [[ $status -ne 0 ]]
then
printf 'The actual file ("%s") is different from expected ("%s")\n' "$actual_file" "$expected_file"
exit $status
else
echo " * Successful - Confirmed custom validation result"
fi
fi
# clean up
cd .. || exit
rm -rf ${temp}
# end of submission
done
# Move back up to project root.
cd ../.. || exit
# end of example
done