Regression test fixes.

This commit is contained in:
Nicholas Marriott
2026-07-06 11:22:56 +01:00
parent 37e4b3cdb6
commit 069201dd1a
5 changed files with 213 additions and 98 deletions

View File

@@ -52,7 +52,7 @@ wait_for()
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
if echo "$CAPTURED" | grep -q "$1"; then
if printf '%s\n' "$CAPTURED" | grep -F -q "$1"; then
return 0
fi
sleep 0.2
@@ -61,6 +61,23 @@ wait_for()
fail "timed out waiting for '$1'"
}
# wait_gone $marker
#
# Wait (up to ~10s) until the rendered screen no longer contains $marker.
wait_gone()
{
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
if ! printf '%s\n' "$CAPTURED" | grep -F -q "$1"; then
return 0
fi
sleep 0.2
i=$((i + 1))
done
fail "timed out waiting for '$1' to disappear"
}
# wait_count $marker $n
#
# Wait (up to ~10s) until exactly $n rendered lines contain $marker. The
@@ -70,7 +87,7 @@ wait_count()
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
c=$(echo "$CAPTURED" | grep -c "$1")
c=$(printf '%s\n' "$CAPTURED" | grep -F -c "$1")
[ "$c" -eq "$2" ] && return 0
sleep 0.2
i=$((i + 1))
@@ -129,11 +146,15 @@ wait_mode()
exit_mode()
{
marker=$1
shift
$TMUX send-keys -t aaa:0 "$@" || fail "send-keys $* failed"
wait_mode aaa:0 0
wait_gone "$marker"
}
$TMUX new-session -d -s aaa -x 80 -y 24 || exit 1
$TMUX new-session -d -s aaa -x 80 -y 24 'cat' || exit 1
$TMUX2 new-session -d -s out -x 80 -y 24 "$TMUX attach -t aaa" || exit 1
wait_clients 1 || fail "no client attached to test server"
@@ -146,28 +167,36 @@ $TMUX set-buffer -b bufz "other buffer" || exit 1
$TMUX choose-buffer -t aaa:0 -F 'B1' -f '#{==:#{buffer_name},bufa}' || exit 1
wait_count ': B1' 1
out=$CAPTURED
echo "$out" | grep -q 'bufa: B1' || fail "bufa missing when it matches"
echo "$out" | grep -q 'bufz: B1' && fail "bufz shown but does not match"
[ "$(echo "$out" | grep -c ': B1')" -eq 1 ] || fail "expected 1 buffer"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'bufa: B1' || \
fail "bufa missing when it matches"
printf '%s\n' "$out" | grep -F -q 'bufz: B1' && \
fail "bufz shown but does not match"
[ "$(printf '%s\n' "$out" | grep -F -c ': B1')" -eq 1 ] || \
fail "expected 1 buffer"
exit_mode ': B1' q
# --- filter by buffer content ------------------------------------------------
$TMUX choose-buffer -t aaa:0 -F 'B2' -f '#{m:*hello*,#{buffer_sample}}' || \
exit 1
wait_count ': B2' 1
out=$CAPTURED
echo "$out" | grep -q 'bufa: B2' || fail "bufa missing when content matches"
echo "$out" | grep -q 'bufz: B2' && fail "bufz shown but content not matched"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'bufa: B2' || \
fail "bufa missing when content matches"
printf '%s\n' "$out" | grep -F -q 'bufz: B2' && \
fail "bufz shown but content not matched"
exit_mode ': B2' q
# --- no filter shows both buffers ---------------------------------------------
$TMUX choose-buffer -t aaa:0 -F 'B3' || exit 1
wait_count ': B3' 2
out=$CAPTURED
echo "$out" | grep -q 'bufa: B3' || fail "bufa missing with no filter"
echo "$out" | grep -q 'bufz: B3' || fail "bufz missing with no filter"
[ "$(echo "$out" | grep -c ': B3')" -eq 2 ] || fail "expected 2 buffers"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'bufa: B3' || \
fail "bufa missing with no filter"
printf '%s\n' "$out" | grep -F -q 'bufz: B3' || \
fail "bufz missing with no filter"
[ "$(printf '%s\n' "$out" | grep -F -c ': B3')" -eq 2 ] || \
fail "expected 2 buffers"
exit_mode ': B3' q
# --- filter matching nothing ---------------------------------------------------
#
@@ -176,25 +205,30 @@ $TMUX choose-buffer -t aaa:0 -F 'B4' -f '#{==:#{buffer_name},nosuch}' || \
exit 1
wait_count ': B4' 2
out=$CAPTURED
echo "$out" | grep -q 'bufa: B4' || fail "bufa missing with no-match filter"
echo "$out" | grep -q 'bufz: B4' || fail "bufz missing with no-match filter"
echo "$out" | grep -q 'no matches' || fail "no matches indicator missing"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'bufa: B4' || \
fail "bufa missing with no-match filter"
printf '%s\n' "$out" | grep -F -q 'bufz: B4' || \
fail "bufz missing with no-match filter"
printf '%s\n' "$out" | grep -F -q 'no matches' || \
fail "no matches indicator missing"
exit_mode ': B4' q
# --- sort orders ---------------------------------------------------------------
#
# By name bufa sorts first and -r reverses.
$TMUX choose-buffer -t aaa:0 -F 'B5' -O name || exit 1
wait_count ': B5' 2
echo "$CAPTURED" | grep ': B5' | head -1 | grep -q 'bufa: B5' || \
printf '%s\n' "$CAPTURED" | grep -F ': B5' | head -1 | \
grep -F -q 'bufa: B5' || \
fail "bufa not first with -O name"
exit_mode q
exit_mode ': B5' q
$TMUX choose-buffer -t aaa:0 -F 'B6' -O name -r || exit 1
wait_count ': B6' 2
echo "$CAPTURED" | grep ': B6' | head -1 | grep -q 'bufz: B6' || \
printf '%s\n' "$CAPTURED" | grep -F ': B6' | head -1 | \
grep -F -q 'bufz: B6' || \
fail "bufz not first with -O name -r"
exit_mode q
exit_mode ': B6' q
# --- d deletes the selected buffer --------------------------------------------
#
@@ -203,9 +237,9 @@ $TMUX choose-buffer -t aaa:0 -F 'G1' -f '#{==:#{buffer_name},bufz}' || exit 1
wait_for 'bufz: G1'
$TMUX send-keys -t aaa:0 d
wait_buffers 1
$TMUX list-buffers -F '#{buffer_name}' | grep -q 'bufa' || \
$TMUX list-buffers -F '#{buffer_name}' | grep -F -q 'bufa' || \
fail "wrong buffer deleted"
exit_mode q
exit_mode ': G1' q
# --- C-t tags all buffers and D deletes the tagged ------------------------------
$TMUX set-buffer -b bufz "other buffer" || exit 1
@@ -214,7 +248,8 @@ $TMUX choose-buffer -t aaa:0 -F 'G2' || exit 1
wait_count ': G2' 3
$TMUX send-keys -t aaa:0 C-t D
wait_buffers 0
exit_mode q
wait_mode aaa:0 0
wait_gone ': G2'
# --- Enter runs the default command (paste-buffer) ------------------------------
#
@@ -223,10 +258,11 @@ exit_mode q
$TMUX set-buffer -b bufa "hello buffer" || exit 1
$TMUX choose-buffer -t aaa:0 -F 'G3' || exit 1
wait_count ': G3' 1
exit_mode Enter
exit_mode ': G3' Enter
i=0
while [ "$i" -lt 50 ]; do
$TMUX capture-pane -p -t aaa:0 | grep -q 'hello buffer' && break
$TMUX capture-pane -p -t aaa:0 | grep -F -q 'hello buffer' && \
break
sleep 0.2
i=$((i + 1))
done

