Prepare for prewarm testing

This commit is contained in:
Kovid Goyal 2022-06-06 15:59:34 +05:30
parent 98f6e24106
commit a6aff817cf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -192,12 +192,17 @@ class BaseTest(TestCase):
class PTY:
def __init__(self, argv, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20, cwd=None, env=None):
def __init__(self, argv=None, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20, cwd=None, env=None):
if isinstance(argv, str):
argv = shlex.split(argv)
self.write_buf = b''
if argv is None:
from kitty.child import openpty
self.master_fd, self.slave_fd = openpty()
self.is_child = False
else:
pid, self.master_fd = fork()
self.is_child = pid == CHILD
self.write_buf = b''
if self.is_child:
while read_screen_size().width != columns * cell_width:
time.sleep(0.01)
@ -268,9 +273,10 @@ class PTY:
if not q():
raise TimeoutError(f'The condition was not met. Screen contents: \n {repr(self.screen_contents())}')
def set_window_size(self, rows=25, columns=80):
def set_window_size(self, rows=25, columns=80, send_signal=True):
if hasattr(self, 'screen'):
self.screen.resize(rows, columns)
if send_signal:
x_pixels = columns * self.cell_width
y_pixels = rows * self.cell_height
s = struct.pack('HHHH', rows, columns, x_pixels, y_pixels)