]> mj.ucw.cz Git - moe.git/commitdiff
Implemented output filters (see OUTPUT_FILTER config variable).
authorMartin Mares <mj@ucw.cz>
Sun, 18 Nov 2007 14:16:13 +0000 (15:16 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 18 Nov 2007 14:16:13 +0000 (15:16 +0100)
Also increased robustness of parameter expansion in SYNTAX_CHECK and
OUTPUT_CHECK, embedded redirections should work fine now.

bin/lib
config

diff --git a/bin/lib b/bin/lib
index c9a7f27a6e36be9494b8718cef9c1b6a711fcdb8..bbe3beb9c1ec62f6765b05a7208b32957961a029 100644 (file)
--- 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> "
+               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 "<syntax> "
-       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 "<check> "
                [ -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 785862ec8ee8b14ead88bb2170eae4b0011873d5..e7a1f2bbbec9c120b4fa2784ff58d3b2baf5f754 100644 (file)
--- 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