View File

@@ -51,7 +51,7 @@ wait_for()
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
if echo "$CAPTURED" | grep -q "$1"; then
if printf '%s\n' "$CAPTURED" | grep -F -q "$1"; then
return 0
fi
sleep 0.2
@@ -60,6 +60,23 @@ wait_for()
fail "timed out waiting for '$1'"
}
# wait_gone $marker
#
# Wait (up to ~10s) until the rendered screen no longer contains $marker.
wait_gone()
{
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
if ! printf '%s\n' "$CAPTURED" | grep -F -q "$1"; then
return 0
fi
sleep 0.2
i=$((i + 1))
done
fail "timed out waiting for '$1' to disappear"
}
# wait_count $marker $n
#
# Wait (up to ~10s) until exactly $n rendered lines contain $marker. The
@@ -69,7 +86,7 @@ wait_count()
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
c=$(echo "$CAPTURED" | grep -c "$1")
c=$(printf '%s\n' "$CAPTURED" | grep -F -c "$1")
[ "$c" -eq "$2" ] && return 0
sleep 0.2
i=$((i + 1))
@@ -113,15 +130,19 @@ wait_mode()
exit_mode()
{
marker=$1
shift
$TMUX send-keys -t aaa:0 "$@" || fail "send-keys $* failed"
wait_mode aaa:0 0
wait_gone "$marker"
}
# One client attached to each of two sessions; the mode is displayed on the
# client attached to aaa (in window 0 of the outer server) and the filters
# tell the clients apart by their attached session.
$TMUX new-session -d -s aaa -x 80 -y 24 || exit 1
$TMUX new-session -d -s bbb -x 80 -y 24 || exit 1
$TMUX new-session -d -s aaa -x 80 -y 24 'cat' || exit 1
$TMUX new-session -d -s bbb -x 80 -y 24 'cat' || exit 1
$TMUX2 new-session -d -s out -x 80 -y 24 "$TMUX attach -t aaa" || exit 1
$TMUX2 new-window -d -t out: "$TMUX attach -t bbb" || exit 1
@@ -132,29 +153,38 @@ $TMUX choose-client -t aaa:0 -F 'C1=#{client_session}' \
-f '#{==:#{client_session},aaa}' || exit 1
wait_count 'C1=' 1
out=$CAPTURED
echo "$out" | grep -q 'C1=aaa' || fail "aaa client missing when it matches"
echo "$out" | grep -q 'C1=bbb' && fail "bbb client shown but does not match"
[ "$(echo "$out" | grep -c 'C1=')" -eq 1 ] || fail "expected 1 client"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'C1=aaa' || \
fail "aaa client missing when it matches"
printf '%s\n' "$out" | grep -F -q 'C1=bbb' && \
fail "bbb client shown but does not match"
[ "$(printf '%s\n' "$out" | grep -F -c 'C1=')" -eq 1 ] || \
fail "expected 1 client"
exit_mode 'C1=' q
# --- filter keeping only the bbb client -------------------------------------
$TMUX choose-client -t aaa:0 -F 'C2=#{client_session}' \
-f '#{==:#{client_session},bbb}' || exit 1
wait_count 'C2=' 1
out=$CAPTURED
echo "$out" | grep -q 'C2=bbb' || fail "bbb client missing when it matches"
echo "$out" | grep -q 'C2=aaa' && fail "aaa client shown but does not match"
[ "$(echo "$out" | grep -c 'C2=')" -eq 1 ] || fail "expected 1 client"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'C2=bbb' || \
fail "bbb client missing when it matches"
printf '%s\n' "$out" | grep -F -q 'C2=aaa' && \
fail "aaa client shown but does not match"
[ "$(printf '%s\n' "$out" | grep -F -c 'C2=')" -eq 1 ] || \
fail "expected 1 client"
exit_mode 'C2=' q
# --- no filter shows both clients -------------------------------------------
$TMUX choose-client -t aaa:0 -F 'C3=#{client_session}' || exit 1
wait_count 'C3=' 2
out=$CAPTURED
echo "$out" | grep -q 'C3=aaa' || fail "aaa client missing with no filter"
echo "$out" | grep -q 'C3=bbb' || fail "bbb client missing with no filter"
[ "$(echo "$out" | grep -c 'C3=')" -eq 2 ] || fail "expected 2 clients"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'C3=aaa' || \
fail "aaa client missing with no filter"
printf '%s\n' "$out" | grep -F -q 'C3=bbb' || \
fail "bbb client missing with no filter"
[ "$(printf '%s\n' "$out" | grep -F -c 'C3=')" -eq 2 ] || \
fail "expected 2 clients"
exit_mode 'C3=' q
# --- filter matching nothing ------------------------------------------------
#
@@ -163,10 +193,13 @@ $TMUX choose-client -t aaa:0 -F 'C4=#{client_session}' \
-f '#{==:#{client_session},nosuch}' || exit 1
wait_count 'C4=' 2
out=$CAPTURED
echo "$out" | grep -q 'C4=aaa' || fail "aaa client missing with no-match filter"
echo "$out" | grep -q 'C4=bbb' || fail "bbb client missing with no-match filter"
echo "$out" | grep -q 'no matches' || fail "no matches indicator missing"
exit_mode q
printf '%s\n' "$out" | grep -F -q 'C4=aaa' || \
fail "aaa client missing with no-match filter"
printf '%s\n' "$out" | grep -F -q 'C4=bbb' || \
fail "bbb client missing with no-match filter"
printf '%s\n' "$out" | grep -F -q 'no matches' || \
fail "no matches indicator missing"
exit_mode 'C4=' q
# --- Enter runs the default command (detach-client) --------------------------
#
@@ -178,6 +211,7 @@ wait_for 'G1=bbb'
$TMUX send-keys -t aaa:0 Enter || fail "send-keys Enter failed"
wait_clients 1 || fail "bbb client did not detach"
wait_mode aaa:0 0
wait_gone 'G1='
[ "$($TMUX list-clients -F '#{client_session}')" = "aaa" ] || \
fail "wrong client detached"

