mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 00:41:15 -03:00
Extract setup and teardown for tmux tests
This was long overdue since the setup logic is much more complex than the actual tests. tmux-prompt.fish had extra logic to protect against XDG_CONFIG_HOME with leading double double-dot. I believe this is no longer necessary with the new test driver. We still use our own temp dir because we want to be able to run this independently of the test driver, This can be useful for debugging tests. For example we can insert a "$tmux attach" command in a test, and then run build/fish -C 'source tests/test_functions/isolated-tmux.fish' tests/checks/tmux-bind.fish This allows to inspect the state of the test and debug interactively. Attaching to the terminal doesn't work when running inside littlecheck because littlecheck consumes our output and doesn't give us a terminal. (Maybe there's an easy way to fix that?)
This commit is contained in:
@@ -1,39 +1,9 @@
|
||||
#RUN: %fish -C 'set -g fish %fish' %s
|
||||
#RUN: %fish %s
|
||||
#REQUIRES: command -v tmux
|
||||
|
||||
set fish (builtin realpath $fish)
|
||||
|
||||
# Isolated tmux.
|
||||
set -g tmpdir (mktemp -d)
|
||||
|
||||
# Don't CD elsewhere, because tmux socket file is relative to CWD. Using
|
||||
# absolute path to socket file is prone to 'socket file name too long' error.
|
||||
cd $tmpdir
|
||||
|
||||
set -g tmux tmux -S .tmux-socket -f /dev/null
|
||||
|
||||
set -g sleep sleep .1
|
||||
set -q CI && set sleep sleep 1
|
||||
|
||||
|
||||
$tmux new-session -x 80 -y 10 -d $fish -C '
|
||||
# This is similar to "tests/interactive.config".
|
||||
function fish_greeting; end
|
||||
function fish_prompt; printf "prompt $status_generation> "; end
|
||||
# No autosuggestion from older history.
|
||||
set fish_history ""
|
||||
'
|
||||
# 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.
|
||||
|
||||
# Test moving around with up-or-search on a multi-line commandline.
|
||||
$tmux send-keys 'echo 12' M-Enter 'echo ab' C-p 345 C-n cde
|
||||
isolated-tmux send-keys 'echo 12' M-Enter 'echo ab' C-p 345 C-n cde
|
||||
$sleep
|
||||
$tmux capture-pane -p
|
||||
isolated-tmux capture-pane -p
|
||||
# CHECK: prompt 0> echo 12345
|
||||
# CHECK: echo abcde
|
||||
|
||||
$tmux kill-server
|
||||
rm -r $tmpdir
|
||||
|
||||
Reference in New Issue
Block a user