#!/bin/bash # The Evaluator -- Public Submit Script # (c) 2001--2004 Martin Mares set -e [ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; } . $MO_ROOT/bin/lib . $MO_ROOT/config FORCE=0 if [ "$1" = --force ] ; then FORCE=1 shift fi [ -n "$1" -o "$1" = "--help" ] || die "Usage: submit [--force] []" PROBLEM=$1 PART=$2 public-setup . $PDIR/config function test-verdict { pend "$2" [ $1 == 0 ] && exit 1 || exit 0 } FAILED=0 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 ( ln $SRCN $TDIR/$TEST.out syntax-check test-result 1 OK ) || FAILED=1 else [ -z "$PART" ] || die "Test number should be given only for open data problems." locate-source compile for TEST in $SAMPLE_TESTS ; do ( pstart "Checking on sample input $TEST: " test-run syntax-check output-check die "How could I get there? It's a buuuuug!" ) || FAILED=$(($FAILED+1)) done fi if [ $FAILED != 0 ] ; then if [ $FORCE != 0 ] ; then pend "TESTS FAILED, but --force given, so submitting anyway." else 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 $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/$PART.out else rm -rf ~/.submit/$PROBLEM mkdir -p ~/.submit/$PROBLEM cp $SRCN ~/.submit/$PROBLEM/ fi pend "OK"