-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·36 lines (28 loc) · 1.09 KB
/
run
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
#!/bin/bash
# parsing configuration
config="$(mktemp)"
cat > "$config"
resources="$(jshon -e 'resources' -u < "$config")"
judge="$(jshon -e 'judge' -u < "$config")"
workdir="$(jshon -e 'workdir' -u < "$config")"
# Prepare to compile
compiledir=$(mktemp -d)
cd $compiledir
cp -r $resources/* .
cat "$(jshon -e 'source' -u < "$config")" > "solution.cs"
# Compiling solution with tests
compileresult="$(mktemp)"
csc -reference:$judge/lib/nunit.framework.dll -out:$workdir/testproject.dll -target:library *.cs > $compileresult
if [ $? -ne 0 ]; then
jshon -s "start-judgement" -i "command" <<< "{}"
message="<pre>$(cat $compileresult | tail -n +4)</pre>"
jshon -s "append-message" -i "command" -n {} -s "html" -i "format" -s "$message" -i "description" -i "message"<<< "{}"
jshon -s "close-judgement" -i "command" -n false -i "accepted" -n {} -s "compilation error" -i "enum" -i "status" <<< "{}"
exit 0
fi
# Copy testing framework
cp $judge/lib/nunit.framework.dll $workdir/nunit.framework.dll
# Execute the tests
cd $workdir
rm -r $compiledir
mono $judge/bin/judge-csharp.exe testproject.dll