Added output filter feature to test runner for cross-platform test compatibility

This commit is contained in:
Thomas Jensen 2014-10-11 21:48:06 +02:00
parent f6c6a175b0
commit b029347429
83 changed files with 93 additions and 6 deletions

View File

@ -1,6 +1,7 @@
:ARGS
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*******/
/* foo */

View File

@ -2,6 +2,7 @@
-s 10x5
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/********/
/* foo */

View File

@ -1,6 +1,7 @@
:ARGS
-f nonexistent
:INPUT
:OUTPUT-FILTER
:EXPECTED-ERROR 1
boxes: Couldn't open config file 'nonexistent' for input.
:EOF

View File

@ -1,8 +1,10 @@
:ARGS
-s
:INPUT
:OUTPUT-FILTER
1s/^.\+: /boxes: /
:EXPECTED-ERROR 1
../src/boxes: option requires an argument -- 's'
boxes: option requires an argument -- 's'
Usage: boxes [options] [infile [outfile]]
Try `boxes -h' for more information.
:EOF

View File

@ -2,6 +2,7 @@
-s 15x5 -a hlvt
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* foo */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hlvc
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hlvb
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hcvt
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* foo */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hcvc
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hcvb
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hrvt
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* foo */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hrvc
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a hrvb
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a l
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a c
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-s 15x5 -a r
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -5,6 +5,7 @@ The row of 'b's shows how position is rounded down if necessary.
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -5,6 +5,7 @@ If no alignment option is given, text is aligned left and put in the top left co
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -3,6 +3,7 @@
:INPUT
aaa
bbbb
:OUTPUT-FILTER
:EXPECTED
/*************/
/* */

View File

@ -2,6 +2,7 @@
-a mistake
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED-ERROR 1
boxes: Illegal text format -- mistake
:EOF

View File

@ -4,6 +4,7 @@
XXXXX
XXXXX
XXXXX
:OUTPUT-FILTER
:EXPECTED
/*********/
/* XXXXX */

View File

@ -4,6 +4,7 @@
XXXXX
XXXXX
XXXXX
:OUTPUT-FILTER
:EXPECTED
/*********/
/* XXXXX */

View File

@ -6,6 +6,7 @@ a
bbb
:OUTPUT-FILTER
:EXPECTED
# a
#

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/***********************/
/* aaa */

View File

@ -5,6 +5,7 @@ Size takes precedence over padding, left padding is killed first
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/********/
/*aaa */

View File

@ -5,6 +5,7 @@ Size takes precedence over padding
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*******/
/*aaa */

View File

@ -5,6 +5,7 @@ Input length takes precedence over size option
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*******/
/*aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/****************************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/\ /\ /\
/\//\\/\ /\//\\/\ /\//\\/\

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/\ /\ /\
/\//\\/\ /\//\\/\ /\//\\/\

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/\ /\ /\
/\//\\/\ /\//\\/\ /\//\\/\

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/\ /\ /\ /\
/\//\\/\ /\//\\/\ /\//\\/\ /\//\\/\

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -2,8 +2,10 @@
-s
:INPUT
foo
:OUTPUT-FILTER
1s/^.\+: /boxes: /
:EXPECTED-ERROR 1
../src/boxes: option requires an argument -- 's'
boxes: option requires an argument -- 's'
Usage: boxes [options] [infile [outfile]]
Try `boxes -h' for more information.
:EOF

View File

@ -2,6 +2,7 @@
-s -2x3
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED-ERROR 1
boxes: invalid box size specification -- -2x3
:EOF

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*********/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*************/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*********/
/* aaa */

View File

@ -4,6 +4,7 @@
aaa
bbbb
ccccc
:OUTPUT-FILTER
:EXPECTED
/*******/
/*aaa */

View File

@ -2,6 +2,7 @@
-s 0x0
:INPUT
foo
:OUTPUT-FILTER
:EXPECTED-ERROR 1
boxes: invalid box size specification -- 0x0
:EOF

View File

@ -3,6 +3,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**************/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**********/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**********/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**********/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXX XXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/***********/
/* XXXXXX */

View File

@ -5,6 +5,7 @@ Because input lines 1 and 3 are only 4 spaces, no tabs can be unexpanded!
XXXXXX
XXX XXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/*******************/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXX XXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/***************/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXX XXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/***************/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**********/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**********/
/* XXXXXX */

View File

@ -4,6 +4,7 @@
XXXXXX
XXXXXX
XXXXXX
:OUTPUT-FILTER
:EXPECTED
/**********/
/* XXXXXX */

View File

@ -45,7 +45,7 @@ fi
echo "Running test case: $testCaseFile"
declare sectionName
for sectionName in :ARGS :INPUT :EXPECTED :EOF; do
for sectionName in :ARGS :INPUT :OUTPUT-FILTER :EXPECTED :EOF; do
if [ $(grep -c ^$sectionName $testCaseFile) -ne 1 ]; then
>&2 echo "Missing section $sectionName in test case '$testCaseFile'."
exit 4
@ -59,11 +59,13 @@ fi
declare -r testInputFile=${testCaseFile/%.txt/.input.tmp}
declare -r testExpectationFile=${testCaseFile/%.txt/.expected.tmp}
declare -r testFilterFile=${testCaseFile/%.txt/.sed.tmp}
declare -r testOutputFile=${testCaseFile/%.txt/.out.tmp}
declare -r boxesArgs=$(cat $testCaseFile | sed -n '/^:ARGS/,+1p' | grep -v ^:INPUT | sed '1d')
cat $testCaseFile | sed -n '/^:INPUT/,/^:EXPECTED\b.*$/p;' | sed '1d;$d' | tr -d '\r' > $testInputFile
cat $testCaseFile | sed -n '/^:EXPECTED/,/^:EOF\b.*$/p;' | sed '1d;$d' | tr -d '\r' > $testExpectationFile
cat $testCaseFile | sed -n '/^:INPUT/,/^:OUTPUT-FILTER/p;' | sed '1d;$d' | tr -d '\r' > $testInputFile
cat $testCaseFile | sed -n '/^:OUTPUT-FILTER/,/^:EXPECTED\b.*$/p;' | sed '1d;$d' | tr -d '\r' > $testFilterFile
cat $testCaseFile | sed -n '/^:EXPECTED/,/^:EOF/p;' | sed '1d;$d' | tr -d '\r' > $testExpectationFile
declare boxesBinary=../src/boxes.exe
if [ ! -x $boxesBinary ]; then
@ -75,7 +77,7 @@ export BOXES=../boxes-config
cat $testInputFile | $boxesBinary $boxesArgs >$testOutputFile 2>&1
declare -ir actualReturnCode=$?
cat $testOutputFile | tr -d '\r' | diff - $testExpectationFile
cat $testOutputFile | tr -d '\r' | sed -f $testFilterFile | diff - $testExpectationFile
if [ $? -ne 0 ]; then
>&2 echo "Error in test case: $testCaseFile (top: actual; bottom: expected)"
exit 5
@ -86,6 +88,7 @@ if [ $actualReturnCode -ne $expectedReturnCode ]; then
fi
rm $testInputFile
rm $testFilterFile
rm $testExpectationFile
rm $testOutputFile