isolated-tmux to more reliably initialize and other fixes

Prior to this change, tmux based tests would call 'isolated-tmux' which would
initialize tmux on first call, an admitted "evil hack." Switch to requiring
an explicit call to 'isolated-tmux-start' which then defines 'isolated-tmux'
and other functions. Add some loop-until-prompt logic into
'isolated-tmux-start'. This improves reliability of the tmux tests on systems
under load; at least it makes the tests pass in the background on my Mac.

Remove the '$sleep' variable, to be replaced with 'tmux-sleep'.
This commit is contained in:
ridiculousfish 2021-09-24 08:07:17 -07:00
parent 13fd3f7a76
commit 0562e599a6
4 changed files with 22 additions and 25 deletions

View file

@ -1,9 +1,11 @@
#RUN: %fish %s
#REQUIRES: command -v tmux
isolated-tmux-start
# Test moving around with up-or-search on a multi-line commandline.
isolated-tmux send-keys 'echo 12' M-Enter 'echo ab' C-p 345 C-n cde
$sleep
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 0> echo 12345
# CHECK: echo abcde

View file

@ -1,13 +1,13 @@
#RUN: %fish %s
#REQUIRES: command -v tmux
isolated-tmux
isolated-tmux-start
# Don't escape existing token (#7526).
echo >file-1
echo >file-2
isolated-tmux send-keys 'HOME=$PWD ls ~/' Tab
$sleep
tmux-sleep
isolated-tmux capture-pane -p
# Note the contents may or may not have the autosuggestion appended - it is a race.
# CHECK: prompt 0> HOME=$PWD ls ~/file-{{1?}}
@ -16,14 +16,14 @@ isolated-tmux capture-pane -p
# No pager on single smartcase completion (#7738).
isolated-tmux send-keys C-u C-l 'mkdir cmake CMakeFiles' Enter C-l \
'cat cmake' Tab
$sleep
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 1> cat cmake/
# Correct case in pager when prefixes differ in case (#7743).
isolated-tmux send-keys C-u C-l 'complete -c foo2 -a "aabc aaBd" -f' Enter C-l \
'foo2 A' Tab
$sleep
tmux-sleep
isolated-tmux capture-pane -p
# The "bc" part is the autosuggestion - we could use "capture-pane -e" to check colors.
# CHECK: prompt 2> foo2 aabc

View file

@ -8,20 +8,13 @@ set -g isolated_tmux_fish_extra_args -C '
end
'
# Start it up and loop a bit, until we get an initial prompt.
isolated-tmux
for i in seq 10
if string match -q '*prompt*' (isolated-tmux capture-pane -p)
break
end
sleep .5
end
isolated-tmux-start
isolated-tmux capture-pane -p
# CHECK: prompt 0> <>
set -q CI && set sleep sleep 10
set -U prompt_var changed
$sleep
tmux-sleep
isolated-tmux capture-pane -p
# CHECK: prompt 0> <changed>

View file

@ -1,14 +1,7 @@
function isolated-tmux --inherit-variable tmpdir
function isolated-tmux-start
set -l tmpdir (mktemp -d)
cd $tmpdir
set -g sleep sleep .1
set -q CI && set sleep sleep 1
# Evil hack - override ourselves, so we only run initialization once.
# We could do this outside the function, but then initialization is done too early for a
# command that wants to set $isolated_tmux_fish_extra_args first, like
# fish -C 'source tests/test_functions/isolated-tmux.fish' tests/checks/tmux-prompt.fish
function isolated-tmux --inherit-variable tmpdir
# tmux can't handle session sockets in paths that are too long, and macOS has a very long
# $TMPDIR, so use a relative path - except macOS doesn't have `realpath --relative-to`...
@ -26,6 +19,12 @@ function isolated-tmux --inherit-variable tmpdir
rm -r $tmpdir
end
function tmux-sleep
set -q CI
and sleep 1
or sleep .1
end
set -l fish (status fish-path)
isolated-tmux new-session -x 80 -y 10 -d $fish -C '
# This is similar to "tests/interactive.config".
@ -37,9 +36,12 @@ function isolated-tmux --inherit-variable tmpdir
# Set the correct permissions for the newly created socket to allow future connections.
# This is required at least under WSL or else each invocation will return a permissions error.
chmod 777 .tmux-socket
$sleep # Let fish draw a prompt.
if set -q argv[1]
isolated-tmux $argv
# Loop a bit, until we get an initial prompt.
for i in seq 25
if string match -q '*prompt*' (isolated-tmux capture-pane -p)
break
end
sleep .2
end
end