4 # Just stream the TAP output (sans extended syntax) if tput is missing
5 command -v tput >/dev
/null ||
exec grep -v "^begin "
7 header_pattern
='[0-9]+\.\.[0-9]+'
10 if [[ "$header" =~
$header_pattern ]]; then
16 count_column_width
=$
(( ${#count} * 2 + 2 ))
18 # If the first line isn't a TAP plan, print it and pass the rest through
19 printf "%s\n" "$header"
23 update_screen_width
() {
24 screen_width
="$(tput cols)"
25 count_column_left
=$
(( $screen_width - $count_column_width ))
28 trap update_screen_width WINCH
33 printf_with_truncation $
(( $count_column_left - 1 )) " %s" "$name"
35 go_to_column
$count_column_left
36 printf "%${#count}s/${count}" "$index"
42 printf " ✓ %s" "$name"
48 [ -z "$reason" ] || reason
=": $reason"
50 printf " - %s (skipped%s)" "$name" "$reason"
57 printf " ✗ %s" "$name"
68 printf "\n%d test%s" "$count" "$(plural "$count")"
70 printf ", %d failure%s" "$failures" "$(plural "$failures")"
72 if [ "$skipped" -gt 0 ]; then
73 printf ", %d skipped" "$skipped"
79 printf_with_truncation
() {
82 local string
="$(printf "$@
")"
84 if [ "${#string}" -gt "$width" ]; then
85 printf "%s..." "${string:0:$(( $width - 4 ))}"
93 printf "\x1B[%dG" $
(( $column + 1 ))
96 clear_to_end_of_line
() {
109 printf "\x1B[%d;%dm" $
(( 30 + $color )) "$( [ "$weight" = "bold
" ] && echo 1 || echo 22 )"
117 [ "$1" -eq 1 ] ||
echo "s"
123 _buffer
="${_buffer}$("$@
")"
127 printf "%s" "$_buffer"
138 while IFS
= read -r line
; do
142 name
="${line#* $index }"
147 skip_expr
="ok $index # skip (\(([^)]*)\))?"
148 if [[ "$line" =~
$skip_expr ]]; then
150 buffer skip
"${BASH_REMATCH[2]}"
160 buffer log
"${line:2}"