From ecf53a146c4a4d9b132fb770cdfc3649fcdf4a14 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 11 Apr 2018 22:12:38 +0000 Subject: [PATCH] Wait for the "output" event. --- tests/system_tests/test_main.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/system_tests/test_main.py b/tests/system_tests/test_main.py index 4c10d8f7..8da49039 100644 --- a/tests/system_tests/test_main.py +++ b/tests/system_tests/test_main.py @@ -211,15 +211,34 @@ class LifecycleTests(TestsBase, unittest.TestCase): self.assertEqual(out, b'') def test_launch_ptvsd_client(self): + lock, wait = get_locked_and_waiter() + + def handle_msg(msg): + if msg.type != 'event': + return False + if msg.event != 'output': + return False + lock.release() + return True argv = [] lockfile = self.workspace.lockfile() done, waitscript = lockfile.wait_in_script() filename = self.write_script('spam.py', waitscript) script = self.write_debugger_script(filename, 9876, run_as='script') with DebugClient(port=9876) as editor: - adapter, session = editor.host_local_debugger(argv, script) + adapter, session = editor.host_local_debugger( + argv, + script, + handlers=[ + (handle_msg, "event 'output'"), + ], + ) + # TODO: There's a race with the initial "output" event. + wait(reason="event 'output'") + (req_initialize, req_launch, req_config ) = lifecycle_handshake(session, 'launch') + done() adapter.wait()