Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Fix and re-enable test_reattach.
Browse files Browse the repository at this point in the history
  • Loading branch information
int19h committed Dec 4, 2019
1 parent 4df532c commit c545ccb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
16 changes: 6 additions & 10 deletions tests/debug/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,8 @@ def __exit__(self, exc_type, exc_val, exc_tb):
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)

Expand Down Expand Up @@ -337,7 +334,9 @@ def spawn_debuggee(self, args, cwd=None, exe=sys.executable, debug_me=None):
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

Expand Down Expand Up @@ -375,10 +374,7 @@ def spawn_debuggee(self, args, cwd=None, exe=sys.executable, debug_me=None):
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)

Expand Down
13 changes: 8 additions & 5 deletions tests/ptvsd/server/test_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def code_to_debug():
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():
Expand All @@ -106,24 +105,28 @@ def code_to_debug():
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):
Expand Down

0 comments on commit c545ccb

Please sign in to comment.