]> mj.ucw.cz Git - moe.git/blobdiff - bin/ev
Renamed desktop icons.
[moe.git] / bin / ev
diff --git a/bin/ev b/bin/ev
index c25f97a7af9670e9716876efd71adbb68e22a05c..a6189077d9f94b228f471887f7a1d062873345ea 100755 (executable)
--- a/bin/ev
+++ b/bin/ev
@@ -1,5 +1,6 @@
+#!/bin/bash
 # The Evaluator -- Master Control Script
-# (c) 2001 Martin Mares <mj@ucw.cz>
+# (c) 2001--2008 Martin Mares <mj@ucw.cz>
 
 set -e
 if [ ! -f config -o ! -f bin/lib ] ; then
@@ -9,14 +10,7 @@ fi
 . bin/lib
 . config
 
-# Set up environment:
-#   PDIR       problem specific data
-#   SDIR       contestant's solution
-#   TDIR       test results
-#   BOXDIR     sandbox
-#   PROBLEM    problem we're evaluating
-
-[ -n "$2" ] || die "Usage: ev <contestant> <problem>"
+[ -n "$2" -a -z "$4" ] || die "Usage: ev <contestant> <problem> [<program>]"
 CONTESTANT=$1
 PROBLEM=$2
 dir-init
@@ -25,29 +19,37 @@ log-init
 box-init
 
 # Compile the program
-locate-source
-compile
+if [ $TASK_TYPE != open-data ] ; then
+       locate-source `if [ -n "$3" ] ; then echo $SDIR/$3 ; fi`
+       compile || true
+fi
+
+# Initialize the points file
+PTSFILE=$TDIR/points
+>$PTSFILE
+
+function test-verdict
+{
+       if [ $1 == 0 ] ; then
+               pend "$2"
+       else
+               pend "$2 ($1 points)"
+       fi
+       echo >>$PTSFILE "$TEST $1 $2"
+       exit 0
+}
 
 # Perform the tests
+[ -z "$EV_SAMPLE" ] || TESTS="$SAMPLE_TESTS $TESTS"
 for TEST in $TESTS ; do
        (
-       pstart "Test $TEST... "
-       [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
        exec >$TDIR/$TEST.log
-       PTSFILE=$TDIR/$TEST.pts
+       test-config
+       pstart "Test $TEST... "
        echo "Test $TEST ($POINTS_PER_TEST points)"
-       if [ ! -f $TDIR/compile.out ] ; then
-               echo >$PTSFILE "0 --"
-               die "No source file"
-       fi
-       if [ ! -f $TDIR/$PROBLEM ] ; then
-               echo >$PTSFILE "0 CE"
-               die "No executable file"
-       fi
-       $TEST_RUN_METHOD || exit 0
-
-       echo "Test completed OK ($POINTS_PER_TEST points)"
-       echo >$PTSFILE "$POINTS_PER_TEST OK"
-       pend "OK"
+       test-run
+       syntax-check
+       output-check
+       die "You must never see this message."
        )
 done