]> mj.ucw.cz Git - eval.git/commitdiff
Added retest utility.
authorMartin Mares <mj@ucw.cz>
Mon, 11 Jun 2007 14:37:00 +0000 (16:37 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 11 Jun 2007 14:37:00 +0000 (16:37 +0200)
TODO
bin/lib
public/retest [new file with mode: 0755]

diff --git a/TODO b/TODO
index 72b106dfb3ffd6105e15395f0d18492946742786..433b8c4e447d013245ddf71ee8bd88ce42a367ff 100644 (file)
--- a/TODO
+++ b/TODO
@@ -6,6 +6,7 @@ interactive tasks: solve deadlocks?
 interactive tasks: logging of messages
 rename problem to task
 submit, check: unify command-line arguments
+clean up retest utility
 
 Environment
 ~~~~~~~~~~~
diff --git a/bin/lib b/bin/lib
index faf6d038d830561453d4a53395beaae29a398f4f..87d7100305a837acde774fef69be09b65247f6dd 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -44,6 +44,11 @@ function fatal
        exit 1
 }
 
+function try-ln
+{
+       ln $1 $2 2>/dev/null || cp $1 $2
+}
+
 # Sandbox subroutines
 
 function box-init
@@ -220,12 +225,12 @@ function test-prolog
        OUT_TYPE=${OUT_TYPE:-$IO_TYPE}
        case $IN_TYPE in
                file)   echo "Input file: $PROBLEM.in (from $PDIR/$TEST.in)"
-                       ln $PDIR/$TEST.in $TDIR/$TEST.in
+                       try-ln $PDIR/$TEST.in $TDIR/$TEST.in
                        cp $PDIR/$TEST.in $BOXDIR/$PROBLEM.in
                        BOX_EXTRAS="$BOX_EXTRAS -i/dev/null"
                        ;;
                stdio)  echo "Input file: <stdin> (from $PDIR/$TEST.in)"
-                       ln $PDIR/$TEST.in $TDIR/$TEST.in
+                       try-ln $PDIR/$TEST.in $TDIR/$TEST.in
                        cp $PDIR/$TEST.in $BOXDIR/.stdin
                        BOX_EXTRAS="$BOX_EXTRAS -i.stdin"
                        ;;
@@ -326,7 +331,7 @@ function output-check
 {
        [ -n "$OUTPUT_CHECK" ] || return 0
        pcont "<check> "
-       [ -f $PDIR/$TEST.out ] && ln $PDIR/$TEST.out $TDIR/$TEST.ok
+       [ -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
diff --git a/public/retest b/public/retest
new file mode 100755 (executable)
index 0000000..a959f03
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/bash
+# The Evaluator -- Public Checking Script
+# (c) 2001--2007 Martin Mares <mj@ucw.cz>
+
+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
+
+function usage
+{
+       die "Usage: check [-s <source-file>] <problem> [<test-number>]"
+}
+
+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
+HDIR=/mo/cpspc/day1/
+PDIR=$HDIR/problems/$PROBLEM
+. $PDIR/config
+
+function test-verdict
+{
+       pend "$2"
+       if [ $1 == 0 ] ; then
+               exit 1
+       else
+               exit 0
+       fi
+}
+
+if [ $TASK_TYPE == open-data ] ; then
+       [ -n "$TEST" ] || die "You need to specify test number for open data problems."
+       pstart "Checking $TEST: "
+       open-locate $SRCFILE
+       ln $SRCN $TDIR/$TEST.out
+       syntax-check
+       test-result 1 OK
+else
+       [ -z "$TEST" ] || die "Test number should be given only for open data problems."
+       locate-source $SRCFILE
+       compile
+       RC=0
+       for TEST in $TESTS ; do
+               (
+               pstart "Checking on sample input $TEST: "
+               test-run
+               syntax-check
+               output-check
+               ) || RC=1
+       done
+       exit $RC
+fi