From 18f7d197acb93829650b8a752998b504b125f2e6 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 11 Jun 2007 22:52:30 +0200 Subject: [PATCH] Fix evaluation of interactive programs. --- TODO | 3 +++ bin/lib | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index 433b8c4..bb5d5e5 100644 --- a/TODO +++ b/TODO @@ -7,6 +7,9 @@ interactive tasks: logging of messages rename problem to task submit, check: unify command-line arguments clean up retest utility +document IA_CHECK +bin/lib changes from mo-eval user +writing of verdicts to stdout (include timing and check on interactive tasks, including judge errors) Environment ~~~~~~~~~~~ diff --git a/bin/lib b/bin/lib index 87d7100..237a891 100644 --- a/bin/lib +++ b/bin/lib @@ -227,7 +227,7 @@ function test-prolog file) echo "Input file: $PROBLEM.in (from $PDIR/$TEST.in)" try-ln $PDIR/$TEST.in $TDIR/$TEST.in cp $PDIR/$TEST.in $BOXDIR/$PROBLEM.in - BOX_EXTRAS="$BOX_EXTRAS -i/dev/null" + [ $TASK_TYPE == interactive ] || BOX_EXTRAS="$BOX_EXTRAS -i/dev/null" ;; stdio) echo "Input file: (from $PDIR/$TEST.in)" try-ln $PDIR/$TEST.in $TDIR/$TEST.in @@ -241,7 +241,7 @@ function test-prolog esac case $OUT_TYPE in file) echo "Output file: $PROBLEM.out" - BOX_EXTRAS="$BOX_EXTRAS -o/dev/null" + [ $TASK_TYPE == interactive ] || BOX_EXTRAS="$BOX_EXTRAS -o/dev/null" ;; stdio) echo "Output file: " BOX_EXTRAS="$BOX_EXTRAS -o.stdout" @@ -301,7 +301,7 @@ function test-run-interactive echo "Interactive checker: $ICCMD" if ! $HDIR/bin/iwrapper $BOXCMD $BOXOPTS -- ./$PROBLEM @@ $ICCMD 2>$TMPDIR/exec.out ; then cat $TMPDIR/exec.out - MSG="`tail -1 $TMPDIR/exec.out`" + MSG="`head -1 $TMPDIR/exec.out`" test-result 0 "$MSG" fi cat $TMPDIR/exec.out @@ -329,19 +329,21 @@ function syntax-check function output-check { - [ -n "$OUTPUT_CHECK" ] || return 0 - pcont " " - [ -f $PDIR/$TEST.out ] && try-ln $PDIR/$TEST.out $TDIR/$TEST.ok - OCHECK=`eval echo $OUTPUT_CHECK` - echo "Output check command: $OCHECK" - if ! eval $OCHECK 2>$TMPDIR/exec.out ; then + MSG= + if [ -n "$OUTPUT_CHECK" -a "$OUT_TYPE" != none ] ; then + pcont " " + [ -f $PDIR/$TEST.out ] && ln $PDIR/$TEST.out $TDIR/$TEST.ok + OCHECK=`eval echo $OUTPUT_CHECK` + echo "Output check command: $OCHECK" + if ! eval $OCHECK 2>$TMPDIR/exec.out ; then + cat $TMPDIR/exec.out + MSG=`tail -1 $TMPDIR/exec.out` + if [ -z "$MSG" ] ; then MSG="Wrong answer." ; fi + test-result 0 "$MSG" + fi cat $TMPDIR/exec.out MSG=`tail -1 $TMPDIR/exec.out` - if [ -z "$MSG" ] ; then MSG="Wrong answer." ; fi - test-result 0 "$MSG" fi - cat $TMPDIR/exec.out - MSG=`tail -1 $TMPDIR/exec.out` if [ -z "$MSG" ] ; then MSG="OK" ; fi test-result $POINTS_PER_TEST "$MSG" } -- 2.39.5