]> mj.ucw.cz Git - moe.git/commitdiff
Implemented general mechanism for overriding variables for specific
authorMartin Mares <mj@ucw.cz>
Sun, 3 Feb 2008 22:22:00 +0000 (23:22 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 3 Feb 2008 22:22:00 +0000 (23:22 +0100)
extensions or test cases. See the `override-vars' function.

Loading of per-test configuration has been moved to `test-config' in bin/lib.

bin/ev
bin/lib
config
public/check

diff --git a/bin/ev b/bin/ev
index 1681d93c612a211ae6e23c9b0fe99d81bcd3aea9..a6189077d9f94b228f471887f7a1d062873345ea 100755 (executable)
--- a/bin/ev
+++ b/bin/ev
@@ -1,6 +1,6 @@
 #!/bin/bash
 # The Evaluator -- Master Control Script
-# (c) 2001--2004 Martin Mares <mj@ucw.cz>
+# (c) 2001--2008 Martin Mares <mj@ucw.cz>
 
 set -e
 if [ ! -f config -o ! -f bin/lib ] ; then
@@ -43,8 +43,8 @@ function test-verdict
 [ -z "$EV_SAMPLE" ] || TESTS="$SAMPLE_TESTS $TESTS"
 for TEST in $TESTS ; do
        (
-       [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
        exec >$TDIR/$TEST.log
+       test-config
        pstart "Test $TEST... "
        echo "Test $TEST ($POINTS_PER_TEST points)"
        test-run
diff --git a/bin/lib b/bin/lib
index 792a546ca9c6f4f475b2dd553762e5c18ca7a92e..a84258cb162aeed79730d40d4701e361063350bf 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -1,5 +1,5 @@
 # The Evaluator -- Shell Function Library
-# (c) 2001--2007 Martin Mares <mj@ucw.cz>
+# (c) 2001--2008 Martin Mares <mj@ucw.cz>
 
 # General settings
 shopt -s dotglob
@@ -49,6 +49,21 @@ function try-ln
        ln $1 $2 2>/dev/null || cp $1 $2
 }
 
+# Given a <prefix>, override each variable <x> by <prefix>_<x>
+
+function override-vars
+{
+       local OR V OLDIFS
+       declare -a OR
+       OLDIFS="$IFS"
+       IFS=$'\n'
+       OR=($(set | sed "s/^$1_//;t;d")) || true
+       IFS="$OLDIFS"
+       for V in "${OR[@]}" ; do
+               eval "$V"
+       done
+}
+
 # Sandbox subroutines
 
 function box-init
@@ -152,6 +167,7 @@ function locate-source
 function compile
 {
        pstart "Compiling... "
+       override-vars "EXT_$SRCEXT"
        # Beware, the original SRCN can be a strange user-supplied name
        SRC=$PROBLEM.$SRCEXT
        cp "$SDIR/$SRCN" $TDIR/$SRC
@@ -195,6 +211,12 @@ function compile
 
 # Running of test program according to current task type (returns exit code and TEST_MSG)
 
+function test-config
+{
+       [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
+       override-vars "TEST_$TEST"
+}
+
 function test-run
 {
        test-run-$TASK_TYPE
diff --git a/config b/config
index 3f870327547d8842e95e0151265821ef3f438755..75f876492d20ec31e2f960fb478e217e060193de 100644 (file)
--- a/config
+++ b/config
@@ -1,5 +1,5 @@
 # Configuration file for the MO Evaluator
-# (c) 2001--2007 Martin Mares <mj@ucw.cz>
+# (c) 2001--2008 Martin Mares <mj@ucw.cz>
 
 # The root of the whole directory hierarchy
 MO_ROOT=/mo
@@ -150,3 +150,9 @@ FREE_PASCAL_RTE=1
 
 # DEBUG: Skip output filters (if you suspect they are buggy)
 #EV_NOFILTER=1
+
+### Variables overrides (most variables can be overridden for specific tests or source extensions):
+
+#EXT_pas_TIME_LIMIT=100
+#TEST_1_TIME_LIMIT=100
+#EXT_pas_TEST_1_TIME_LIMIT=100
index 51b627186acc3f5149338fdd7d50a4ceb7ed75d3..6a8012f2bcfefee60ab3c2c174d8cba91a867614 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # The Evaluator -- Public Checking Script
-# (c) 2001--2007 Martin Mares <mj@ucw.cz>
+# (c) 2001--2008 Martin Mares <mj@ucw.cz>
 
 set -e
 [ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
@@ -48,7 +48,7 @@ function test-verdict
 if [ $TASK_TYPE == open-data ] ; then
        [ -n "$TEST" ] || die "You need to specify test number for open data problems."
        pstart "Checking $TEST: "
-       [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
+       test-config
        open-locate "$SRCFILE"
        try-ln "$SDIR/$SRCN" $TDIR/$TEST.out
        syntax-check
@@ -61,7 +61,7 @@ else
        for TEST in $SAMPLE_TESTS ; do
                (
                pstart "Checking on sample input $TEST: "
-               [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
+               test-config
                test-run
                syntax-check
                output-check