mirror of
https://github.com/ascii-boxes/boxes.git
synced 2024-12-04 05:54:06 +01:00
Add test cases for generating debug log output
This commit is contained in:
parent
83fc460a49
commit
a71e1b875c
@ -739,6 +739,12 @@ int generate_box(sentry_t *thebox)
|
||||
int rc;
|
||||
int i;
|
||||
|
||||
if (is_debug_logging(MAIN)) {
|
||||
for (i = 0; i < NUM_SHAPES; i++) {
|
||||
debug_print_shape(opt.design->shape + i);
|
||||
}
|
||||
}
|
||||
|
||||
rc = horiz_generate(&(thebox[0]), &(thebox[2]));
|
||||
if (rc) {
|
||||
goto err;
|
||||
|
@ -468,8 +468,9 @@ void debug_print_shape(sentry_t *shape)
|
||||
log_debug(__FILE__, MAIN, "NULL\n");
|
||||
return;
|
||||
}
|
||||
log_debug(__FILE__, MAIN, "Shape %3s (%dx%d): elastic=%s, bl=",
|
||||
shape_name[shape->name], (int) shape->width, (int) shape->height, shape->elastic ? "true" : "false");
|
||||
log_debug(__FILE__, MAIN, "Shape %3s (%dx%d): elastic=%s,%s bl=",
|
||||
shape_name[shape->name], (int) shape->width, (int) shape->height,
|
||||
shape->elastic ? "true" : "false", shape->elastic ? " " : "");
|
||||
if (shape->blank_leftward == NULL) {
|
||||
log_debug_cont(MAIN, "NULL");
|
||||
}
|
||||
|
22
test/192_logging1.txt
Normal file
22
test/192_logging1.txt
Normal file
@ -0,0 +1,22 @@
|
||||
:DESC
|
||||
Test case which checks some logging features.
|
||||
|
||||
:ARGS
|
||||
-d dog -x debug:all
|
||||
:INPUT
|
||||
foo
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED discard-stderr
|
||||
__ _,--="=--,_ __
|
||||
/ \." .-. "./ \
|
||||
/ ,/ _ : : _ \/` \
|
||||
\ `| /o\ :_: /o\ |\__/
|
||||
`-'| :="~` _ `~"=: |
|
||||
\` (_) `/ jgs
|
||||
.-"-. \ | / .-"-.
|
||||
.---{ }--| /,.-'-.,\ |--{ }---.
|
||||
) (_)_)_) \_/`~-===-~`\_/ (_(_(_) (
|
||||
( foo )
|
||||
) (
|
||||
'---------------------------------------'
|
||||
:EOF
|
13
test/193_logging2.txt
Normal file
13
test/193_logging2.txt
Normal file
@ -0,0 +1,13 @@
|
||||
:DESC
|
||||
Test case which checks some logging features.
|
||||
|
||||
:ARGS
|
||||
-d headline -x debug:main,regexp,parser,lexer,DISCOVERY
|
||||
:INPUT
|
||||
Hello World!
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED discard-stderr
|
||||
/*****************************/
|
||||
/* H e l l o W o r l d ! */
|
||||
/*****************************/
|
||||
:EOF
|
13
test/194_logging_with_parent_configs.txt
Normal file
13
test/194_logging_with_parent_configs.txt
Normal file
@ -0,0 +1,13 @@
|
||||
:DESC
|
||||
Test case 130 with logging turned on.
|
||||
|
||||
:ARGS
|
||||
-f 130_data/B.cfg -d designA -p l1 -a vc -x debug:all
|
||||
:INPUT
|
||||
foo
|
||||
:OUTPUT-FILTER
|
||||
:EXPECTED discard-stderr
|
||||
AAA
|
||||
AAA foo
|
||||
AAA
|
||||
:EOF
|
@ -232,6 +232,9 @@ function arrange_test_fixtures()
|
||||
if [ $(grep -c "^:EXPECTED-ERROR " ${opt_testCase}) -eq 1 ]; then
|
||||
expectedReturnCode=$(grep "^:EXPECTED-ERROR " "${opt_testCase}" | sed -e 's/:EXPECTED-ERROR //')
|
||||
fi
|
||||
if [ $(grep -c "^:EXPECTED discard-stderr" ${opt_testCase}) -eq 1 ]; then
|
||||
discardStderr=true
|
||||
fi
|
||||
|
||||
cat "${opt_testCase}" | sed -n '/^:INPUT/,/^:OUTPUT-FILTER/p;' | sed '1d;$d' | tr -d '\r' > "${testInputFile}"
|
||||
cat "${opt_testCase}" | sed -n '/^:OUTPUT-FILTER/,/^:EXPECTED\b.*$/p;' | sed '1d;$d' | tr -d '\r' > "${testFilterFile}"
|
||||
@ -248,9 +251,17 @@ function run_boxes()
|
||||
|
||||
echo " Invoking: $(basename $boxesBinary) $boxesArgs"
|
||||
if [ -z "${BOXES_TEST_XXD:-}" ]; then
|
||||
eval "$boxesBinary $boxesArgs" < "$testInputFile" > "$testOutputFile" 2>&1
|
||||
if [ ${discardStderr} == true ]; then
|
||||
eval "$boxesBinary $boxesArgs" < "$testInputFile" > "$testOutputFile" 2> "$testErrorFile"
|
||||
else
|
||||
eval "$boxesBinary $boxesArgs" < "$testInputFile" > "$testOutputFile" 2>&1
|
||||
fi
|
||||
else
|
||||
eval "$boxesBinary $boxesArgs" < "$testInputFile" | xxd > "$testOutputFile" 2>&1
|
||||
if [ ${discardStderr} == true ]; then
|
||||
eval "$boxesBinary $boxesArgs" < "$testInputFile" | xxd > "$testOutputFile" 2> "$testErrorFile"
|
||||
else
|
||||
eval "$boxesBinary $boxesArgs" < "$testInputFile" | xxd > "$testOutputFile" 2>&1
|
||||
fi
|
||||
fi
|
||||
actualReturnCode=$?
|
||||
}
|
||||
@ -311,7 +322,9 @@ declare -r testInputFile=${opt_testCase/%.txt/.input.tmp}
|
||||
declare -r testExpectationFile=${opt_testCase/%.txt/.expected.tmp}
|
||||
declare -r testFilterFile=${opt_testCase/%.txt/.sed.tmp}
|
||||
declare -r testOutputFile=${opt_testCase/%.txt/.out.tmp}
|
||||
declare -r testErrorFile=${opt_testCase/%.txt/.err.tmp}
|
||||
declare -r boxesArgs=$(sed -n '/^:ARGS/,+1p' < "${opt_testCase}" | grep -v ^:INPUT | sed '1d' | tr -d '\r')
|
||||
declare discardStderr=false
|
||||
|
||||
arrange_environment
|
||||
arrange_test_fixtures
|
||||
@ -328,6 +341,7 @@ rm "${testInputFile}"
|
||||
rm "${testFilterFile}"
|
||||
rm "${testExpectationFile}"
|
||||
rm "${testOutputFile}"
|
||||
rm -f "${testErrorFile}"
|
||||
|
||||
echo " OK"
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user