]> granicus.if.org Git - re2c/commitdiff
run_tests.sh: separate stdout and stderr, diff with -b on wine.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 10 Aug 2015 12:16:56 +0000 (13:16 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 10 Aug 2015 12:16:56 +0000 (13:16 +0100)
Found some errors while testing mingw-built re2c.exe on wine:
    1. redirecting stderr to stdout resulted resulted in random
       mix in tests that triggered re2c warnings
    2. removing all '\r' symbols in the generated files didn't
       work anymore since some tests that contain '\r' were added

Fixed:
    1. redirect both to different files and cat manually
    2. diff with -b flag on wine

re2c/run_tests.sh.in

index b33b026201c2bf162a56304b0e76bfd90be91f8c..8583f25ce162bbf6325c94489668b23c7c533918 100644 (file)
@@ -80,6 +80,13 @@ then
        echo $valgrind
 fi
 
+diff_prog="diff"
+if test -n "${wine}"
+then
+       # ignore whitespace at the end of line
+       diff_prog="${diff_prog} -b"
+fi
+
 run_pack() {
        local log="$1"
        shift 1
@@ -101,11 +108,14 @@ run_pack() {
                local switches="$switches -W"
 
                local cmd="${valgrind} ${wine} ${re2c} $switches $x"
-               if test -n "${wine}"
-               then
-                       local filter_newlines='-e s/\r//g'
-               fi
-               $cmd 2>&1 | LC_ALL=C sed -e "s,$x,`basename $x`,g" -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g' ${filter_newlines} > $outname
+               local outname_stdout="${outname}.stdout"
+               local outname_stderr="${outname}.stderr"
+               $cmd 2>$outname_stderr >$outname_stdout
+               cat $outname_stderr > $outname && rm $outname_stderr
+               cat $outname_stdout >> $outname && rm $outname_stdout
+               LC_ALL=C sed -i $outname \
+                       -e "s,$x,`basename $x`,g" \
+                       -e 's,/\* Generated by re2c .*\*/,/\* Generated by re2c \*/,g'
                if test -n "$genname"
                then
                        cat $genname | sed \
@@ -122,7 +132,7 @@ run_pack() {
                        local errcnt=$(($errcnt + 1))
                        cp -f $x $test_blddir
                else
-                       local r=`diff ${x%.re}.c $outname > $outdiff; echo $?`
+                       local r=`$diff_prog ${x%.re}.c $outname > $outdiff; echo $?`
                        if [[ $r == 0 ]]
                        then
                                echo "OK $x: $switches"
@@ -143,7 +153,7 @@ run_pack() {
                                echo "FAIL missing ${x%.re}.h"
                                local errcnt=$(($errcnt + 1))
                                cp -f $x $test_blddir
-                       elif diff ${x%.re}.h $typname > $typdiff
+                       elif $diff_prog ${x%.re}.h $typname > $typdiff
                        then
                                echo "OK $x: $switches"
                                rm $typname