View File

@@ -59,7 +59,7 @@ wait_for()
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
if echo "$CAPTURED" | grep -q "$1"; then
if printf '%s\n' "$CAPTURED" | grep -F -q "$1"; then
return 0
fi
sleep 0.2
@@ -68,15 +68,15 @@ wait_for()
fail "timed out waiting for '$1'"
}
# wait_count $marker $n
# wait_count $row-marker $n
#
# Wait (up to ~10s) until exactly $n rendered lines contain $marker.
# Wait (up to ~10s) until exactly $n rendered list rows contain $row-marker.
wait_count()
{
i=0
while [ "$i" -lt 50 ]; do
CAPTURED=$(capture)
c=$(echo "$CAPTURED" | grep -c "$1")
c=$(printf '%s\n' "$CAPTURED" | grep -F -c "$1")
[ "$c" -eq "$2" ] && return 0
sleep 0.2
i=$((i + 1))
@@ -131,10 +131,10 @@ exit_mode()
#
# 0 zzz 1 window 0 2 pane 0 3 pane 1 4 window 1 5 pane 0
# 6 aaa 7 window 0 8 pane 0
$TMUX new-session -d -s zzz -x 80 -y 24 || exit 1
$TMUX split-window -t zzz:0 || exit 1
$TMUX new-window -t zzz || exit 1
$TMUX new-session -d -s aaa -x 80 -y 24 || exit 1
$TMUX new-session -d -s zzz -x 80 -y 24 'cat' || exit 1
$TMUX split-window -t zzz:0 'cat' || exit 1
$TMUX new-window -t zzz 'cat' || exit 1
$TMUX new-session -d -s aaa -x 80 -y 24 'cat' || exit 1
$TMUX2 new-session -d -s out -x 80 -y 24 "$TMUX attach -t aaa" || exit 1
wait_clients 1 || fail "no client attached to test server"
@@ -145,10 +145,12 @@ wait_clients 1 || fail "no client attached to test server"
# regression - its two-pane window 0. aaa contributes exactly three lines
# (session, window, pane).
$TMUX choose-tree -t aaa:0 -F 'F1' -f '#{==:#{session_name},aaa}' || exit 1
wait_count 'F1' 3
wait_count ': F1' 3
out=$CAPTURED
echo "$out" | grep -q 'aaa: F1' || fail "aaa missing when filter matches it"
echo "$out" | grep -q 'zzz: F1' && fail "zzz shown but no pane matches"
printf '%s\n' "$out" | grep -F -q 'aaa: F1' || \
fail "aaa missing when filter matches it"
printf '%s\n' "$out" | grep -F -q 'zzz: F1' && \
fail "zzz shown but no pane matches"
exit_mode q
# --- filter keeping only zzz ------------------------------------------------
@@ -156,10 +158,12 @@ exit_mode q
# zzz contributes six lines (session, two windows, three panes); aaa must
# disappear.
$TMUX choose-tree -t aaa:0 -F 'F2' -f '#{==:#{session_name},zzz}' || exit 1
wait_count 'F2' 6
wait_count ': F2' 6
out=$CAPTURED
echo "$out" | grep -q 'zzz: F2' || fail "zzz missing when filter matches it"
echo "$out" | grep -q 'aaa: F2' && fail "aaa shown but no pane matches"
printf '%s\n' "$out" | grep -F -q 'zzz: F2' || \
fail "zzz missing when filter matches it"
printf '%s\n' "$out" | grep -F -q 'aaa: F2' && \
fail "aaa shown but no pane matches"
exit_mode q
# --- filter matching a single pane ------------------------------------------
@@ -167,22 +171,28 @@ exit_mode q
# Only pane 1 of zzz:0 matches, so the tree is exactly session zzz, window 0
# and that pane; zzz:1 and all of aaa must disappear.
$TMUX choose-tree -t aaa:0 -F 'F3' -f '#{==:#{pane_index},1}' || exit 1
wait_count 'F3' 3
wait_count ': F3' 3
out=$CAPTURED
echo "$out" | grep -q 'zzz: F3' || fail "zzz missing when its pane matches"
echo "$out" | grep -q 'aaa: F3' && fail "aaa shown but no pane matches"
echo "$out" | grep -q '1: F3' || fail "matching pane missing"
printf '%s\n' "$out" | grep -F -q 'zzz: F3' || \
fail "zzz missing when its pane matches"
printf '%s\n' "$out" | grep -F -q 'aaa: F3' && \
fail "aaa shown but no pane matches"
printf '%s\n' "$out" | grep -F -q '1: F3' || \
fail "matching pane missing"
exit_mode q
# --- filter matching nothing ------------------------------------------------
#
# Everything is shown and the filter indicator reports no matches.
$TMUX choose-tree -t aaa:0 -F 'F4' -f '#{==:#{session_name},nosuch}' || exit 1
wait_count 'F4' 9
wait_count ': F4' 9
out=$CAPTURED
echo "$out" | grep -q 'aaa: F4' || fail "aaa missing with no-match filter"
echo "$out" | grep -q 'zzz: F4' || fail "zzz missing with no-match filter"
echo "$out" | grep -q 'no matches' || fail "no matches indicator missing"
printf '%s\n' "$out" | grep -F -q 'aaa: F4' || \
fail "aaa missing with no-match filter"
printf '%s\n' "$out" | grep -F -q 'zzz: F4' || \
fail "zzz missing with no-match filter"
printf '%s\n' "$out" | grep -F -q 'no matches' || \
fail "no matches indicator missing"
exit_mode q
# --- -h with the tree pane as the only match --------------------------------
@@ -191,28 +201,32 @@ exit_mode q
# match, so session and window aaa stay listed: two lines, no pane line.
$TMUX choose-tree -h -t aaa:0 -F 'F5' -f '#{==:#{session_name},aaa}' || \
exit 1
wait_count 'F5' 2
echo "$CAPTURED" | grep -q 'aaa: F5' || fail "aaa missing with -h"
wait_count ': F5' 2
printf '%s\n' "$CAPTURED" | grep -F -q 'aaa: F5' || \
fail "aaa missing with -h"
exit_mode q
# --- sort orders ------------------------------------------------------------
#
# By index zzz (created first) sorts first, by name aaa does, and -r reverses.
$TMUX choose-tree -t aaa:0 -F 'F6' -O index || exit 1
wait_count 'F6' 9
echo "$CAPTURED" | grep 'F6' | head -1 | grep -q 'zzz: F6' || \
wait_count ': F6' 9
printf '%s\n' "$CAPTURED" | grep -F ': F6' | head -1 | \
grep -F -q 'zzz: F6' || \
fail "zzz not first with -O index"
exit_mode q
$TMUX choose-tree -t aaa:0 -F 'F7' -O name || exit 1
wait_count 'F7' 9
echo "$CAPTURED" | grep 'F7' | head -1 | grep -q 'aaa: F7' || \
wait_count ': F7' 9
printf '%s\n' "$CAPTURED" | grep -F ': F7' | head -1 | \
grep -F -q 'aaa: F7' || \
fail "aaa not first with -O name"
exit_mode q
$TMUX choose-tree -t aaa:0 -F 'F8' -O name -r || exit 1
wait_count 'F8' 9
echo "$CAPTURED" | grep 'F8' | head -1 | grep -q 'zzz: F8' || \
wait_count ': F8' 9
printf '%s\n' "$CAPTURED" | grep -F ': F8' | head -1 | \
grep -F -q 'zzz: F8' || \
fail "zzz not first with -O name -r"
exit_mode q
@@ -221,33 +235,35 @@ exit_mode q
# g moves to the top (session zzz); h collapses it, hiding its five children;
# l expands it again.
$TMUX choose-tree -t aaa:0 -F 'G1' -O index || exit 1
wait_count 'G1' 9
wait_count ': G1' 9
$TMUX send-keys -t aaa:0 g h || fail "send-keys collapse failed"
wait_count 'G1' 4
wait_count ': G1' 4
$TMUX send-keys -t aaa:0 l || fail "send-keys expand failed"
wait_count 'G1' 9
wait_count ': G1' 9
exit_mode q
# --- filter entered at the prompt with f, cleared with c ----------------------
$TMUX choose-tree -t aaa:0 -F 'G2' -O index || exit 1
wait_count 'G2' 9
wait_count ': G2' 9
$TMUX send-keys -t aaa:0 f || fail "send-keys f failed"
$TMUX send-keys -t aaa:0 -l '#{==:#{session_name},aaa}' || \
fail "send-keys filter failed"
$TMUX send-keys -t aaa:0 Enter || fail "send-keys Enter failed"
wait_count 'G2' 3
wait_count ': G2' 3
out=$CAPTURED
echo "$out" | grep -q 'aaa: G2' || fail "aaa missing with prompt filter"
echo "$out" | grep -q 'zzz: G2' && fail "zzz shown with prompt filter"
printf '%s\n' "$out" | grep -F -q 'aaa: G2' || \
fail "aaa missing with prompt filter"
printf '%s\n' "$out" | grep -F -q 'zzz: G2' && \
fail "zzz shown with prompt filter"
$TMUX send-keys -t aaa:0 c || fail "send-keys c failed"
wait_count 'G2' 9
wait_count ': G2' 9
exit_mode q
# --- Enter runs the default command (switch-client) ----------------------------
#
# g selects session zzz and Enter switches the client to it.
$TMUX choose-tree -t aaa:0 -F 'G3' -O index || exit 1
wait_count 'G3' 9
wait_count ': G3' 9
$TMUX send-keys -t aaa:0 g Enter || fail "send-keys Enter failed"
i=0
while [ "$i" -lt 50 ]; do
@@ -265,11 +281,11 @@ wait_mode aaa:0 0
# g and four times j select window 1 of zzz; x asks for confirmation and y
# kills it, leaving zzz with one window and the tree with seven lines.
$TMUX choose-tree -t aaa:0 -F 'G4' -O index || exit 1
wait_count 'G4' 9
wait_count ': G4' 9
$TMUX send-keys -t aaa:0 g j j j j x || fail "send-keys x failed"
wait_for 'Kill window 1'
$TMUX send-keys -t aaa:0 y || fail "send-keys y failed"
wait_count 'G4' 7
wait_count ': G4' 7
[ "$($TMUX list-windows -t zzz -F x | grep -c x)" -eq 1 ] || \
fail "window 1 of zzz not killed"
exit_mode q

View File

@@ -49,7 +49,13 @@ tmux_run()
name=$1
shift
out=$(run_cmd $TMUX "$@" 2>&1)
out=$(
if command -v timeout >/dev/null 2>&1; then
timeout 10 $TMUX "$@" 2>&1
else
$TMUX "$@" 2>&1
fi
)
rc=$?
bounded "$name" "$out"
[ "$rc" -eq 0 ] || fail "$name failed: $out"
@@ -58,7 +64,13 @@ tmux_run()
capture()
{
out=$(run_cmd $TMUX2 capture-pane -p -t out:0 2>/dev/null)
out=$(
if command -v timeout >/dev/null 2>&1; then
timeout 10 $TMUX2 capture-pane -p -t out:0 2>/dev/null
else
$TMUX2 capture-pane -p -t out:0 2>/dev/null
fi
)
rc=$?
bounded "capture-pane" "$out"
[ "$rc" -eq 0 ] || fail "capture-pane failed"
@@ -67,7 +79,14 @@ capture()
capture_esc()
{
out=$(run_cmd $TMUX2 capture-pane -pe -t out:0 2>/dev/null)
out=$(
if command -v timeout >/dev/null 2>&1; then
timeout 10 $TMUX2 capture-pane -pe -t out:0 \
2>/dev/null
else
$TMUX2 capture-pane -pe -t out:0 2>/dev/null
fi
)
rc=$?
bounded "capture-pane -e" "$out"
[ "$rc" -eq 0 ] || fail "capture-pane -e failed"

View File

@@ -8,20 +8,30 @@ PATH=/bin:/usr/bin
TERM=screen
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
TMP=$(mktemp -d) || exit 1
TMUX_TMPDIR="$TMP"
export TMUX_TMPDIR
TMUX="$TEST_TMUX -Ltest -f/dev/null"
TMUX2="$TEST_TMUX -Ltest2 -f/dev/null"
TMUX="$TEST_TMUX -Lmode-mutation-$$ -f/dev/null"
TMUX2="$TEST_TMUX -Lmode-mutation-outer-$$ -f/dev/null"
cleanup()
cleanup_servers()
{
$TMUX kill-server 2>/dev/null
$TMUX2 kill-server 2>/dev/null
sleep 0.5
}
cleanup()
{
cleanup_servers
rm -rf "$TMP"
}
trap cleanup EXIT
fail()
{
echo "$1"
echo "$1" >&2
cleanup
exit 1
}
@@ -53,7 +63,7 @@ wait_for()
{
i=0
while [ "$i" -lt 50 ]; do
capture | grep -q "$1" && return 0
capture | grep -F -q "$1" && return 0
sleep 0.2
i=$((i + 1))
done
@@ -95,7 +105,7 @@ start_client()
s=$1
cmd=${2:-cat}
cleanup
cleanup_servers
$TMUX new-session -d -s "$s" -n main -x 80 -y 24 "$cmd" || \
fail "$s: new-session failed"
$TMUX2 new-session -d -s out -x 80 -y 24 "$TMUX attach -t $s" || \
@@ -287,7 +297,7 @@ test_copy_mode()
assert_alive "copy-mode exit"
}
cleanup
cleanup_servers
test_choose_tree
test_choose_buffer
test_choose_client