Skip to content

Commit 2610573

Browse files
committed
Fix zsh integration test on CI
Also, add various other robustness improvements to the test
1 parent a43f610 commit 2610573

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

.github/workflows/ci.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def install_deps():
3838
' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev zsh'
3939
' libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev librsync-dev uuid-dev'
4040
' zsh bash dash fish')
41+
# for some reason these directories are world writable which causes zsh
42+
# compinit to break
43+
run('sudo chmod -R og-w /usr/share/zsh')
4144
if is_bundle:
4245
install_bundle()
4346
else:

kitty_tests/shell_integration.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import unittest
99
from contextlib import contextmanager
1010

11-
from kitty.constants import terminfo_dir
11+
from kitty.constants import kitty_base_dir, terminfo_dir
1212
from kitty.fast_data_types import CURSOR_BEAM
1313
from kitty.shell_integration import setup_zsh_env
1414

@@ -22,24 +22,28 @@ def safe_env_for_running_shell(home_dir, rc='', shell='zsh'):
2222
'TERM': 'xterm-kitty',
2323
'TERMINFO': terminfo_dir,
2424
'KITTY_SHELL_INTEGRATION': 'enabled',
25+
'KITTY_INSTALLATION_DIR': kitty_base_dir,
2526
}
27+
for x in ('USER', 'LANG'):
28+
if os.environ.get(x):
29+
ans[x] = os.environ[x]
2630
if shell == 'zsh':
2731
ans['ZLE_RPROMPT_INDENT'] = '0'
2832
with open(os.path.join(home_dir, '.zshenv'), 'w') as f:
2933
print('unset GLOBAL_RCS', file=f)
3034
with open(os.path.join(home_dir, '.zshrc'), 'w') as f:
31-
print(rc, file=f)
35+
print(rc + '\n', file=f)
3236
setup_zsh_env(ans)
3337
return ans
3438

3539

3640
class ShellIntegration(BaseTest):
3741

3842
@contextmanager
39-
def run_shell(self, shell='zsh', rc=''):
43+
def run_shell(self, shell='zsh', rc='', cmd='{shell} -il'):
4044
home_dir = os.path.realpath(tempfile.mkdtemp())
4145
try:
42-
pty = self.create_pty(f'{shell} -il', cwd=home_dir, env=safe_env_for_running_shell(home_dir, rc))
46+
pty = self.create_pty(cmd.format(**locals()), cwd=home_dir, env=safe_env_for_running_shell(home_dir, rc))
4347
i = 10
4448
while i > 0 and not pty.screen_contents().strip():
4549
pty.process_input_from_child()
@@ -66,4 +70,5 @@ def test_zsh_integration(self):
6670
self.ae(pty.callbacks.titlebuf, '~')
6771
pty.send_cmd_to_child('mkdir test && ls -a')
6872
pty.wait_till(lambda: pty.screen_contents().count(ps1) == 2)
69-
self.ae(pty.last_cmd_output(), str(pty.screen.line(1)))
73+
q = '\n'.join(str(pty.screen.line(i)) for i in range(1, pty.screen.cursor.y))
74+
self.ae(pty.last_cmd_output(), q)

test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import os
66
import sys
77
import warnings
8-
from tempfile import TemporaryDirectory
98
from contextlib import contextmanager
9+
from tempfile import TemporaryDirectory
1010
from typing import Iterator
1111

1212
base = os.path.dirname(os.path.abspath(__file__))

0 commit comments

Comments
 (0)