From 37377e822044dc13ad020ed5c2927bc3c49b75f7 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 11 Jun 2025 19:32:56 -0400 Subject: [PATCH] Prevent `test_breakpoint_hook_restored` subproc hangs If the underlying example script fails (say due to a console output pattern-mismatch, `AssertionError`) the `pexpect` managed subproc with a `debug_mode=True` crash-handling-REPL engaged will ofc *not terminate* due to any SIGINT sent by the test harnesss (since we shield from it as part of normal sub-actor debugger operation). So instead always send a 'continue' cmd to the active `PdbREPL`'s stdin so it deactivates and allows the py-script-process to raise and terminate, unblocking the `pexpect.spawn`'s internal subproc joiner (which would otherwise hang without manual intervention, blocking downstream tests..). Also, use the new `PexpectSpawner` type alias after actually importing future annots.. XD --- tests/devx/conftest.py | 1 + tests/devx/test_tooling.py | 37 +++++++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/tests/devx/conftest.py b/tests/devx/conftest.py index 30393c92..9a5c90a5 100644 --- a/tests/devx/conftest.py +++ b/tests/devx/conftest.py @@ -2,6 +2,7 @@ `tractor.devx.*` tooling sub-pkg test space. ''' +from __future__ import annotations import time from typing import ( Callable, diff --git a/tests/devx/test_tooling.py b/tests/devx/test_tooling.py index 2debe3f7..c1bb8692 100644 --- a/tests/devx/test_tooling.py +++ b/tests/devx/test_tooling.py @@ -13,9 +13,13 @@ TODO: when debugging a problem inside the stack vs. in their app. ''' +from __future__ import annotations import os import signal import time +from typing import ( + TYPE_CHECKING, +) from .conftest import ( expect, @@ -29,9 +33,12 @@ from pexpect.exceptions import ( EOF, ) +if TYPE_CHECKING: + from ..conftest import PexpectSpawner + def test_shield_pause( - spawn, + spawn: PexpectSpawner, ): ''' Verify the `tractor.pause()/.post_mortem()` API works inside an @@ -126,7 +133,7 @@ def test_shield_pause( def test_breakpoint_hook_restored( - spawn, + spawn: PexpectSpawner, ): ''' Ensures our actor runtime sets a custom `breakpoint()` hook @@ -140,16 +147,22 @@ def test_breakpoint_hook_restored( child = spawn('restore_builtin_breakpoint') child.expect(PROMPT) - assert_before( - child, - [ - _pause_msg, - "