]> mj.ucw.cz Git - moe.git/blob - public/submit
Added a switch for allowing timing syscalls.
[moe.git] / public / submit
1 # The Evaluator -- Public Submit Script
2 # (c) 2001 Martin Mares <mj@ucw.cz>
3
4 set -e
5 [ -n "$MO_PUBLIC" -a -d "$MO_PUBLIC" ] || { echo >&2 "MO_PUBLIC not set, giving up." ; exit 1 ; }
6 . $MO_PUBLIC/bin/lib
7 . $MO_PUBLIC/config
8
9 FORCE=0
10 if [ "$1" = --force ] ; then
11         FORCE=1
12         shift
13 fi
14 [ -n "$1" -o "$1" = "--help" ] || die "Usage: submit [--force] <problem> [<test>]"
15 PROBLEM=$1
16 public-setup
17 . $PDIR/config
18 PTSFILE=$TDIR/points
19 FAILED=0
20 if [ -n "$OPEN_DATA_PROBLEM" ] ; then
21         [ -n "$2" ] || die "You need to specify test number for open data problems."
22         TEST=$2
23         open-locate
24         syntax-check || FAILED=1
25 else
26         [ -z "$2" ] || die "No test number should be specified for normal problems."
27         locate-source
28         compile
29         for TEST in $SAMPLE_TESTS ; do
30                 pstart "Checking on sample input $TEST: "
31                 if test-run && syntax-check && output-check ; then
32                         pend "OK"
33                 else
34                         FAILED=$(($FAILED+1))
35                 fi
36         done
37 fi
38 pstart "Submitting... "
39 if [ $FAILED != 0 ] ; then
40         if [ $FORCE != 0 ] ; then
41                 pcont "(tests failed, but --force given) "
42         else
43                 pend "TESTS FAILED  Use submit --force if you really want to submit a wrong solution."
44                 exit 1
45         fi
46 fi
47 mkdir -p ~/.submit
48 [ -z "$OPEN_DATA_PROBLEM" ] && rm -rf ~/.submit/$PROBLEM
49 mkdir -p ~/.submit/$PROBLEM
50 cp $SRCN ~/.submit/$PROBLEM/
51 pend "OK"