@@ -232,6 +232,9 @@ function arrange_test_fixtures()
232
232
if [ $( grep -c " ^:EXPECTED-ERROR " ${opt_testCase} ) -eq 1 ]; then
233
233
expectedReturnCode=$( grep " ^:EXPECTED-ERROR " " ${opt_testCase} " | sed -e ' s/:EXPECTED-ERROR //' )
234
234
fi
235
+ if [ $( grep -c " ^:EXPECTED discard-stderr" ${opt_testCase} ) -eq 1 ]; then
236
+ discardStderr=true
237
+ fi
235
238
236
239
cat " ${opt_testCase} " | sed -n ' /^:INPUT/,/^:OUTPUT-FILTER/p;' | sed ' 1d;$d' | tr -d ' \r' > " ${testInputFile} "
237
240
cat " ${opt_testCase} " | sed -n ' /^:OUTPUT-FILTER/,/^:EXPECTED\b.*$/p;' | sed ' 1d;$d' | tr -d ' \r' > " ${testFilterFile} "
@@ -248,9 +251,17 @@ function run_boxes()
248
251
249
252
echo " Invoking: $( basename $boxesBinary ) $boxesArgs "
250
253
if [ -z " ${BOXES_TEST_XXD:- } " ]; then
251
- eval " $boxesBinary $boxesArgs " < " $testInputFile " > " $testOutputFile " 2>&1
254
+ if [ ${discardStderr} == true ]; then
255
+ eval " $boxesBinary $boxesArgs " < " $testInputFile " > " $testOutputFile " 2> " $testErrorFile "
256
+ else
257
+ eval " $boxesBinary $boxesArgs " < " $testInputFile " > " $testOutputFile " 2>&1
258
+ fi
252
259
else
253
- eval " $boxesBinary $boxesArgs " < " $testInputFile " | xxd > " $testOutputFile " 2>&1
260
+ if [ ${discardStderr} == true ]; then
261
+ eval " $boxesBinary $boxesArgs " < " $testInputFile " | xxd > " $testOutputFile " 2> " $testErrorFile "
262
+ else
263
+ eval " $boxesBinary $boxesArgs " < " $testInputFile " | xxd > " $testOutputFile " 2>&1
264
+ fi
254
265
fi
255
266
actualReturnCode=$?
256
267
}
@@ -311,7 +322,9 @@ declare -r testInputFile=${opt_testCase/%.txt/.input.tmp}
311
322
declare -r testExpectationFile=${opt_testCase/% .txt/ .expected.tmp}
312
323
declare -r testFilterFile=${opt_testCase/% .txt/ .sed.tmp}
313
324
declare -r testOutputFile=${opt_testCase/% .txt/ .out.tmp}
325
+ declare -r testErrorFile=${opt_testCase/% .txt/ .err.tmp}
314
326
declare -r boxesArgs=$( sed -n ' /^:ARGS/,+1p' < " ${opt_testCase} " | grep -v ^:INPUT | sed ' 1d' | tr -d ' \r' )
327
+ declare discardStderr=false
315
328
316
329
arrange_environment
317
330
arrange_test_fixtures
@@ -328,6 +341,7 @@ rm "${testInputFile}"
328
341
rm " ${testFilterFile} "
329
342
rm " ${testExpectationFile} "
330
343
rm " ${testOutputFile} "
344
+ rm -f " ${testErrorFile} "
331
345
332
346
echo " OK"
333
347
exit 0
0 commit comments