X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=bin%2Flib;h=981b01002a93e3ae4544d19285786059732d5148;hb=d9766570488d6407d3f348bab1a1ea7f9407a39b;hp=bbe3beb9c1ec62f6765b05a7208b32957961a029;hpb=4ea5a509cea333f6bd6c8226a6e71fa114a95a47;p=moe.git diff --git a/bin/lib b/bin/lib index bbe3beb..981b010 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 @@ -57,7 +72,7 @@ function box-init if [ -z "$TEST_USER" -o "$TEST_USER" == $EVAL_USER ] ; then pcont "running locally (INSECURE), " TEST_USER=$EVAL_USER - BOXDIR=box + BOXDIR=`pwd`/box BOXCMD=bin/box mkdir -p box else @@ -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 @@ -162,8 +178,7 @@ function compile box-clean for a in $SRC $COMP_EXTRAS ; do cp $TDIR/$a $BOXDIR/ ; done EXE=$PROBLEM - CCMD=COMP_$SRCEXT - CCMD=`eval echo ${!CCMD}` + CCMD=`eval echo $COMP` COMP_SANDBOX_OPTS=`eval echo $COMP_SANDBOX_OPTS` echo "Compiler command: $CCMD" echo "Compiler sandbox options: $COMP_SANDBOX_OPTS" @@ -195,6 +210,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 @@ -268,7 +289,15 @@ function test-prolog esac if [ -n "$EV_PEDANT" -a $IN_TYPE != none ] ; then pcont " " - bin/pedant <$TDIR/$TEST.in | tr '\n' ' ' >&2 + if [ "$EV_PEDANT" = 1 ] ; then + EV_PEDANT=" " + fi + bin/pedant <$TDIR/$TEST.in >$TDIR/$TEST.pedant $EV_PEDANT + if [ -s $TDIR/$TEST.pedant ] ; then + pend + sed 's/^/\t/' <$TDIR/$TEST.pedant >&2 + pstart -e '\t' + fi fi case $OUT_TYPE in file) echo "Output file: $PROBLEM.out"