Fix truncate grahic placing and reduce summary to two lines

This commit is contained in:
2022-03-21 22:43:55 +01:00
parent 333e226871
commit cac8014f15

View File

@@ -42,14 +42,22 @@ tocompete=()
rl::printPath() { rl::printPath() {
local testnum="${1:-0}" local testnum="${1:-0}"
local input="${2:-"-"}" local input="${2:-"-"}"
local truncate_graphic=
local inputwidth=${config_path_width}
if (( flag_extendedOutput )); then if (( flag_extendedOutput )); then
printf -- "%-3d Inp: %-${config_path_width}s ---" ${testnum} "${input}" printf -- "%-3d Inp: %-${config_path_width}s ---" ${testnum} "${input}"
else else
# Truncate input string on the left if longer than $config_path_width # Truncate input string on the left if longer than $config_path_width
(( ${#input} > ${config_path_width} )) && input="${input:$(( ${#input} - ${config_path_width} + 1 ))}" && truncate_graphic="✀" if (( ${#input} > ${config_path_width} )) ; then
# +1 : prepending truncate_graphic
input="${input:$(( ${#input} - ${config_path_width} + 1 ))}"
# -1 : prepending truncate_graphic
inputwidth=$((config_path_width - 1))
truncate_graphic="✀"
fi
# Print input and expected # Print input and expected
printf "%b%${config_path_width}s" "${truncate_graphic}" "${input}" printf "%b%${inputwidth}s" "${truncate_graphic}" "${input}"
fi fi
} }
@@ -58,18 +66,11 @@ rl::printTestSummary() {
local failed=${2:-0} local failed=${2:-0}
local skipped=${3:-0} local skipped=${3:-0}
local total=$(( success + failed + skipped )) local total=$(( success + failed + skipped ))
local separator="--------------------" readonly columnwidth=7
readonly tableformat="%${columnwidth}s | %${columnwidth}s | %${columnwidth}s | %${columnwidth}s\n"
cat <<TEST_SUMMARY_EOF printf "\n# Result : ${tableformat}" "success" "failed" "skipped" "total"
printf " ${tableformat}" "${success}" "${failed}" "${skipped}" "${total}"
# Test summary:
successful: ${success}
failed: ${failed}
skipped: ${skipped}
TEST_SUMMARY_EOF
printf "%15s-%s\n" "------" "${separator:0:${#total}}"
printf "%15s %d\n" "total:" ${total}
} }
# rl::testcmp <TEST NUMBER> <TEST INPUT> <EXPECTED RESULT> <ACTUAL RESULT> # rl::testcmp <TEST NUMBER> <TEST INPUT> <EXPECTED RESULT> <ACTUAL RESULT>
@@ -81,7 +82,6 @@ rl::testcmp() {
local actual="${4:-"-"}" local actual="${4:-"-"}"
local testresult=0 #failed local testresult=0 #failed
local testresult_graphic="${color_red}${color_less}" # alt. symbol ≠ local testresult_graphic="${color_red}${color_less}" # alt. symbol ≠
local truncate_graphic=
if [[ "${expect}" == "${actual}" ]] ; then if [[ "${expect}" == "${actual}" ]] ; then
# Don't print success for this flag # Don't print success for this flag