X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=public%2Fsubmit;h=f597ee46b17eabf5ae1fdd5ab6067aeba06b3186;hb=65517c0cd75d3c846d8e8304c414e9d63d155ecc;hp=bdd475f7a512633d12033c62b7bcb27bb523071e;hpb=210b070496ef912a3b4745477b609b150b013d6b;p=moe.git diff --git a/public/submit b/public/submit old mode 100644 new mode 100755 index bdd475f..f597ee4 --- a/public/submit +++ b/public/submit @@ -1,51 +1,105 @@ +#!/bin/bash # The Evaluator -- Public Submit Script -# (c) 2001 Martin Mares +# (c) 2001--2007 Martin Mares 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 ] []" +} FORCE=0 if [ "$1" = --force ] ; then FORCE=1 shift fi -[ -n "$1" -o "$1" = "--help" ] || die "Usage: submit [--force] []" +[ -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 -PTSFILE=$TDIR/points + +function test-verdict +{ + pend "$2" + [ $1 == 0 ] && exit 1 || exit 0 +} + FAILED=0 -if [ -n "$OPEN_DATA_PROBLEM" ] ; then - [ -n "$2" ] || die "You need to specify test number for open data problems." - TEST=$2 - open-locate - syntax-check || FAILED=1 +if [ $TASK_TYPE == open-data ] ; then + [ -n "$PART" ] || die "You need to specify test number for open data problems." + TEST=$PART + pstart "Test case $TEST: " + open-locate "$SRCFILE" + ( + [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config + try-ln "$SDIR/$SRCN" $TDIR/$TEST.out + syntax-check + test-result $POINTS_PER_TEST OK + ) || FAILED=1 else - [ -z "$2" ] || die "No test number should be specified for normal 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: " - if test-run && syntax-check && output-check ; then - pend "OK" - else - FAILED=$(($FAILED+1)) - fi + [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config + test-run + syntax-check + output-check + die "How could I get there? It's a buuuuug!" + ) || FAILED=$(($FAILED+1)) done fi -pstart "Submitting... " + if [ $FAILED != 0 ] ; then if [ $FORCE != 0 ] ; then - pcont "(tests failed, but --force given) " + echo "Submit forced." + pend "TESTS FAILED, but --force given, so submitting anyway." else - pend "TESTS FAILED Use submit --force if you really want to submit a wrong solution." + pend "TESTS FAILED. Nothing has been submitted!" + pend "Use submit --force if you really want to submit an obviously WRONG solution." exit 1 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 -[ -z "$OPEN_DATA_PROBLEM" ] && rm -rf ~/.submit/$PROBLEM -mkdir -p ~/.submit/$PROBLEM -cp $SRCN ~/.submit/$PROBLEM/ +if [ $TASK_TYPE == open-data ] ; then + mkdir -p ~/.submit/$PROBLEM + cp "$SDIR/$SRCN" ~/.submit/$PROBLEM/$PART.out +else + rm -rf ~/.submit/$PROBLEM + mkdir -p ~/.submit/$PROBLEM + cp "$SDIR/$SRCN" ~/.submit/$PROBLEM/ +fi pend "OK"