Fix and re-enable test_reattach.

This commit is contained in:
Pavel Minaev 2019-12-03 13:14:48 -08:00 committed by Pavel Minaev
parent 4df532c601
commit c545ccb5f8
2 changed files with 14 additions and 15 deletions

View file

@ -246,11 +246,8 @@ class Session(object):
pass
self.disconnect(force=True)
if self.adapter_endpoints is not None:
log.info(
"Waiting for {0} to close listener ports ...",
self.adapter_id,
)
if self.adapter_endpoints is not None and self.expected_exit_code is not None:
log.info("Waiting for {0} to close listener ports ...", self.adapter_id)
while self.adapter_endpoints.check():
time.sleep(0.1)
@ -337,7 +334,9 @@ class Session(object):
cwd = compat.filename_str(cwd) if isinstance(cwd, py.path.local) else cwd
env = self._make_env(self.spawn_debuggee.env, codecov=False)
env["PTVSD_ADAPTER_ENDPOINTS"] = self.adapter_endpoints = self.tmpdir / "adapter_endpoints"
env["PTVSD_ADAPTER_ENDPOINTS"] = self.adapter_endpoints = (
self.tmpdir / "adapter_endpoints"
)
if debug_me is not None:
env["PTVSD_TEST_DEBUG_ME"] = debug_me
@ -375,10 +374,7 @@ class Session(object):
os.close(fd)
def wait_for_enable_attach(self):
log.info(
"Waiting for {0} to open the IDE listener socket...",
self.adapter_id,
)
log.info("Waiting for {0} to open the IDE listener socket...", self.adapter_id)
while not self.adapter_endpoints.check():
time.sleep(0.1)

View file

@ -88,8 +88,7 @@ def test_attach_api(pyfile, target, wait_for_attach, is_attached, stop_method):
session.request_continue()
@pytest.mark.parametrize("run", runners.all_attach)
@pytest.mark.skip(reason="https://github.com/microsoft/ptvsd/issues/1802")
@pytest.mark.parametrize("run", runners.all_attach_by_socket)
def test_reattach(pyfile, target, run):
@pyfile
def code_to_debug():
@ -106,24 +105,28 @@ def test_reattach(pyfile, target, run):
object() # @second
with debug.Session() as session1:
session1.captured_output = None
session1.captured_output = set()
session1.expected_exit_code = None # not expected to exit on disconnect
with run(session1, target(code_to_debug)):
host, port = session1.config["host"], session1.config["port"]
pass
session1.wait_for_stop(expected_frames=[some.dap.frame(code_to_debug, "first")])
session1.disconnect()
with debug.Session() as session2:
session2.config.update(session1.config)
with session2.connect_to_adapter((host, port)):
if "host" in session2.config:
session2.connect_to_adapter((session2.config["host"], session2.config["port"]))
with session2.request_attach():
pass
session2.wait_for_stop(
expected_frames=[some.dap.frame(code_to_debug, "second")]
)
session2.scratchpad["exit"] = True
session2.request_continue()
def test_attach_by_pid(pyfile, target):