From: Martin Mares Date: Mon, 11 Jun 2007 10:08:11 +0000 (+0200) Subject: Added ability to submit or check an arbitrary file. X-Git-Tag: python-dummy-working~362 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=3a9934c8d0b88440efca1432368613c2d3124dd5;p=moe.git Added ability to submit or check an arbitrary file. --- diff --git a/TODO b/TODO index da76d30..72b106d 100644 --- a/TODO +++ b/TODO @@ -4,9 +4,8 @@ box: konfigurovatelny pristup k timerum a /proc/self/stat (pripadne /proc/self/f score: better formatting of the score table interactive tasks: solve deadlocks? interactive tasks: logging of messages - -!!!!!!!!! copy all users -!!!!!!!!! contest: call check with the right filename and don't let it guess +rename problem to task +submit, check: unify command-line arguments Environment ~~~~~~~~~~~ diff --git a/bin/lib b/bin/lib index 588cf26..faf6d03 100644 --- a/bin/lib +++ b/bin/lib @@ -104,7 +104,30 @@ EOF function locate-source { pstart "Finding source... " - SBASE=${1:-$PROBLEM} + if [ -n "$1" ] ; then + SRCBASE=$(echo $1 | sed 's/\.\([^.]\+\)//') + SRCEXT=$(echo $1 | sed 's/.*\.\([^.]\+\)/\1/') + if [ -n "$SRCEXT" ] ; then + # Full name given, so just check the extension and existence + SRCN=$1 + if [ ${SRCN:0:1} == / ] ; then + SRCN=${SRCN:1} + SDIR= + fi + [ -f "$SDIR/$SRCN" ] || die "Cannot find source file $SDIR/$SRCN" + SRCEXT_OK= + for a in $EXTENSIONS ; do + if [ $a == $SRCEXT ] ; then + pend $SDIR/$SRCN + echo "Explicitly set source file: $SDIR/$SRCN" + return 0 + fi + done + die "Unknown extension .$SRCEXT" + fi + else + SBASE=$PROBLEM + fi for a in $EXTENSIONS ; do if [ -f $SDIR/$SBASE.$a ] ; then [ -z "$SRCN" ] || die "Multiple source files found: $SDIR/$PROBLEM.$a and $SDIR/$SRCN. Please fix." @@ -122,14 +145,15 @@ function locate-source function compile { pstart "Compiling... " - cp -a $SDIR/$SRCN $TDIR/$SRCN + # Beware, the original SRCN can be a strange user-supplied name + SRC=$PROBLEM.$SRCEXT + cp -a $SDIR/$SRCN $TDIR/$SRC if [ -n "$COMP_EXTRAS" ] ; then echo "Extras: $COMP_EXTRAS" for a in $COMP_EXTRAS ; do cp $PDIR/$a $TDIR/ ; done fi box-clean - for a in $SRCN $COMP_EXTRAS ; do cp $TDIR/$a $BOXDIR/ ; done - SRC=$SRCN + for a in $SRC $COMP_EXTRAS ; do cp $TDIR/$a $BOXDIR/ ; done EXE=$PROBLEM CCMD=COMP_$SRCEXT CCMD=`eval echo ${!CCMD}` @@ -344,6 +368,10 @@ function public-setup function open-locate { [ -f $PDIR/$TEST.in ] || die "Unknown test $TEST" - SRCN=$SDIR/$PROBLEM$TEST.out + if [ -n "$1" ] ; then + SRCN=$1 + else + SRCN=$SDIR/$PROBLEM$TEST.out + fi [ -f $SRCN ] || fatal "Output file $SRCN not found" } diff --git a/public/check b/public/check index d5fecff..152884d 100755 --- a/public/check +++ b/public/check @@ -1,14 +1,37 @@ #!/bin/bash # The Evaluator -- Public Checking Script -# (c) 2001--2004 Martin Mares +# (c) 2001--2007 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 -[ -n "$1" ] || die "Usage: check []" +function usage +{ + die "Usage: check [-s ] []" +} + +SRCFILE= +while getopts "s:" opt ; do + case $opt in + s) SRCFILE="$OPTARG" + ;; + *) usage + ;; + esac +done +shift $(($OPTIND-1)) +[ -n "$1" ] || usage PROBLEM=$1 +TEST= +shift +if [ -n "$1" ] ; then + TEST="$1" + shift +fi +[ -z "$1" ] || usage + public-setup . $PDIR/config @@ -23,16 +46,15 @@ function test-verdict } if [ $TASK_TYPE == open-data ] ; then - [ -n "$2" ] || die "You need to specify test number for open data problems." - TEST=$2 + [ -n "$TEST" ] || die "You need to specify test number for open data problems." pstart "Checking $TEST: " - open-locate + open-locate $SRCFILE ln $SRCN $TDIR/$TEST.out syntax-check test-result 1 OK else - [ -z "$2" ] || die "Test number should be given only for open data problems." - locate-source + [ -z "$TEST" ] || die "Test number should be given only for open data problems." + locate-source $SRCFILE compile RC=0 for TEST in $SAMPLE_TESTS ; do diff --git a/public/submit b/public/submit index fc7c08e..886a1c8 100755 --- a/public/submit +++ b/public/submit @@ -7,14 +7,36 @@ set -e . $MO_ROOT/bin/lib . $MO_ROOT/config +function usage +{ + die "Usage: check [--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=$2 +PART= +shift +if [ -n "$1" ] ; then + PART="$1" + shift +fi +[ -z "$1" ] || usage public-setup . $PDIR/config @@ -29,7 +51,7 @@ 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 + open-locate $SRCFILE ( ln $SRCN $TDIR/$TEST.out syntax-check @@ -37,7 +59,7 @@ if [ $TASK_TYPE == open-data ] ; then ) || FAILED=1 else [ -z "$PART" ] || die "Test number should be given only for open data problems." - locate-source + locate-source $SRCFILE compile for TEST in $SAMPLE_TESTS ; do ( @@ -62,7 +84,7 @@ fi if [ -n "$REMOTE_SUBMIT" ] ; then pstart "Submitting to the server... " - $MO_ROOT/bin/remote-submit $PROBLEM $PART $SRCN + $MO_ROOT/bin/remote-submit $PROBLEM $PART $SDIR/$SRCN pend "OK" exit 0 fi diff --git a/submit/contest b/submit/contest index 17e1b39..3f9e6c3 100755 --- a/submit/contest +++ b/submit/contest @@ -429,7 +429,7 @@ sub run_checks() { my $root = $conn->{"root"}; my ($task, $part) = split /\//, $selected_task; defined $part or $part = ""; - my $verdict = `$root/bin/check $task $part 2>&1`; + my $verdict = `$root/bin/check -s "$submit_filename" $task $part 2>&1`; if ($?) { checks_failed($verdict); } else {