зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1025125 - If enabled, enter pdb session when test fails. r=ahal
This commit is contained in:
Родитель
ea49fe57ec
Коммит
fa13622978
|
@ -207,6 +207,7 @@ class CommonTestCase(unittest.TestCase):
|
|||
__metaclass__ = MetaParameterized
|
||||
match_re = None
|
||||
failureException = AssertionError
|
||||
pydebugger = None
|
||||
|
||||
def __init__(self, methodName, **kwargs):
|
||||
unittest.TestCase.__init__(self, methodName)
|
||||
|
@ -216,6 +217,10 @@ class CommonTestCase(unittest.TestCase):
|
|||
self.expected = kwargs.pop('expected', 'pass')
|
||||
self.logger = get_default_logger()
|
||||
|
||||
def _enter_pm(self):
|
||||
if self.pydebugger:
|
||||
self.pydebugger.post_mortem(sys.exc_info()[2])
|
||||
|
||||
def _addSkip(self, result, reason):
|
||||
addSkip = getattr(result, 'addSkip', None)
|
||||
if addSkip is not None:
|
||||
|
@ -277,6 +282,7 @@ class CommonTestCase(unittest.TestCase):
|
|||
except _ExpectedFailure as e:
|
||||
expected_failure(result, e.exc_info)
|
||||
except:
|
||||
self._enter_pm()
|
||||
result.addError(self, sys.exc_info())
|
||||
else:
|
||||
try:
|
||||
|
@ -289,6 +295,7 @@ class CommonTestCase(unittest.TestCase):
|
|||
else:
|
||||
testMethod()
|
||||
except self.failureException:
|
||||
self._enter_pm()
|
||||
result.addFailure(self, sys.exc_info())
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
|
@ -305,6 +312,7 @@ class CommonTestCase(unittest.TestCase):
|
|||
except SkipTest as e:
|
||||
self._addSkip(result, str(e))
|
||||
except:
|
||||
self._enter_pm()
|
||||
result.addError(self, sys.exc_info())
|
||||
else:
|
||||
success = True
|
||||
|
@ -321,6 +329,7 @@ class CommonTestCase(unittest.TestCase):
|
|||
except _ExpectedFailure as e:
|
||||
expected_failure(result, e.exc_info)
|
||||
except:
|
||||
self._enter_pm()
|
||||
result.addError(self, sys.exc_info())
|
||||
success = False
|
||||
# Here we could handle doCleanups() instead of calling cleanTest directly
|
||||
|
|
|
@ -403,6 +403,10 @@ class BaseMarionetteOptions(OptionParser):
|
|||
action='store_true',
|
||||
default=False,
|
||||
help='Enable the jsdebugger for marionette javascript.')
|
||||
self.add_option('--pydebugger',
|
||||
dest='pydebugger',
|
||||
help='Enable python post-mortem debugger when a test fails.'
|
||||
' Pass in the debugger you want to use, eg pdb or ipdb.')
|
||||
self.add_option('--socket-timeout',
|
||||
dest='socket_timeout',
|
||||
action='store',
|
||||
|
|
|
@ -15,6 +15,8 @@ class MarionetteTestRunner(BaseMarionetteTestRunner):
|
|||
self.test_handlers = [MarionetteTestCase, MarionetteJSTestCase]
|
||||
|
||||
def startTestRunner(runner_class, options, tests):
|
||||
if options.pydebugger:
|
||||
MarionetteTestCase.pydebugger = __import__(options.pydebugger)
|
||||
|
||||
runner = runner_class(**vars(options))
|
||||
runner.run_tests(tests)
|
||||
|
|
|
@ -123,6 +123,9 @@ class MachCommands(MachCommandBase):
|
|||
help='Path to gecko log file, or "-" for stdout.')
|
||||
@CommandArgument('--jsdebugger', action='store_true',
|
||||
help='Enable the jsdebugger for marionette javascript.')
|
||||
@CommandArgument('--pydebugger',
|
||||
help='Enable python post-mortem debugger when a test fails.'
|
||||
' Pass in the debugger you want to use, eg pdb or ipdb.')
|
||||
@CommandArgument('--e10s', action='store_true',
|
||||
help='Enable electrolysis for marionette tests (desktop only).')
|
||||
@CommandArgument('tests', nargs='*', metavar='TESTS',
|
||||
|
|
Загрузка…
Ссылка в новой задаче