]> mj.ucw.cz Git - moe.git/blob - public/submit
MO_PUBLIC has been replaced by MO_ROOT.
[moe.git] / public / submit
1 # The Evaluator -- Public Submit Script
2 # (c) 2001--2004 Martin Mares <mj@ucw.cz>
3
4 set -e
5 [ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
6 . $MO_ROOT/bin/lib
7 . $MO_ROOT/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-number>]"
15 PROBLEM=$1
16 public-setup
17 . $PDIR/config
18
19 function test-verdict
20 {
21         pend "$2"
22         [ $1 == 0 ] && exit 1 || exit 0
23 }
24
25 FAILED=0
26 if [ $TASK_TYPE == open-data ] ; then
27         [ -n "$2" ] || die "You need to specify test number for open data problems."
28         TEST=$2
29         pstart "Test case $TEST: "
30         open-locate
31         (
32                 ln $SRCN $TDIR/$TEST.out
33                 syntax-check
34                 test-result 1 OK
35         ) || FAILED=1
36 else
37         [ -z "$2" ] || die "Test number should be given only for open data problems."
38         locate-source
39         compile
40         for TEST in $SAMPLE_TESTS ; do
41                 (
42                 pstart "Checking on sample input $TEST: "
43                 test-run
44                 syntax-check
45                 output-check
46                 die "How could I get there? It's a buuuuug!"
47                 ) || FAILED=$(($FAILED+1))
48         done
49 fi
50
51 if [ $FAILED != 0 ] ; then
52         if [ $FORCE != 0 ] ; then
53                 pend "TESTS FAILED, but --force given, so submitting anyway."
54         else
55                 pend "TESTS FAILED. Nothing has been submitted!"
56                 pend "Use submit --force if you really want to submit an obviously WRONG solution."
57                 exit 1
58         fi
59 fi
60
61 pstart "Submitting... "
62 mkdir -p ~/.submit
63 if [ $TASK_TYPE == open-data ] ; then
64         mkdir -p ~/.submit/$PROBLEM
65         cp $SRCN ~/.submit/$PROBLEM/$TEST.out
66 else
67         rm -rf ~/.submit/$PROBLEM
68         mkdir -p ~/.submit/$PROBLEM
69         cp $SRCN ~/.submit/$PROBLEM/
70 fi
71 pend "OK"