From: Martin Mares Date: Sun, 18 Nov 2007 14:16:13 +0000 (+0100) Subject: Implemented output filters (see OUTPUT_FILTER config variable). X-Git-Tag: python-dummy-working~276 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=4ea5a509cea333f6bd6c8226a6e71fa114a95a47;p=moe.git Implemented output filters (see OUTPUT_FILTER config variable). Also increased robustness of parameter expansion in SYNTAX_CHECK and OUTPUT_CHECK, embedded redirections should work fine now. --- diff --git a/bin/lib b/bin/lib index c9a7f27..bbe3beb 100644 --- a/bin/lib +++ b/bin/lib @@ -301,6 +301,20 @@ function test-epilog cp $BOXDIR/.stdout $TDIR/$TEST.out ;; esac + + if [ -n "$OUTPUT_FILTER" -a "$OUT_TYPE" != none -a -z "$EV_NOFILTER" ] ; then + pcont " " + FILTER=`eval echo \"$OUTPUT_FILTER\"` + echo "Output filter command: $FILTER" + mv $TDIR/$TEST.out $TDIR/$TEST.raw + if ! eval $FILTER 2>$TMPDIR/exec.out ; then + cat $TMPDIR/exec.out + MSG=`tail -1 $TMPDIR/exec.out` + if [ -z "$MSG" ] ; then MSG="Filter failed" ; fi + test-result 0 "$MSG" + fi + cat $TMPDIR/exec.out + fi } # Running of test program with file input/output @@ -354,7 +368,7 @@ function syntax-check [ -n "$SYNTAX_CHECK" ] || return 0 [ -z "$EV_NOCHECK" ] || return 0 pcont " " - SCHECK=`eval echo $SYNTAX_CHECK` + SCHECK=`eval echo \"$SYNTAX_CHECK\"` echo "Syntax check command: $SCHECK" if ! eval $SCHECK 2>$TMPDIR/exec.out ; then cat $TMPDIR/exec.out @@ -373,7 +387,7 @@ function output-check if [ -n "$OUTPUT_CHECK" -a "$OUT_TYPE" != none -a -z "$EV_NOCHECK" ] ; then pcont " " [ -f $PDIR/$TEST.out ] && ln $PDIR/$TEST.out $TDIR/$TEST.ok - OCHECK=`eval echo $OUTPUT_CHECK` + OCHECK=`eval echo \"$OUTPUT_CHECK\"` echo "Output check command: $OCHECK" if ! eval $OCHECK 2>$TMPDIR/exec.out ; then cat $TMPDIR/exec.out diff --git a/config b/config index 785862e..e7a1f2b 100644 --- a/config +++ b/config @@ -104,6 +104,12 @@ TIME_LIMIT=10 # Memory limit in kilobytes MEM_LIMIT=16384 +# Command used for filtering of program output (optional) +# If turned on, program output (*.raw) is ran through this filter and the +# checkers are applied to the output of the filter (*.out). +# Can exit with code 1 if there is a syntax error in the output. +#OUTPUT_FILTER='tr -d '\''\r'\'' <$TDIR/$TEST.raw >$TDIR/$TEST.out' + # Command used to check output syntax (optional) # Returns exit code 1 if syntax is wrong, 0 if correct # fd1 is connect to evaluator log, feel free to log anything @@ -141,3 +147,6 @@ FREE_PASCAL_RTE=1 # DEBUG: Skip checks (useful when generating output files by running model solution) #EV_NOCHECK=1 + +# DEBUG: Skip output filters (if you suspect they are buggy) +#EV_NOFILTER=1