-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_autograder
executable file
·55 lines (42 loc) · 2.01 KB
/
run_autograder
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
#!/usr/bin/env bash
# START: Sets correct directories based on local dev machine vs Gradescope production
if [ -f "/autograder/harness.py" ]; then
echo "[GS] Running on Gradescope container, using Gradescope vars"
DIR="/autograder/source"
OUTPUT_DIR="/autograder/results"
STUDENT_SUBMISSION_DIR="/autograder/submission"
else
echo "[GS] Running on local dev machine, using ./localautograder/ "
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OUTPUT_DIR="$DIR/localautograder/results"
if [ "$#" -lt 1 ]; then
STUDENT_SUBMISSION_DIR="$DIR/localautograder/submission"
else
STUDENT_SUBMISSION_DIR="$1"
fi
fi
PYTHON_JSON_TOOL="$DIR/tools/json_generator.py"
# END: Sets correct directories based on local dev machine vs Gradescope production
# overrides: files to copy into student tree, overwriting whatever is there
# completely. for my projects that will probably be /.eslintrc.cjs,
# /tsconfig.json, and instructor-defined test cases. Students could add extra
# files but that should be easy to find and covered by academic integrity rules.
cp -r "$DIR/overrides/." $STUDENT_SUBMISSION_DIR
# merges: json files that should be merged via `jq -s '.[0] * .[1]' file1 file2`
# this is mainly for package.json to make sure that the build scripts are what I
# expect them to be. Not sure what this will be useful for besides making sure
# that package.json scripts are not changed, probably not super useful.
find "$DIR/merges" -type f ! -name ".gitkeep" -print0 | while read -d $'\0' file
do
TMP=$(mktemp)
jq -s '.[0] * .[1]' "$STUDENT_SUBMISSION_DIR/$(basename "$file")" "$file" >> $TMP && mv $TMP "$STUDENT_SUBMISSION_DIR/$(basename "$file")"
done
cd $STUDENT_SUBMISSION_DIR
# Clean out __MACOSX directories and hidden files
find . -name "__MACOSX" -exec rm -rf {} \;
# Remove old results.json files
rm -r "$OUTPUT_DIR"/*.json
"$DIR"/run_main_tests
# Compile json results
echo "[GS] Compiling results**.json files to results.json"
python3 $PYTHON_JSON_TOOL -c $OUTPUT_DIR