Fix zsh integration test on CI
Also, add various other robustness improvements to the test
This commit is contained in:
parent
a43f610555
commit
261057396c
3
.github/workflows/ci.py
vendored
3
.github/workflows/ci.py
vendored
@ -38,6 +38,9 @@ def install_deps():
|
|||||||
' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev zsh'
|
' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev zsh'
|
||||||
' libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev librsync-dev uuid-dev'
|
' libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev librsync-dev uuid-dev'
|
||||||
' zsh bash dash fish')
|
' zsh bash dash fish')
|
||||||
|
# for some reason these directories are world writable which causes zsh
|
||||||
|
# compinit to break
|
||||||
|
run('sudo chmod -R og-w /usr/share/zsh')
|
||||||
if is_bundle:
|
if is_bundle:
|
||||||
install_bundle()
|
install_bundle()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from kitty.constants import terminfo_dir
|
from kitty.constants import kitty_base_dir, terminfo_dir
|
||||||
from kitty.fast_data_types import CURSOR_BEAM
|
from kitty.fast_data_types import CURSOR_BEAM
|
||||||
from kitty.shell_integration import setup_zsh_env
|
from kitty.shell_integration import setup_zsh_env
|
||||||
|
|
||||||
@ -22,13 +22,17 @@ def safe_env_for_running_shell(home_dir, rc='', shell='zsh'):
|
|||||||
'TERM': 'xterm-kitty',
|
'TERM': 'xterm-kitty',
|
||||||
'TERMINFO': terminfo_dir,
|
'TERMINFO': terminfo_dir,
|
||||||
'KITTY_SHELL_INTEGRATION': 'enabled',
|
'KITTY_SHELL_INTEGRATION': 'enabled',
|
||||||
|
'KITTY_INSTALLATION_DIR': kitty_base_dir,
|
||||||
}
|
}
|
||||||
|
for x in ('USER', 'LANG'):
|
||||||
|
if os.environ.get(x):
|
||||||
|
ans[x] = os.environ[x]
|
||||||
if shell == 'zsh':
|
if shell == 'zsh':
|
||||||
ans['ZLE_RPROMPT_INDENT'] = '0'
|
ans['ZLE_RPROMPT_INDENT'] = '0'
|
||||||
with open(os.path.join(home_dir, '.zshenv'), 'w') as f:
|
with open(os.path.join(home_dir, '.zshenv'), 'w') as f:
|
||||||
print('unset GLOBAL_RCS', file=f)
|
print('unset GLOBAL_RCS', file=f)
|
||||||
with open(os.path.join(home_dir, '.zshrc'), 'w') as f:
|
with open(os.path.join(home_dir, '.zshrc'), 'w') as f:
|
||||||
print(rc, file=f)
|
print(rc + '\n', file=f)
|
||||||
setup_zsh_env(ans)
|
setup_zsh_env(ans)
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
@ -36,10 +40,10 @@ def safe_env_for_running_shell(home_dir, rc='', shell='zsh'):
|
|||||||
class ShellIntegration(BaseTest):
|
class ShellIntegration(BaseTest):
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def run_shell(self, shell='zsh', rc=''):
|
def run_shell(self, shell='zsh', rc='', cmd='{shell} -il'):
|
||||||
home_dir = os.path.realpath(tempfile.mkdtemp())
|
home_dir = os.path.realpath(tempfile.mkdtemp())
|
||||||
try:
|
try:
|
||||||
pty = self.create_pty(f'{shell} -il', cwd=home_dir, env=safe_env_for_running_shell(home_dir, rc))
|
pty = self.create_pty(cmd.format(**locals()), cwd=home_dir, env=safe_env_for_running_shell(home_dir, rc))
|
||||||
i = 10
|
i = 10
|
||||||
while i > 0 and not pty.screen_contents().strip():
|
while i > 0 and not pty.screen_contents().strip():
|
||||||
pty.process_input_from_child()
|
pty.process_input_from_child()
|
||||||
@ -66,4 +70,5 @@ RPS1="{rps1}"
|
|||||||
self.ae(pty.callbacks.titlebuf, '~')
|
self.ae(pty.callbacks.titlebuf, '~')
|
||||||
pty.send_cmd_to_child('mkdir test && ls -a')
|
pty.send_cmd_to_child('mkdir test && ls -a')
|
||||||
pty.wait_till(lambda: pty.screen_contents().count(ps1) == 2)
|
pty.wait_till(lambda: pty.screen_contents().count(ps1) == 2)
|
||||||
self.ae(pty.last_cmd_output(), str(pty.screen.line(1)))
|
q = '\n'.join(str(pty.screen.line(i)) for i in range(1, pty.screen.cursor.y))
|
||||||
|
self.ae(pty.last_cmd_output(), q)
|
||||||
|
|||||||
2
test.py
2
test.py
@ -5,8 +5,8 @@ import importlib
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from tempfile import TemporaryDirectory
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
from typing import Iterator
|
from typing import Iterator
|
||||||
|
|
||||||
base = os.path.dirname(os.path.abspath(__file__))
|
base = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user