Skip to content

Commit

Permalink
checks/tmux: Rationalize sleeps
Browse files Browse the repository at this point in the history
These are only really necessary before a capture-pane.

Also move the "2" tests into the regular ones to reduce the number of tests.
  • Loading branch information
faho committed Jan 14, 2025
1 parent 6b945bc commit 5a08bf0
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 55 deletions.
6 changes: 0 additions & 6 deletions tests/checks/tmux-abbr.fish
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,27 @@ isolated-tmux-start

# Expand abbreviations on space.
isolated-tmux send-keys abbr-test Space arg1 Enter
tmux-sleep
# CHECK: prompt {{\d+}}> abbr-test [expanded] arg1

# Expand abbreviations at the cursor when executing.
isolated-tmux send-keys abbr-test Enter
tmux-sleep
# CHECK: prompt {{\d+}}> abbr-test [expanded]

# Use Control+Z right after abbreviation expansion, to keep going without expanding.
isolated-tmux send-keys abbr-test Space C-z arg2 Enter
tmux-sleep
# CHECK: prompt {{\d+}}> abbr-test arg2

# Same with a redundant space; it does not expand abbreviations.
isolated-tmux send-keys C-u abbr-test Space C-z Space arg2 Enter
tmux-sleep
# CHECK: prompt {{\d+}}> abbr-test arg2

# Or use Control+Space ("bind -k nul") to the same effect.
isolated-tmux send-keys abbr-test C-Space arg3 Enter
tmux-sleep
# CHECK: prompt {{\d+}}> abbr-test arg3

# Do not expand abbrevation if the cursor is not at the command, even if it's just white space.
# This makes the behavior more consistent with the above two scenarios.
isolated-tmux send-keys abbr-test C-Space Enter
tmux-sleep
# CHECK: prompt {{\d+}}> abbr-test

# CHECK: prompt {{\d+}}>
Expand Down
4 changes: 1 addition & 3 deletions tests/checks/tmux-autosuggestion.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
isolated-tmux-start
isolated-tmux send-keys 'echo "foo bar baz"' Enter C-l
isolated-tmux send-keys 'echo '
tmux-sleep
isolated-tmux send-keys M-Right
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 1> echo "foo bar baz"
tmux-sleep

touch COMPL

Expand All @@ -25,7 +24,6 @@ isolated-tmux capture-pane -p
# CHECK: prompt 2> : ./COMPL

isolated-tmux send-keys C-u C-k C-l ': ./CO'
tmux-sleep
isolated-tmux send-keys A C-h
tmux-sleep
isolated-tmux capture-pane -p
Expand Down
12 changes: 9 additions & 3 deletions tests/checks/tmux-bind.fish
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ isolated-tmux capture-pane -p
# CHECK: echo abcde

isolated-tmux send-keys C-c
tmux-sleep
isolated-tmux send-keys C-l
isolated-tmux send-keys begin Enter 'echo 1' Enter e n d C-p 23
tmux-sleep
Expand All @@ -22,10 +21,17 @@ isolated-tmux capture-pane -p

# regression test
isolated-tmux send-keys C-c # not sure why we need to wait after this
tmux-sleep
isolated-tmux send-keys 'bind S begin-selection' Enter C-l
tmux-sleep
isolated-tmux send-keys 'echo one two threeS' C-u C-y
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 1> echo one two three

isolated-tmux send-keys "function prepend; commandline --cursor 0; commandline -i echo; end" Enter
isolated-tmux send-keys "bind ctrl-g prepend" Enter
isolated-tmux send-keys C-l
isolated-tmux send-keys 'printf'
isolated-tmux send-keys C-g Space
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 2> echo printf
13 changes: 0 additions & 13 deletions tests/checks/tmux-bind2.fish

This file was deleted.

15 changes: 7 additions & 8 deletions tests/checks/tmux-complete.fish
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ isolated-tmux capture-pane -p | sed -n '1p;$p'
# Canceling the pager removes the inserted completion, no matter what happens in the search field.
# The common prefix remains because it is inserted before the pager is shown.
isolated-tmux send-keys C-c
tmux-sleep
isolated-tmux send-keys C-l foo2 Space BTab b BSpace b Escape
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 3> foo2 aa

# Check that down-or-search works even when the pager is not selected.
isolated-tmux send-keys C-u foo2 Space Tab
tmux-sleep
isolated-tmux send-keys Down
tmux-sleep
isolated-tmux capture-pane -p
Expand All @@ -79,25 +77,21 @@ isolated-tmux capture-pane -p
# CHECK: prompt 5> foo2 aabc old-arg

