From cac8014f151d30dc29fe99acbcbb746493d477b0 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Mon, 21 Mar 2022 22:43:55 +0100 Subject: [PATCH] Fix truncate grahic placing and reduce summary to two lines --- test/test_rdlink.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/test_rdlink.sh b/test/test_rdlink.sh index 375d3a3..baab27b 100755 --- a/test/test_rdlink.sh +++ b/test/test_rdlink.sh @@ -42,14 +42,22 @@ tocompete=() rl::printPath() { local testnum="${1:-0}" local input="${2:-"-"}" + local truncate_graphic= + local inputwidth=${config_path_width} if (( flag_extendedOutput )); then printf -- "%-3d Inp: %-${config_path_width}s ---" ${testnum} "${input}" else # 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 - printf "%b%${config_path_width}s" "${truncate_graphic}" "${input}" + printf "%b%${inputwidth}s" "${truncate_graphic}" "${input}" fi } @@ -58,18 +66,11 @@ rl::printTestSummary() { local failed=${2:-0} local skipped=${3:-0} local total=$(( success + failed + skipped )) - local separator="--------------------" + readonly columnwidth=7 + readonly tableformat="%${columnwidth}s | %${columnwidth}s | %${columnwidth}s | %${columnwidth}s\n" - cat < @@ -81,7 +82,6 @@ rl::testcmp() { local actual="${4:-"-"}" local testresult=0 #failed local testresult_graphic="${color_red}✗${color_less}" # alt. symbol ≠ - local truncate_graphic= if [[ "${expect}" == "${actual}" ]] ; then # Don't print success for this flag