Fix test failure with fish >= 4.1

fish now requires a response to a DA1 query
This commit is contained in:
Kovid Goyal
2025-09-29 14:01:57 +05:30
parent 7a71db8830
commit 2f991691f9
2 changed files with 16 additions and 5 deletions

View File

@@ -138,7 +138,10 @@ class Callbacks:
self.bell_count += 1
def on_da1(self) -> None:
self.da1.append(da1(get_options()))
payload = da1(get_options())
self.da1.append(payload)
if self.pty and self.pty.needs_da1:
self.pty.send_da1_response(payload)
def on_activity_since_last_focus(self) -> None:
pass
@@ -279,10 +282,13 @@ class BaseTest(TestCase):
def create_pty(
self, argv=None, cols=80, lines=100, scrollback=100, cell_width=10, cell_height=20,
options=None, cwd=None, env=None, stdin_fd=None, stdout_fd=None
options=None, cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=False,
):
self.set_options(options)
return PTY(argv, lines, cols, scrollback, cell_width, cell_height, cwd, env, stdin_fd=stdin_fd, stdout_fd=stdout_fd)
return PTY(
argv, lines, cols, scrollback, cell_width, cell_height, cwd, env, stdin_fd=stdin_fd, stdout_fd=stdout_fd,
needs_da1=needs_da1,
)
def assertEqualAttributes(self, c1, c2):
x1, y1, c1.x, c1.y = c1.x, c1.y, 0, 0
@@ -315,7 +321,7 @@ class PTY:
def __init__(
self, argv=None, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20,
cwd=None, env=None, stdin_fd=None, stdout_fd=None
cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=False,
):
self.is_child = False
if isinstance(argv, str):
@@ -353,6 +359,7 @@ class PTY:
self.cell_width = cell_width
self.cell_height = cell_height
self.set_window_size(rows=rows, columns=columns)
self.needs_da1 = needs_da1
self.callbacks = Callbacks(self)
self.screen = Screen(self.callbacks, rows, columns, scrollback, cell_width, cell_height, 0, self.callbacks)
self.received_bytes = b''
@@ -385,6 +392,9 @@ class PTY:
if flush:
self.process_input_from_child(0)
def send_da1_response(self, data: str) -> None:
self.write_to_child('\x1b[' + data, flush=True)
def send_cmd_to_child(self, cmd, flush=False):
self.callbacks.last_cmd_exit_status = sys.maxsize
self.last_cmd = cmd