isolated-tmux send-keys C-u 'echo suggest this' Enter C-l
tmux-sleep
isolated-tmux send-keys 'echo sug' C-w C-z
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 6> echo suggest this

isolated-tmux send-keys C-u 'bind ctrl-s forward-single-char' Enter C-l
isolated-tmux send-keys 'echo suggest thi'
tmux-sleep
isolated-tmux send-keys C-s
tmux-sleep
isolated-tmux send-keys C-s
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 7> echo suggest this

isolated-tmux send-keys C-u
isolated-tmux send-keys 'echo sugg' C-a
tmux-sleep
isolated-tmux send-keys C-e M-f Space nothing
tmux-sleep
isolated-tmux capture-pane -p
Expand All @@ -106,13 +100,18 @@ isolated-tmux capture-pane -p
isolated-tmux send-keys C-u 'bind \cs forward-char-passive' Enter C-l
isolated-tmux send-keys C-u 'bind \cb backward-char-passive' Enter C-l
isolated-tmux send-keys C-u 'echo do not accept this' Enter C-l
tmux-sleep
isolated-tmux send-keys 'echo do not accept thi' C-b C-b DC C-b C-s 'h'
tmux-sleep
isolated-tmux send-keys C-s C-s C-s 'x'
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 10> echo do not accept thix
isolated-tmux send-keys C-u C-l ': {*,' Tab Tab Space ,
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 10> : {*,cmake/ ,{{.*}}

isolated-tmux send-keys 'touch ~/"path with spaces"' Enter C-l \
'cat ~/space' Tab
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 11> cat ~/path\ with\ spaces
13 changes: 0 additions & 13 deletions tests/checks/tmux-complete2.fish

This file was deleted.

8 changes: 2 additions & 6 deletions tests/checks/tmux-history-search.fish
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ isolated-tmux-start

isolated-tmux send-keys 'true needle' Enter
# CHECK: prompt 0> true needle
tmux-sleep
isolated-tmux send-keys 'true hay ee hay' Enter
# CHECK: prompt 1> true hay ee hay
tmux-sleep
isolated-tmux send-keys C-p C-a M-f M-f M-f M-.
# CHECK: prompt 2> true hay needle hay
tmux-sleep
Expand All @@ -33,16 +31,17 @@ isolated-tmux capture-pane -p | grep 'prompt 2'

# When history pager fails to find a result, copy the search field to the command line.
isolated-tmux send-keys C-e C-u C-r "echo no such command in history"
tmux-sleep
isolated-tmux send-keys Enter
# CHECK: prompt 2> echo no such command in history
tmux-sleep
isolated-tmux capture-pane -p | grep 'prompt 2'
isolated-tmux send-keys C-c

isolated-tmux send-keys C-r hay/shmay
isolated-tmux send-keys C-w C-h
isolated-tmux send-keys Enter
# CHECK: prompt 2> true hay ee hay
tmux-sleep
isolated-tmux capture-pane -p | grep 'prompt 2>'
isolated-tmux send-keys C-c

Expand All @@ -52,17 +51,14 @@ tmux-sleep
isolated-tmux capture-pane -p
#CHECK: prompt 5> echo 2
isolated-tmux send-keys C-c
tmux-sleep

isolated-tmux send-keys "echo sdifjsdoifjsdoifj" Enter
tmux-sleep
isolated-tmux capture-pane -p | grep "^sdifjsdoifjsdoifj\|prompt 6>"
# CHECK: sdifjsdoifjsdoifj
# CHECK: prompt 6>
isolated-tmux send-keys C-e C-u C-r
tmux-sleep
isolated-tmux send-keys "echo sdifjsdoifjsdoifj"
tmux-sleep
isolated-tmux send-keys M-d # alt-d
tmux-sleep
isolated-tmux capture-pane -p | grep "(no matches)"
Expand Down
4 changes: 1 addition & 3 deletions tests/checks/tmux-job.fish
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ isolated-tmux-start

isolated-tmux send-keys \
"sleep 0.5 &" Enter
sleep 0.1
isolated-tmux send-keys \
"echo hello"
sleep 0.6
isolated-tmux send-keys Space world
sleep 0.1
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 0> sleep 0.5 &
# CHECK: prompt 0> echo hello
Expand Down
1 change: 1 addition & 0 deletions tests/checks/tmux-transient.fish
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set -g isolated_tmux_fish_extra_args -C '
'

isolated-tmux-start
tmux-sleep

isolated-tmux send-keys 'echo foo' Enter
tmux-sleep
Expand Down

0 comments on commit 5a08bf0

Please sign in to comment.