From df8e326e39dae8edea29c4be962d5937c393d72a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 17 Jun 2025 14:29:01 -0400 Subject: [PATCH] Add `debugging/subactor_bp_in_ctx.py` test set It's been in the debug scripts quite a while without a wrapping test and will be, - only the 2nd such REPL test which uses a lower-level `@context` ep-API - the first official and explicit use of `enable_transports=['uds']` a suite. Deats, - flip to 'uds' tpt and 'devx' level logging in the script. - add a new 2-case suite `test_ctxep_pauses_n_maybe_ipc_breaks` which validates both the quit-early (via `BdbQuit`) and channel-dropped-need-to-ctlc cases from a single test fn. --- examples/debugging/subactor_bp_in_ctx.py | 3 + tests/devx/test_debugger.py | 89 ++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/examples/debugging/subactor_bp_in_ctx.py b/examples/debugging/subactor_bp_in_ctx.py index 2c5fee8c..f55d2cd4 100644 --- a/examples/debugging/subactor_bp_in_ctx.py +++ b/examples/debugging/subactor_bp_in_ctx.py @@ -33,8 +33,11 @@ async def just_bp( async def main(): + async with tractor.open_nursery( debug_mode=True, + enable_transports=['uds'], + loglevel='devx', ) as n: p = await n.start_actor( 'bp_boi', diff --git a/tests/devx/test_debugger.py b/tests/devx/test_debugger.py index b9f3d9a1..6179ef01 100644 --- a/tests/devx/test_debugger.py +++ b/tests/devx/test_debugger.py @@ -10,10 +10,14 @@ TODO: - wonder if any of it'll work on OS X? """ +from __future__ import annotations from functools import partial import itertools import platform import time +from typing import ( + TYPE_CHECKING, +) import pytest from pexpect.exceptions import ( @@ -34,6 +38,9 @@ from .conftest import ( assert_before, ) +if TYPE_CHECKING: + from ..conftest import PexpectSpawner + # TODO: The next great debugger audit could be done by you! # - recurrent entry to breakpoint() from single actor *after* and an # error in another task? @@ -1062,6 +1069,88 @@ def test_shield_pause( child.expect(EOF) +@pytest.mark.parametrize( + 'quit_early', [False, True] +) +def test_ctxep_pauses_n_maybe_ipc_breaks( + spawn: PexpectSpawner, + quit_early: bool, +): + ''' + Audit generator embedded `.pause()`es from within a `@context` + endpoint with a chan close at the end, requiring that ctl-c is + mashed and zombie reaper kills sub with no hangs. + + ''' + child = spawn('subactor_bp_in_ctx') + child.expect(PROMPT) + + # 3 iters for the `gen()` pause-points + for i in range(3): + assert_before( + child, + [ + _pause_msg, + "('bp_boi'", # actor name + "