Skip to content

Commit c6e6696

Browse files
committed
test
1 parent 2c9e3ed commit c6e6696

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

test/192_logging1.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:DESC
2+
Test case which checks some logging features.
3+
4+
:ARGS
5+
-d dog -x debug:all
6+
:INPUT
7+
foo
8+
:OUTPUT-FILTER
9+
:EXPECTED discard-stderr
10+
__ _,--="=--,_ __
11+
/ \." .-. "./ \
12+
/ ,/ _ : : _ \/` \
13+
\ `| /o\ :_: /o\ |\__/
14+
`-'| :="~` _ `~"=: |
15+
\` (_) `/ jgs
16+
.-"-. \ | / .-"-.
17+
.---{ }--| /,.-'-.,\ |--{ }---.
18+
) (_)_)_) \_/`~-===-~`\_/ (_(_(_) (
19+
( foo )
20+
) (
21+
'---------------------------------------'
22+
:EOF

test/testrunner.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ function arrange_test_fixtures()
232232
if [ $(grep -c "^:EXPECTED-ERROR " ${opt_testCase}) -eq 1 ]; then
233233
expectedReturnCode=$(grep "^:EXPECTED-ERROR " "${opt_testCase}" | sed -e 's/:EXPECTED-ERROR //')
234234
fi
235+
if [ $(grep -c "^:EXPECTED discard-stderr" ${opt_testCase}) -eq 1 ]; then
236+
discardStderr=true
237+
fi
235238

236239
cat "${opt_testCase}" | sed -n '/^:INPUT/,/^:OUTPUT-FILTER/p;' | sed '1d;$d' | tr -d '\r' > "${testInputFile}"
237240
cat "${opt_testCase}" | sed -n '/^:OUTPUT-FILTER/,/^:EXPECTED\b.*$/p;' | sed '1d;$d' | tr -d '\r' > "${testFilterFile}"
@@ -248,9 +251,17 @@ function run_boxes()
248251

249252
echo " Invoking: $(basename $boxesBinary) $boxesArgs"
250253
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
252259
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
254265
fi
255266
actualReturnCode=$?
256267
}
@@ -311,7 +322,9 @@ declare -r testInputFile=${opt_testCase/%.txt/.input.tmp}
311322
declare -r testExpectationFile=${opt_testCase/%.txt/.expected.tmp}
312323
declare -r testFilterFile=${opt_testCase/%.txt/.sed.tmp}
313324
declare -r testOutputFile=${opt_testCase/%.txt/.out.tmp}
325+
declare -r testErrorFile=${opt_testCase/%.txt/.err.tmp}
314326
declare -r boxesArgs=$(sed -n '/^:ARGS/,+1p' < "${opt_testCase}" | grep -v ^:INPUT | sed '1d' | tr -d '\r')
327+
declare discardStderr=false
315328

316329
arrange_environment
317330
arrange_test_fixtures
@@ -328,6 +341,7 @@ rm "${testInputFile}"
328341
rm "${testFilterFile}"
329342
rm "${testExpectationFile}"
330343
rm "${testOutputFile}"
344+
rm -f "${testErrorFile}"
331345

332346
echo " OK"
333347
exit 0

0 commit comments

Comments
 (0)