OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import sys |
| 6 import pdb |
| 7 |
| 8 from .type_definitions import Handler |
| 9 |
| 10 |
| 11 class DebugHandler(Handler): |
| 12 """Execute each test under the pdb debugger.""" |
| 13 SKIP_RUNLOOP = True |
| 14 |
| 15 class ResultStageHandler(Handler.ResultStageHandler): |
| 16 @staticmethod |
| 17 def handle_MultiTest(mtest): |
| 18 for _ in mtest.process(DebugHandler.ResultStageHandler.handle_Test): |
| 19 pass |
| 20 |
| 21 @staticmethod |
| 22 def handle_Test(test): |
| 23 dbg = pdb.Pdb() |
| 24 for path, line, funcname in test.breakpoints: |
| 25 dbg.set_break(path, line, funcname=funcname) |
| 26 |
| 27 dbg.reset() |
| 28 |
| 29 def dispatch_thunk(*args): |
| 30 """Allows us to continue until the actual breakpoint.""" |
| 31 val = dbg.trace_dispatch(*args) |
| 32 dbg.set_continue() |
| 33 sys.settrace(dbg.trace_dispatch) |
| 34 return val |
| 35 sys.settrace(dispatch_thunk) |
| 36 try: |
| 37 test.run() |
| 38 except pdb.bdb.BdbQuit: |
| 39 pass |
| 40 finally: |
| 41 dbg.quitting = 1 |
| 42 sys.settrace(None) |
OLD | NEW |