]> mj.ucw.cz Git - eval.git/blobdiff - public/submit
Added configuration file for libucw modules.
[eval.git] / public / submit
old mode 100644 (file)
new mode 100755 (executable)
index 65416e0..f597ee4
@@ -1,18 +1,42 @@
+#!/bin/bash
 # The Evaluator -- Public Submit Script
-# (c) 2001--2004 Martin Mares <mj@ucw.cz>
+# (c) 2001--2007 Martin Mares <mj@ucw.cz>
 
 set -e
-[ -n "$MO_PUBLIC" -a -d "$MO_PUBLIC" ] || { echo >&2 "MO_PUBLIC not set, giving up." ; exit 1 ; }
-. $MO_PUBLIC/bin/lib
-. $MO_PUBLIC/config
+[ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
+. $MO_ROOT/bin/lib
+. $MO_ROOT/config
+
+function usage
+{
+       die "Usage: submit [--force] [-s <source-file>] <problem> [<test-number>]"
+}
 
 FORCE=0
 if [ "$1" = --force ] ; then
        FORCE=1
        shift
 fi
-[ -n "$1" -o "$1" = "--help" ] || die "Usage: submit [--force] <problem> [<test-number>]"
+[ -n "$1" -a "$1" != "--help" ] || usage
+SRCFILE=
+while getopts "s:" opt ; do
+       case $opt in
+               s)      SRCFILE="$OPTARG"
+                       ;;
+               *)      usage
+                       ;;
+       esac
+done
+shift $(($OPTIND-1))
+[ -n "$1" ] || usage
 PROBLEM=$1
+PART=
+shift
+if [ -n "$1" ] ; then
+       PART="$1"
+       shift
+fi
+[ -z "$1" ] || usage
 public-setup
 . $PDIR/config
 
@@ -24,22 +48,24 @@ function test-verdict
 
 FAILED=0
 if [ $TASK_TYPE == open-data ] ; then
-       [ -n "$2" ] || die "You need to specify test number for open data problems."
-       TEST=$2
+       [ -n "$PART" ] || die "You need to specify test number for open data problems."
+       TEST=$PART
        pstart "Test case $TEST: "
-       open-locate
+       open-locate "$SRCFILE"
        (
-               ln $SRCN $TDIR/$TEST.out
+               [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
+               try-ln "$SDIR/$SRCN" $TDIR/$TEST.out
                syntax-check
-               test-result 1 OK
+               test-result $POINTS_PER_TEST OK
        ) || FAILED=1
 else
-       [ -z "$2" ] || die "Test number should be given only for open data problems."
-       locate-source
+       [ -z "$PART" ] || die "Test number should be given only for open data problems."
+       locate-source "$SRCFILE"
        compile
        for TEST in $SAMPLE_TESTS ; do
                (
                pstart "Checking on sample input $TEST: "
+               [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
                test-run
                syntax-check
                output-check
@@ -50,6 +76,7 @@ fi
 
 if [ $FAILED != 0 ] ; then
        if [ $FORCE != 0 ] ; then
+               echo "Submit forced."
                pend "TESTS FAILED, but --force given, so submitting anyway."
        else
                pend "TESTS FAILED. Nothing has been submitted!"
@@ -58,14 +85,21 @@ if [ $FAILED != 0 ] ; then
        fi
 fi
 
+if [ -n "$REMOTE_SUBMIT" ] ; then
+       pstart "Submitting to the server... "
+       $MO_ROOT/bin/remote-submit $PROBLEM $PART "$SDIR/$SRCN"
+       pend "OK"
+       exit 0
+fi
+
 pstart "Submitting... "
 mkdir -p ~/.submit
 if [ $TASK_TYPE == open-data ] ; then
        mkdir -p ~/.submit/$PROBLEM
-       cp $SRCN ~/.submit/$PROBLEM/$TEST.out
+       cp "$SDIR/$SRCN" ~/.submit/$PROBLEM/$PART.out
 else
        rm -rf ~/.submit/$PROBLEM
        mkdir -p ~/.submit/$PROBLEM
-       cp $SRCN ~/.submit/$PROBLEM/
+       cp "$SDIR/$SRCN" ~/.submit/$PROBLEM/
 fi
 pend "OK"