From 94551623ec2c6efa5e8ba02bd702f84a5289c64d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 13 Jul 2022 19:14:59 +0530 Subject: [PATCH] Make JSON reading test a bit more robust --- kitty_tests/prewarm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kitty_tests/prewarm.py b/kitty_tests/prewarm.py index bf6449f6a..fbbfdf82a 100644 --- a/kitty_tests/prewarm.py +++ b/kitty_tests/prewarm.py @@ -47,7 +47,6 @@ def socket_child_main(exit_code=0, initial_print=''): 'font_family': get_options().font_family, 'cols': read_screen_size(fd=sys.stderr.fileno()).cols, 'stdin_data': sys.stdin.read(), - 'done': 'hello', } print(json.dumps(output, indent=2), file=sys.stderr, flush=True) @@ -114,7 +113,12 @@ def socket_child_main(exit_code=0, initial_print=''): stdin_data = 'testing--stdin-read' with open(stdin_w, 'w') as f: f.write(stdin_data) - pty.wait_till(lambda: 'hello' in pty.screen_contents()) + + def has_json(): + s = pty.screen_contents().strip() + return 'hello' in s and s.endswith('}') + + pty.wait_till(has_json) wait_for_death(exit_code) output = json.loads(pty.screen_contents().strip()) self.assertEqual(output['test_env'], env['TEST_ENV_PASS'])