-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_autograder
executable file
·107 lines (89 loc) · 2.4 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
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
102
103
104
105
106
107
#!/usr/bin/env bash
##########################################################
# Autograder script for 500.112, Gateway Computing: Java #
##########################################################
# If script is passed parameter "local", runs the script locally
where_to_run=$1
# Setting folder variables
src_files=/autograder/source/
subm_files=/autograder/submission/
results=/autograder/results/
# make it local
if [ "$where_to_run" == "local" ]
then
src_files=".${src_files}"
subm_files=".${subm_files}"
results=".${results}"
fi
prgs=('Proj2B')
############
# Clean up #
############
echo 'Removing files we will generate, just in case'
remove_files
# need to do a bit of back and forth due to local filesystem
if [ "$where_to_run" != "local" ]
then
cd $src_files
fi
# Copy student code into folder where we'll execute it
for i in ${prgs[@]}
do
cp ${subm_files}${i}.java $src_files
done
go_there
#####################################
# Compile sample code #
#####################################
echo "COMPILING AUTOGRADER CODE..."
javac -classpath junit/junit-4.13-beta-2.jar:checkstyle/checkstyle-8.28-all.jar:. AutograderMain.java
javac ${prgs[0]}Sample.java
come_back
######################
# Create JSON output #
######################
echo ''
echo 'Now creating JSON output'
json_prg="AutograderMain"
rslt_folder=$results
# Note in the local case, the result folder is in the source file
if [ "$where_to_run" == "local" ]
then
cd $src_files
rslt_folder="results/"
fi
java -classpath junit/*:checkstyle/*:. $json_prg ${prgs[0]} 7 14 > ${rslt_folder}results.json
rm *.out
echo ''
echo 'Autograder script ended'
# If we're running around locally and need to jump around
function come_back {
if [ "$where_to_run" == "local" ]
then
cd ..
cd ..
fi
}
# If we're running around locally and need to jump around
function go_there {
if [ "$where_to_run" == "local" ]
then
cd $src_files
fi
}
function remove_files {
echo ''
rm -f ${results}results.json
for i in "${prgs[@]}"
do
rm -f ${src_files}${i}.java
rm -f ${src_files}${i}.class
rm -f ${src_files}${i}.compile
rm -f ${src_files}${i}.out
rm -f ${src_files}${i}.pass
rm -f ${src_files}${i}.diffresults
rm -f ${src_files}${i}.expected
done
rm -f ${src_files}_difflines*
rm -f ${src_files}_checkresult*.txt
}