Use `assert_before` more extensively

signint_saviour
Tyler Goodlet 2022-07-29 19:34:54 -04:00
parent 87b2ccb86a
commit 8896ba2bf8
1 changed files with 49 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
@ -423,10 +424,6 @@ def test_multi_subactors(
"NameError", "NameError",
]) ])
# before = str(child.before.decode())
# assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
# assert "NameError" in before
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
@ -455,11 +452,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 +468,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 +486,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 +610,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 +618,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