From 50cc126ebe949259a54f153a123848d771601b77 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 3 Feb 2008 23:22:00 +0100 Subject: [PATCH] Implemented general mechanism for overriding variables for specific 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 | 4 ++-- bin/lib | 24 +++++++++++++++++++++++- config | 8 +++++++- public/check | 6 +++--- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/bin/ev b/bin/ev index 1681d93..a618907 100755 --- a/bin/ev +++ b/bin/ev @@ -1,6 +1,6 @@ #!/bin/bash # The Evaluator -- Master Control Script -# (c) 2001--2004 Martin Mares +# (c) 2001--2008 Martin Mares 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 792a546..a84258c 100644 --- a/bin/lib +++ b/bin/lib @@ -1,5 +1,5 @@ # The Evaluator -- Shell Function Library -# (c) 2001--2007 Martin Mares +# (c) 2001--2008 Martin Mares # General settings shopt -s dotglob @@ -49,6 +49,21 @@ function try-ln ln $1 $2 2>/dev/null || cp $1 $2 } +# Given a , override each variable by _ + +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 3f87032..75f8764 100644 --- a/config +++ b/config @@ -1,5 +1,5 @@ # Configuration file for the MO Evaluator -# (c) 2001--2007 Martin Mares +# (c) 2001--2008 Martin Mares # 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 diff --git a/public/check b/public/check index 51b6271..6a8012f 100755 --- a/public/check +++ b/public/check @@ -1,6 +1,6 @@ #!/bin/bash # The Evaluator -- Public Checking Script -# (c) 2001--2007 Martin Mares +# (c) 2001--2008 Martin Mares 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 -- 2.39.2