From 3d202272c4290cd38ae06a4519c34b824b9fb48e Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 15 Apr 2023 19:43:58 -0400 Subject: [PATCH] Change over debugger tests to use `PROMPT` var.. --- tests/test_debugger.py | 71 +++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/tests/test_debugger.py b/tests/test_debugger.py index 7885034..5f90703 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -95,7 +95,7 @@ def spawn( return _spawn -PROMPT = r"\(Pdb\+\+\)" +PROMPT = r"\(Pdb\+\)" def expect( @@ -151,6 +151,7 @@ def ctlc( use_ctlc = request.param + # TODO: we can remove this bc pdbp right? if ( sys.version_info <= (3, 10) and use_ctlc @@ -231,7 +232,7 @@ def test_root_actor_bp(spawn, user_in_out): child = spawn('root_actor_breakpoint') # scan for the pdbpp prompt - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) assert 'Error' not in str(child.before) @@ -272,7 +273,7 @@ def do_ctlc( if expect_prompt: before = str(child.before.decode()) time.sleep(delay) - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) time.sleep(delay) if patt: @@ -291,7 +292,7 @@ def test_root_actor_bp_forever( # entries for _ in range(10): - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) if ctlc: do_ctlc(child) @@ -301,7 +302,7 @@ def test_root_actor_bp_forever( # do one continue which should trigger a # new task to lock the tty child.sendline('continue') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # seems that if we hit ctrl-c too fast the # sigint guard machinery might not kick in.. @@ -312,10 +313,10 @@ def test_root_actor_bp_forever( # XXX: this previously caused a bug! child.sendline('n') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) child.sendline('n') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # quit out of the loop child.sendline('q') @@ -339,7 +340,7 @@ def test_subactor_error( child = spawn('subactor_error') # scan for the pdbpp prompt - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "Attaching to pdb in crashed actor: ('name_error'" in before @@ -359,7 +360,7 @@ def test_subactor_error( # creating actor child.sendline('continue') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) # root actor gets debugger engaged @@ -387,7 +388,7 @@ def test_subactor_breakpoint( child = spawn('subactor_breakpoint') # scan for the pdbpp prompt - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "Attaching pdb to actor: ('breakpoint_forever'" in before @@ -396,7 +397,7 @@ def test_subactor_breakpoint( # entries for _ in range(10): child.sendline('next') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) if ctlc: do_ctlc(child) @@ -404,7 +405,7 @@ def test_subactor_breakpoint( # now run some "continues" to show re-entries for _ in range(5): child.sendline('continue') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "Attaching pdb to actor: ('breakpoint_forever'" in before @@ -415,7 +416,7 @@ def test_subactor_breakpoint( child.sendline('q') # child process should exit but parent will capture pdb.BdbQuit - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "RemoteActorError: ('breakpoint_forever'" in before @@ -448,7 +449,7 @@ def test_multi_subactors( child = spawn(r'multi_subactors') # scan for the pdbpp prompt - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "Attaching pdb to actor: ('breakpoint_forever'" in before @@ -460,7 +461,7 @@ def test_multi_subactors( # entries for _ in range(10): child.sendline('next') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) if ctlc: do_ctlc(child) @@ -469,7 +470,7 @@ def test_multi_subactors( child.sendline('c') # first name_error failure - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "Attaching to pdb in crashed actor: ('name_error'" in before assert "NameError" in before @@ -481,7 +482,7 @@ def test_multi_subactors( child.sendline('c') # 2nd name_error failure - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # TODO: will we ever get the race where this crash will show up? # blocklist strat now prevents this crash @@ -495,7 +496,7 @@ def test_multi_subactors( # breakpoint loop should re-engage child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "Attaching pdb to actor: ('breakpoint_forever'" in before @@ -511,7 +512,7 @@ def test_multi_subactors( ): child.sendline('c') time.sleep(0.1) - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) if ctlc: @@ -530,11 +531,11 @@ def test_multi_subactors( # now run some "continues" to show re-entries for _ in range(5): child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # quit the loop and expect parent to attach child.sendline('q') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert_before(child, [ @@ -578,7 +579,7 @@ def test_multi_daemon_subactors( ''' child = spawn('multi_daemon_subactors') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # there can be a race for which subactor will acquire # the root's tty lock first so anticipate either crash @@ -608,7 +609,7 @@ def test_multi_daemon_subactors( # second entry by `bp_forever`. child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) assert_before(child, [next_msg]) # XXX: hooray the root clobbering the child here was fixed! @@ -630,7 +631,7 @@ def test_multi_daemon_subactors( # expect another breakpoint actor entry child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) try: assert_before(child, [bp_forever_msg]) @@ -646,7 +647,7 @@ def test_multi_daemon_subactors( # after 1 or more further bp actor entries. child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) assert_before(child, [name_error_msg]) # wait for final error in root @@ -654,7 +655,7 @@ def test_multi_daemon_subactors( while True: try: child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) assert_before( child, [bp_forever_msg] @@ -688,7 +689,7 @@ def test_multi_subactors_root_errors( child = spawn('multi_subactor_root_errors') # scan for the pdbpp prompt - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # at most one subactor should attach before the root is cancelled before = str(child.before.decode()) @@ -703,7 +704,7 @@ def test_multi_subactors_root_errors( # due to block list strat from #337, this will no longer # propagate before the root errors and cancels the spawner sub-tree. - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # only if the blocking condition doesn't kick in fast enough before = str(child.before.decode()) @@ -718,7 +719,7 @@ def test_multi_subactors_root_errors( do_ctlc(child) child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # check if the spawner crashed or was blocked from debug # and if this intermediary attached check the boxed error @@ -735,7 +736,7 @@ def test_multi_subactors_root_errors( do_ctlc(child) child.sendline('c') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # expect a root actor crash assert_before(child, [ @@ -784,7 +785,7 @@ def test_multi_nested_subactors_error_through_nurseries( for send_char in itertools.cycle(['c', 'q']): try: - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) child.sendline(send_char) time.sleep(0.01) @@ -826,7 +827,7 @@ def test_root_nursery_cancels_before_child_releases_tty_lock( child = spawn('root_cancelled_but_child_is_in_tty_lock') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "NameError: name 'doggypants' is not defined" in before @@ -841,7 +842,7 @@ def test_root_nursery_cancels_before_child_releases_tty_lock( for i in range(4): time.sleep(0.5) try: - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) except ( EOF, @@ -898,7 +899,7 @@ def test_root_cancels_child_context_during_startup( ''' child = spawn('fast_error_in_root_after_spawn') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) before = str(child.before.decode()) assert "AssertionError" in before @@ -915,7 +916,7 @@ def test_different_debug_mode_per_actor( ctlc: bool, ): child = spawn('per_actor_debug') - child.expect(r"\(Pdb\+\+\)") + child.expect(PROMPT) # only one actor should enter the debugger before = str(child.before.decode())