From 896ff890d8306ce76bddc20738be34514ec96305 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 12 Jan 2025 13:14:38 +0000 Subject: [PATCH] Adjustments to reduce false positives on slow systems. --- tests/Display_-_--numeric_--bytes.test | 13 ++++++++----- tests/Terminal_-_Detect_width.test | 9 +++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/Display_-_--numeric_--bytes.test b/tests/Display_-_--numeric_--bytes.test index 7b3bc0b..f9d6d82 100755 --- a/tests/Display_-_--numeric_--bytes.test +++ b/tests/Display_-_--numeric_--bytes.test @@ -18,18 +18,21 @@ dd if=/dev/zero bs=500 count=1 2>/dev/null \ lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9') finalLine=$(sed -n '$p' < "${workFile1}") -# The number of output lines should be >8 and <13, and the final byte count +# The number of output lines should be >6 and <13, and the final byte count # should be 500. # -if ! test "${lineCount}" -gt 8; then - echo "fewer than 9 output lines (${lineCount})" +if ! test "${lineCount}" -gt 6; then + echo "fewer than 7 output lines (${lineCount}):" + cat "${workFile1}" exit 1 fi if ! test "${lineCount}" -lt 13; then - echo "more than 12 output lines (${lineCount})" + echo "more than 12 output lines (${lineCount}):" + cat "${workFile1}" exit 1 fi if ! test "${finalLine}" = "500"; then - echo "final byte count was not 500 (${finalLine})" + echo "final byte count was not 500 (${finalLine}):" + cat "${workFile1}" exit 1 fi diff --git a/tests/Terminal_-_Detect_width.test b/tests/Terminal_-_Detect_width.test index 7955326..8fbcbdf 100755 --- a/tests/Terminal_-_Detect_width.test +++ b/tests/Terminal_-_Detect_width.test @@ -37,6 +37,7 @@ runInTerminal () { # tmux 1.8 doesn't have "resize-window" echo "resize-pane -x ${terminalWidth} -y 5" echo "pipe-pane 'cat > ${workFile1}'" + sleep 0.5 echo "respawn-pane -k \"${commandToRun}\"" sleep "${secondsToWait}" echo "kill-server" @@ -51,7 +52,7 @@ runInTerminal () { # longest number of characters seen between "[" and "]". # runWidthTest () { - runInTerminal "$1" 1 "${testSubject} -pSs 1K /dev/null" \ + runInTerminal "$1" "$2" "${testSubject} -pSs 1K /dev/null" \ | tr '\r' '\n' \ | sed -n 's/^.*\[//;s/\].*$//p' \ | awk 'BEGIN {m=0} {n=length($0); m=(n>m?n:m)} END {print m}' @@ -64,7 +65,11 @@ runWidthTest () { # widthTest () { terminalWidth="$1" - longestBar=$(runWidthTest "${terminalWidth}") + longestBar=$(runWidthTest "${terminalWidth}" 1) + # Retry test with longer delay, if null result. + if test -z "${longestBar}" || test "${longestBar}" -eq 0; then + longestBar=$(runWidthTest "${terminalWidth}" 5) + fi if test -z "${longestBar}"; then echo "no output from test at width=${terminalWidth}" exit 1