Use sub tests for the various prewarm things

This commit is contained in:
Kovid Goyal 2022-07-13 18:57:07 +05:30
parent cb5157f2d1
commit cb0d23bae8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -78,25 +78,24 @@ def socket_child_main(exit_code=0, initial_print=''):
with suppress(AttributeError):
self.assertEqual(os.waitstatus_to_exitcode(status), exit_code, pty.screen_contents())
# signal delivery tests are pretty flakey on CI so give up on them
if not self.is_ci: # signal delivery tests are pretty flakey on CI so give up on them
with self.subTest(msg='test SIGINT via signal to wrapper'):
pty = self.create_pty(
argv=[kitty_exe(), '+runpy', src + 'socket_child_main(initial_print="child ready:")'], cols=cols, env=env, cwd=cwd)
pty.wait_till(lambda: 'child ready:' in pty.screen_contents())
os.kill(pty.child_pid, signal.SIGINT)
pty.wait_till(lambda: 'KeyboardInterrupt' in pty.screen_contents())
wait_for_death(signal.SIGINT)
# # test SIGINT via signal to wrapper
# pty = self.create_pty(
# argv=[kitty_exe(), '+runpy', src + 'socket_child_main(initial_print="child ready:")'], cols=cols, env=env, cwd=cwd)
# pty.wait_till(lambda: 'child ready:' in pty.screen_contents())
# os.kill(pty.child_pid, signal.SIGINT)
# pty.wait_till(lambda: 'KeyboardInterrupt' in pty.screen_contents())
# wait_for_death(signal.SIGINT)
#
# # test SIGINT via Ctrl-c
# pty = self.create_pty(
# argv=[kitty_exe(), '+runpy', src + 'socket_child_main(initial_print="child ready:")'], cols=cols, env=env, cwd=cwd)
# pty.wait_till(lambda: 'child ready:' in pty.screen_contents())
# pty.write_to_child('\x03', flush=True)
# pty.wait_till(lambda: 'KeyboardInterrupt' in pty.screen_contents())
# wait_for_death(signal.SIGINT)
with self.subTest(msg='test SIGINT via Ctrl-c'):
pty = self.create_pty(
argv=[kitty_exe(), '+runpy', src + 'socket_child_main(initial_print="child ready:")'], cols=cols, env=env, cwd=cwd)
pty.wait_till(lambda: 'child ready:' in pty.screen_contents())
pty.write_to_child('\x03', flush=True)
pty.wait_till(lambda: 'KeyboardInterrupt' in pty.screen_contents())
wait_for_death(signal.SIGINT)
# test SIGWINCH handling
with self.subTest(msg='test SIGWINCH handling'):
pty = self.create_pty(
argv=[kitty_exe(), '+runpy', src + 'socket_child_main(initial_print="child ready:")'], cols=cols, env=env, cwd=cwd)
pty.wait_till(lambda: 'child ready:' in pty.screen_contents())
@ -104,7 +103,7 @@ def socket_child_main(exit_code=0, initial_print=''):
pty.wait_till(lambda: f'Screen size changed: {cols + 3}' in pty.screen_contents())
os.close(pty.master_fd)
# test passing of data via cwd, env vars and stdin/stdout redirection
with self.subTest(msg='test passing of data via cwd, env vars and stdin/stdout redirection'):
stdin_r, stdin_w = os.pipe()
os.set_inheritable(stdin_w, False)
stdout_r, stdout_w = os.pipe()