Adjust `test_shield_pause` for capsys backends
Under `main_thread_forkserver` the bootstrapping hook switches to `--capture=sys`, so subactor fd-level output (tree dumps, zombie-reaper msgs) isn't captured per-test by pexpect. Gate those expects behind a `no_capfd` check so the test passes on both capture modes. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codesubint_forkserver_backend
parent
72a0465c52
commit
5a9926fc32
|
|
@ -52,6 +52,8 @@ def test_shield_pause(
|
||||||
...,
|
...,
|
||||||
PexpectSpawner,
|
PexpectSpawner,
|
||||||
],
|
],
|
||||||
|
start_method: str,
|
||||||
|
request: pytest.FixtureRequest,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Verify the `tractor.pause()/.post_mortem()` API works inside an
|
Verify the `tractor.pause()/.post_mortem()` API works inside an
|
||||||
|
|
@ -119,6 +121,21 @@ def test_shield_pause(
|
||||||
# (above) and `end-of-('hanger'` (below).
|
# (above) and `end-of-('hanger'` (below).
|
||||||
handle_out_of_order: bool = False
|
handle_out_of_order: bool = False
|
||||||
|
|
||||||
|
# XXX, when capfd is NOT used we don't expect to
|
||||||
|
# see the logging output from the subactor.
|
||||||
|
if (no_capfd := (start_method in [
|
||||||
|
'main_thread_forkserver',
|
||||||
|
])
|
||||||
|
):
|
||||||
|
opts = request.config.option
|
||||||
|
assert opts.spawn_backend == start_method
|
||||||
|
# ?XXX? i guess the `testdir` fixture "pretends to" reset
|
||||||
|
# this to the default 'fd'??
|
||||||
|
# assert opts.capture in [
|
||||||
|
# 'sys',
|
||||||
|
# 'no',
|
||||||
|
# ]
|
||||||
|
|
||||||
if (
|
if (
|
||||||
handle_out_of_order
|
handle_out_of_order
|
||||||
and
|
and
|
||||||
|
|
@ -128,25 +145,30 @@ def test_shield_pause(
|
||||||
assert 'Relaying `SIGUSR1`[10] to sub-actor' in _before
|
assert 'Relaying `SIGUSR1`[10] to sub-actor' in _before
|
||||||
|
|
||||||
else:
|
else:
|
||||||
expect(
|
_before = expect(
|
||||||
child,
|
child,
|
||||||
'Relaying `SIGUSR1`\\[10\\] to sub-actor',
|
'Relaying `SIGUSR1`\\[10\\] to sub-actor',
|
||||||
)
|
)
|
||||||
expect(
|
# _before: str = assert_before(
|
||||||
child,
|
# child,
|
||||||
# end-of-subactor's-tree delimiter
|
# ["('hanger'",] # uid line
|
||||||
"end-of-\('hanger'",
|
# )
|
||||||
)
|
if not no_capfd:
|
||||||
_before: str = assert_before(
|
expect(
|
||||||
child,
|
child,
|
||||||
[
|
# end-of-subactor's-tree delimiter
|
||||||
"('hanger'", # uid line
|
"end-of-\('hanger'",
|
||||||
|
)
|
||||||
|
_before: str = assert_before(
|
||||||
|
child,
|
||||||
|
[
|
||||||
|
"('hanger'", # uid line
|
||||||
|
|
||||||
# TODO!? SEE ABOVE
|
# TODO!? SEE ABOVE
|
||||||
# hanger LOC where it's shield-halted
|
# hanger LOC where it's shield-halted
|
||||||
# 'await trio.sleep_forever() # in subactor',
|
# 'await trio.sleep_forever() # in subactor',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# simulate the user sending a ctl-c to the hanging program.
|
# simulate the user sending a ctl-c to the hanging program.
|
||||||
|
|
@ -163,14 +185,19 @@ def test_shield_pause(
|
||||||
_shutdown_msg,
|
_shutdown_msg,
|
||||||
timeout=6,
|
timeout=6,
|
||||||
)
|
)
|
||||||
assert_before(
|
expect_on_teardown: list[str] = [
|
||||||
child,
|
'raise KeyboardInterrupt',
|
||||||
[
|
'Root actor terminated',
|
||||||
'raise KeyboardInterrupt',
|
]
|
||||||
|
if not no_capfd:
|
||||||
|
expect_on_teardown += [
|
||||||
# 'Shutting down actor runtime',
|
# 'Shutting down actor runtime',
|
||||||
'#T-800 deployed to collect zombie B0',
|
'#T-800 deployed to collect zombie B0',
|
||||||
"'--uid', \"('hanger',",
|
"'--uid', \"('hanger',",
|
||||||
]
|
]
|
||||||
|
assert_before(
|
||||||
|
child,
|
||||||
|
expect_on_teardown,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue