Skip to content

Commit

Permalink
Add before assert helper and print console bytes on fail
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Jul 15, 2022
1 parent b767377 commit 8cd8eb5
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions tests/test_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ def _spawn(cmd):
return _spawn


def assert_before(
child,
patts: list[str],

) -> None:

before = str(child.before.decode())

for patt in patts:
try:
assert patt in before
except AssertionError:
print(before)
raise


@pytest.fixture(
params=[False, True],
ids='ctl-c={}'.format,
Expand Down Expand Up @@ -163,6 +179,8 @@ def do_ctlc(
time.sleep(delay)
child.sendcontrol('c')

before = str(child.before.decode())

# TODO: figure out why this makes CI fail..
# if you run this test manually it works just fine..
from conftest import _ci_env
Expand All @@ -175,8 +193,6 @@ def do_ctlc(
# should see the last line on console
assert patt in before

before = str(child.before.decode())


def test_root_actor_bp_forever(
spawn,
Expand Down Expand Up @@ -365,9 +381,15 @@ def test_multi_subactors(

# 2nd name_error failure
child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode())
assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
assert "NameError" in before

assert_before(child, [
"Attaching to pdb in crashed actor: ('name_error_1'",
"NameError",
])

# before = str(child.before.decode())
# assert "Attaching to pdb in crashed actor: ('name_error_1'" in before
# assert "NameError" in before

if ctlc:
do_ctlc(child)
Expand Down

0 comments on commit 8cd8eb5

Please sign in to comment.