forked from goodboy/tractor
1
0
Fork 0

Use `assert_before` more extensively

sigintsaviour_citesthackin
Tyler Goodlet 2022-07-29 19:34:54 -04:00
parent 6b8c193221
commit 0b4fc4fc47
1 changed files with 53 additions and 41 deletions

View File

@ -376,10 +376,11 @@ def test_multi_subactors(
spawn, spawn,
ctlc: bool, ctlc: bool,
): ):
""" '''
Multiple subactors, both erroring and breakpointing as well as Multiple subactors, both erroring and
a nested subactor erroring. breakpointing as well as a nested subactor erroring.
"""
'''
child = spawn(r'multi_subactors') child = spawn(r'multi_subactors')
# scan for the pdbpp prompt # scan for the pdbpp prompt
@ -418,10 +419,10 @@ def test_multi_subactors(
# 2nd name_error failure # 2nd name_error failure
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
# XXX: lol honestly no idea why CI is suck a cuck # XXX: lol honestly no idea why CI is cuck but
from conftest import _ci_env # seems like this likely falls into our unhandled nested
name = 'name_error' if _ci_env else 'name_error_1' # case and isn't working in that env due to raciness..
name = 'name_error' if ctlc else 'name_error_1'
assert_before(child, [ assert_before(child, [
f"Attaching to pdb in crashed actor: ('{name}'", f"Attaching to pdb in crashed actor: ('{name}'",
"NameError", "NameError",
@ -455,11 +456,11 @@ def test_multi_subactors(
do_ctlc(child) do_ctlc(child)
# 2nd depth nursery should trigger # 2nd depth nursery should trigger
# child.sendline('c') if not ctlc:
# child.expect(r"\(Pdb\+\+\)") assert_before(child, [
# before = str(child.before.decode()) spawn_err,
assert spawn_err in before "RemoteActorError: ('name_error_1'",
assert "RemoteActorError: ('name_error_1'" in before ])
# now run some "continues" to show re-entries # now run some "continues" to show re-entries
for _ in range(5): for _ in range(5):
@ -471,14 +472,17 @@ def test_multi_subactors(
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode()) before = str(child.before.decode())
# debugger attaches to root assert_before(child, [
assert "Attaching to pdb in crashed actor: ('root'" in before # debugger attaches to root
# expect a multierror with exceptions for each sub-actor "Attaching to pdb in crashed actor: ('root'",
assert "RemoteActorError: ('breakpoint_forever'" in before
assert "RemoteActorError: ('name_error'" in before # expect a multierror with exceptions for each sub-actor
assert "RemoteActorError: ('spawn_error'" in before "RemoteActorError: ('breakpoint_forever'",
assert "RemoteActorError: ('name_error_1'" in before "RemoteActorError: ('name_error'",
assert 'bdb.BdbQuit' in before "RemoteActorError: ('spawn_error'",
"RemoteActorError: ('name_error_1'",
'bdb.BdbQuit',
])
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
@ -486,13 +490,15 @@ def test_multi_subactors(
# process should exit # process should exit
child.sendline('c') child.sendline('c')
child.expect(pexpect.EOF) child.expect(pexpect.EOF)
# repeat of previous multierror for final output # repeat of previous multierror for final output
before = str(child.before.decode()) assert_before(child, [
assert "RemoteActorError: ('breakpoint_forever'" in before "RemoteActorError: ('breakpoint_forever'",
assert "RemoteActorError: ('name_error'" in before "RemoteActorError: ('name_error'",
assert "RemoteActorError: ('spawn_error'" in before "RemoteActorError: ('spawn_error'",
assert "RemoteActorError: ('name_error_1'" in before "RemoteActorError: ('name_error_1'",
assert 'bdb.BdbQuit' in before 'bdb.BdbQuit',
])
def test_multi_daemon_subactors( def test_multi_daemon_subactors(
@ -608,7 +614,6 @@ def test_multi_subactors_root_errors(
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
# continue again to catch 2nd name error from
# continue again to catch 2nd name error from # continue again to catch 2nd name error from
# actor 'name_error_1' (which is 2nd depth). # actor 'name_error_1' (which is 2nd depth).
child.sendline('c') child.sendline('c')
@ -617,31 +622,38 @@ def test_multi_subactors_root_errors(
except TIMEOUT: except TIMEOUT:
child.sendline('') child.sendline('')
before = str(child.before.decode()) # XXX: lol honestly no idea why CI is cuck but
assert "Attaching to pdb in crashed actor: ('name_error_1'" in before # seems like this likely falls into our unhandled nested
assert "NameError" in before # case and isn't working in that env due to raciness..
name = 'name_error' if ctlc else 'name_error_1'
assert_before(child, [
f"Attaching to pdb in crashed actor: ('{name}'",
"NameError",
])
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
child.sendline('c') child.sendline('c')
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode()) assert_before(child, [
assert "Attaching to pdb in crashed actor: ('spawn_error'" in before "Attaching to pdb in crashed actor: ('spawn_error'",
# boxed error from previous step # boxed error from previous step
assert "RemoteActorError: ('name_error_1'" in before "RemoteActorError: ('name_error_1'",
assert "NameError" in before "NameError",
])
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
child.sendline('c') child.sendline('c')
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode()) assert_before(child, [
assert "Attaching to pdb in crashed actor: ('root'" in before "Attaching to pdb in crashed actor: ('root'",
# boxed error from first level failure # boxed error from previous step
assert "RemoteActorError: ('name_error'" in before "RemoteActorError: ('name_error'",
assert "NameError" in before "NameError",
])
# warnings assert we probably don't need # warnings assert we probably don't need
# assert "Cancelling nursery in ('spawn_error'," in before # assert "Cancelling nursery in ('spawn_error'," in before