Fix tests.

This commit is contained in:
Nicholas Marriott
2026-10-07 09:08:33 +01:00
parent 3b20a0418a
commit 7b4d4074cf
2 changed files with 48 additions and 57 deletions

View File

@@ -100,14 +100,12 @@ $TMUX set -g status on || exit 1
sleep 0.5
check_drag 1 7
# Window and pane ranges on different status rows still dispatch Status
# bindings; a control range dispatches its Control binding.
# Window and pane ranges on different status rows still dispatch Ctrl-drag
# Status bindings; a control range dispatches its Ctrl-drag Control binding.
$TMUX set -g status 3 || exit 1
$TMUX set -g 'status-format[0]' '#[range=window|0]WINDOW WINDOW WINDOW#[norange]' || exit 1
$TMUX set -g 'status-format[1]' "#[range=pane|$BASE]PANE PANE PANE PANE#[norange]" || exit 1
$TMUX set -g 'status-format[2]' '#[range=control|0]CONTROL CONTROL CONTROL#[norange]' || exit 1
$TMUX bind -n MouseDown1Status set -g @status-range status || exit 1
$TMUX bind -n MouseDown1Control0 set -g @status-range control || exit 1
$TMUX bind -n C-MouseDrag1Status set -g @status-drag status || exit 1
$TMUX bind -n C-MouseDrag1Control0 set -g @status-drag control || exit 1
wait_status
@@ -117,11 +115,6 @@ for range in window pane control; do
want=status
[ "$range" = control ] && want=control
$TMUX set -g @status-range '' || exit 1
mouse 0 10 "$row" M
mouse 0 10 "$row" m
wait_option @status-range "$want"
$TMUX set -g @status-drag '' || exit 1
check_drag "$row" 9
wait_option @status-drag "$want"

View File

@@ -29,25 +29,7 @@ fail() {
exit 1
}
wait_for_panes() {
tries=0
while :; do
panes=$($TMUX2 list-panes -t"$window" -F '#{pane_dead}') || exit 1
case "$panes" in
*0*)
;;
*)
return
;;
esac
tries=$((tries + 1))
[ "$tries" -lt 100 ] || fail "timed out waiting for panes to exit"
sleep 0.1
done
}
compare() {
wait_for_panes
if [ -n "$GENERATE" ]; then
sleep 1
$TMUX capturep -p $2 >$TMP || exit 1
@@ -66,18 +48,35 @@ compare() {
fail "scene $1 differs from $RESULTS/$1.result"
}
wait_for_pids() {
for pid in $1; do
tries=0
while kill -0 "$pid" 2>/dev/null; do
tries=$((tries + 1))
[ "$tries" -lt 100 ] || \
fail "timed out waiting for pane $pid to exit"
sleep 0.05
done
done
}
# new_scene <width> <height>: fresh inner window of the given window size.
new_scene() {
if [ -n "$window" ]; then
pids=$($TMUX2 list-panes -t"$window" -F '#{pane_pid}') || exit 1
$TMUX2 killw -t"$window" || exit 1
wait_for_pids "$pids"
fi
window=$($TMUX2 neww -dP -F '#{window_id}' \
"sh -c 'printf base'") || exit 1
"sh -c 'printf base; exec sleep 100'") || exit 1
$TMUX2 selectw -t"$window" || exit 1
$TMUX2 killw -a -t"$window" || exit 1
$TMUX2 resizew -x$1 -y$2 || exit 1
}
# tile_2x2: split the current window into a 2x2 grid of tiled panes.
tile_2x2() {
C=""
C="sh -c 'exec sleep 100'"
$TMUX2 splitw -h "$C" || exit 1
$TMUX2 splitw -v "$C" || exit 1
$TMUX2 selectp -t0 || exit 1
@@ -87,13 +86,13 @@ tile_2x2() {
# fill_base_pattern: make clipped floating panes visibly cover every column.
fill_base_pattern() {
$TMUX2 respawnp -k "sh -c 'i=0; while [ \$i -lt 12 ]; do printf \"%02d:abcdefghijklmnopqrstuvwxyz0123456789\n\" \$i; i=\$((i + 1)); done'" || exit 1
$TMUX2 respawnp -k "sh -c 'i=0; while [ \$i -lt 12 ]; do printf \"%02d:abcdefghijklmnopqrstuvwxyz0123456789\n\" \$i; i=\$((i + 1)); done; exec sleep 100'" || exit 1
}
# fill_all_panes: make each pane visibly nonblank.
fill_all_panes() {
for pane in $($TMUX2 list-panes -F '#{pane_id}'); do
$TMUX2 respawnp -k -t "$pane" "sh -c 'i=0; while [ \$i -lt 5 ]; do printf \"TILE%02d abcdefghij\n\" \$i; i=\$((i + 1)); done'" || exit 1
$TMUX2 respawnp -k -t "$pane" "sh -c 'i=0; while [ \$i -lt 5 ]; do printf \"TILE%02d abcdefghij\n\" \$i; i=\$((i + 1)); done; exec sleep 100'" || exit 1
done
}
@@ -101,8 +100,7 @@ $TMUX kill-server 2>/dev/null
$TMUX2 kill-server 2>/dev/null
$TMUX2 new -d -x40 -y12 "sh -c 'printf base; exec sleep 100'" || exit 1
$TMUX2 set -g remain-on-exit on || exit 1
$TMUX2 set -g remain-on-exit-format "" || exit 1
window=
$TMUX2 set -g status off || exit 1
$TMUX2 set -g window-size manual || exit 1
$TMUX2 set -g pane-border-format " #{pane_title} " || exit 1
@@ -117,7 +115,7 @@ sleep 1
# Basic floating pane, well inside the window.
new_scene 40 12
$TMUX2 new-pane -x20 -y6 -X8 -Y3 "sh -c 'printf FLOAT'" || exit 1
$TMUX2 new-pane -x20 -y6 -X8 -Y3 "sh -c 'printf FLOAT; exec sleep 100'" || exit 1
compare floating-basic
# Floating pane with a title on its border. pane-border-status also draws the
@@ -127,71 +125,71 @@ new_scene 40 12
$TMUX2 setw pane-border-status top || exit 1
$TMUX2 selectp -t:.0 -T base || exit 1
$TMUX2 new-pane -x20 -y6 -X8 -Y2 -T title \
"sh -c 'printf FLOAT'" || exit 1
"sh -c 'printf FLOAT; exec sleep 100'" || exit 1
compare floating-title
# Larger floating pane with double border lines.
new_scene 40 12
$TMUX2 new-pane -x28 -y8 -X4 -Y1 -B double \
"sh -c 'printf FLOAT'" || exit 1
"sh -c 'printf FLOAT; exec sleep 100'" || exit 1
compare floating-border-double
# Larger floating pane with rounded border lines.
new_scene 40 12
$TMUX2 new-pane -x28 -y8 -X4 -Y1 -B rounded \
"sh -c 'printf FLOAT'" || exit 1
"sh -c 'printf FLOAT; exec sleep 100'" || exit 1
compare floating-border-rounded
# Floating pane with no border lines: redraw_mark_pane_borders returns early so
# the float has no border at all, only its (clipped) content over the base pane.
new_scene 40 12
$TMUX2 new-pane -x20 -y6 -X10 -Y3 -B none \
"sh -c 'printf NOBORDER'" || exit 1
"sh -c 'printf NOBORDER; exec sleep 100'" || exit 1
compare floating-noborder
# Floating pane positioned past the right and bottom edges: must clip.
new_scene 40 12
$TMUX2 new-pane -x20 -y6 -X30 -Y8 "sh -c 'printf CLIP'" || exit 1
$TMUX2 new-pane -x20 -y6 -X30 -Y8 "sh -c 'printf CLIP; exec sleep 100'" || exit 1
compare floating-clip-edge
# Window smaller than the client (outside area filled), with a floating pane
# that overlaps the boundary into the outside region.
new_scene 28 8
$TMUX2 new-pane -x16 -y5 -X18 -Y4 "sh -c 'printf OUT'" || exit 1
$TMUX2 new-pane -x16 -y5 -X18 -Y4 "sh -c 'printf OUT; exec sleep 100'" || exit 1
compare floating-outside
# Floating pane whose right border is exactly on the window right edge. The
# floating pane is clipped so the tiled pane's right border remains unbroken.
new_scene 28 8
$TMUX2 respawnp -k "sh -c 'i=0; while [ \$i -lt 8 ]; do printf \"%02d:abcdefghijklmnopq\n\" \$i; i=\$((i + 1)); done'" || exit 1
$TMUX2 new-pane -x10 -y5 -X19 -Y2 "sh -c 'printf EDGE'" || exit 1
$TMUX2 respawnp -k "sh -c 'i=0; while [ \$i -lt 8 ]; do printf \"%02d:abcdefghijklmnopq\n\" \$i; i=\$((i + 1)); done; exec sleep 100'" || exit 1
$TMUX2 new-pane -x10 -y5 -X19 -Y2 "sh -c 'printf EDGE; exec sleep 100'" || exit 1
compare floating-clip-window-edge
# Floating pane clipped at the top-left corner (negative offsets).
new_scene 40 12
$TMUX2 new-pane -x18 -y6 -X-4 -Y-2 "sh -c 'printf TL'" || exit 1
$TMUX2 new-pane -x18 -y6 -X-4 -Y-2 "sh -c 'printf TL; exec sleep 100'" || exit 1
compare floating-clip-topleft
# Floating panes clipped at each edge. The patterned base pane makes sure the
# clipped edge still obscures both content and borders underneath.
new_scene 40 12
fill_base_pattern
$TMUX2 new-pane -x20 -y6 -X-10 -Y3 "sh -c 'printf LEFT'" || exit 1
$TMUX2 new-pane -x20 -y6 -X-10 -Y3 "sh -c 'printf LEFT; exec sleep 100'" || exit 1
compare floating-clip-left
new_scene 40 12
fill_base_pattern
$TMUX2 new-pane -x20 -y6 -X30 -Y3 "sh -c 'printf RIGHT'" || exit 1
$TMUX2 new-pane -x20 -y6 -X30 -Y3 "sh -c 'printf RIGHT; exec sleep 100'" || exit 1
compare floating-clip-right
new_scene 40 12
fill_base_pattern
$TMUX2 new-pane -x20 -y6 -X10 -Y-3 "sh -c 'printf TOP'" || exit 1
$TMUX2 new-pane -x20 -y6 -X10 -Y-3 "sh -c 'printf TOP; exec sleep 100'" || exit 1
compare floating-clip-top
new_scene 40 12
fill_base_pattern
$TMUX2 new-pane -x20 -y6 -X10 -Y9 "sh -c 'printf BOTTOM'" || exit 1
$TMUX2 new-pane -x20 -y6 -X10 -Y9 "sh -c 'printf BOTTOM; exec sleep 100'" || exit 1
compare floating-clip-bottom
# Floating pane over a tiled 2x2 grid: the float draws a complete box and must
@@ -199,7 +197,7 @@ compare floating-clip-bottom
new_scene 40 12
tile_2x2
fill_all_panes
$TMUX2 new-pane -x16 -y6 -X11 -Y3 "sh -c 'printf FLT'" || exit 1
$TMUX2 new-pane -x16 -y6 -X11 -Y3 "sh -c 'printf FLT; exec sleep 100'" || exit 1
compare floating-over-tiled
# Same, but the float uses double border lines while the tiled panes use single:
@@ -208,13 +206,13 @@ new_scene 40 12
tile_2x2
fill_all_panes
$TMUX2 new-pane -x16 -y6 -X11 -Y3 -B double \
"sh -c 'printf FLT'" || exit 1
"sh -c 'printf FLT; exec sleep 100'" || exit 1
compare floating-over-tiled-double
# Two overlapping floating panes: the later (top) float draws over the earlier.
new_scene 40 12
$TMUX2 new-pane -x16 -y6 -X4 -Y2 "sh -c 'printf AAA'" || exit 1
$TMUX2 new-pane -x16 -y6 -X14 -Y6 "sh -c 'printf BBB'" || exit 1
$TMUX2 new-pane -x16 -y6 -X4 -Y2 "sh -c 'printf AAA; exec sleep 100'" || exit 1
$TMUX2 new-pane -x16 -y6 -X14 -Y6 "sh -c 'printf BBB; exec sleep 100'" || exit 1
compare floating-overlap
# Two floating panes with different per-pane configuration: one has its status on
@@ -223,11 +221,11 @@ compare floating-overlap
new_scene 40 12
$TMUX2 setw pane-border-format " #{pane_title} " || exit 1
$TMUX2 new-pane -x16 -y4 -X3 -Y1 -T one \
"sh -c 'printf ONE'" || exit 1
"sh -c 'printf ONE; exec sleep 100'" || exit 1
$TMUX2 set -p pane-border-status top || exit 1
$TMUX2 set -p pane-border-lines single || exit 1
$TMUX2 new-pane -x16 -y4 -X18 -Y6 -T two \
"sh -c 'printf TWO'" || exit 1
"sh -c 'printf TWO; exec sleep 100'" || exit 1
$TMUX2 set -p pane-border-status bottom || exit 1
$TMUX2 set -p pane-border-lines heavy || exit 1
compare floating-mixed-config
@@ -237,7 +235,7 @@ compare floating-mixed-config
new_scene 40 12
$TMUX2 setw pane-scrollbars on || exit 1
$TMUX2 setw pane-scrollbars-style "bg=black,fg=white,width=1,pad=0" || exit 1
$TMUX2 new-pane -x16 -y6 -X22 -Y3 "sh -c 'printf OVERSB'" || exit 1
$TMUX2 new-pane -x16 -y6 -X22 -Y3 "sh -c 'printf OVERSB; exec sleep 100'" || exit 1
compare floating-over-scrollbar -e
# Floating pane overlapping the client status line: the status line is not part
@@ -246,7 +244,7 @@ new_scene 40 11
$TMUX2 set status on || exit 1
$TMUX2 set status-position bottom || exit 1
$TMUX2 set status-format[0] "" || exit 1
$TMUX2 new-pane -x20 -y6 -X8 -Y7 "sh -c 'printf OVERST'" || exit 1
$TMUX2 new-pane -x20 -y6 -X8 -Y7 "sh -c 'printf OVERST; exec sleep 100'" || exit 1
compare floating-over-status
# A window left with only a floating pane: killing the single tiled pane removes
@@ -254,7 +252,7 @@ compare floating-over-status
# Use a visible fill character for the EMPTY cells around the float.
$TMUX2 set -g fill-character '#[acs]~' || exit 1
new_scene 40 12
$TMUX2 new-pane -x20 -y6 -X8 -Y3 "sh -c 'printf FLOAT'" || exit 1
$TMUX2 new-pane -x20 -y6 -X8 -Y3 "sh -c 'printf FLOAT; exec sleep 100'" || exit 1
tiled=$($TMUX2 list-panes -F '#{pane_floating_flag} #{pane_id}' | \
awk '$1==0{print $2; exit}') || exit 1
$TMUX2 kill-pane -t "$tiled" || exit 1