Bug 932144 - Add option to break into debugger on test failure. r=jmaher

This commit is contained in:
Felipe Gomes 2013-11-01 17:23:34 -02:00
Родитель 499afc168b
Коммит 7d32f2051b
6 изменённых файлов: 35 добавлений и 1 удалений

Просмотреть файл

@ -601,6 +601,12 @@ function testResult(aCondition, aName, aDiag, aIsTodo, aStack) {
this.result = "TEST-UNEXPECTED-PASS";
else
this.result = "TEST-UNEXPECTED-FAIL";
if (gConfig.debugOnFailure) {
// You've hit this line because you requested to break into the
// debugger upon a testcase failure on your test run.
debugger;
}
}
}

Просмотреть файл

@ -186,7 +186,7 @@ class MochitestRunner(MozbuildObject):
debugger_args=None, shuffle=False, keep_open=False, rerun_failures=False,
no_autorun=False, repeat=0, run_until_failure=False, slow=False,
chunk_by_dir=0, total_chunks=None, this_chunk=None, jsdebugger=False,
start_at=None, end_at=None):
debug_on_failure=False, start_at=None, end_at=None):
"""Runs a mochitest.
test_file is a path to a test file. It can be a relative path from the
@ -287,6 +287,7 @@ class MochitestRunner(MozbuildObject):
options.totalChunks = total_chunks
options.thisChunk = this_chunk
options.jsdebugger = jsdebugger
options.debugOnFailure = debug_on_failure
options.startAt = start_at
options.endAt = end_at
@ -416,6 +417,11 @@ def MochitestCommand(func):
help='If running tests by chunks, the number of the chunk to run.')
func = this_chunk(func)
debug_on_failure = CommandArgument('--debug-on-failure', action='store_true',
help='Breaks execution and enters the JS debugger on a test failure. ' \
'Should be used together with --jsdebugger.')
func = debug_on_failure(func)
jsdebugger = CommandArgument('--jsdebugger', action='store_true',
help='Start the browser JS debugger before running the test. Implies --no-autorun.')
func = jsdebugger(func)

Просмотреть файл

@ -340,6 +340,12 @@ class MochitestOptions(optparse.OptionParser):
"dest": "jsdebugger",
"help": "open the browser debugger",
}],
[["--debug-on-failure"],
{ "action": "store_true",
"default": False,
"dest": "debugOnFailure",
"help": "breaks execution and enters the JS debugger on a test failure. Should be used together with --jsdebugger."
}],
]
def __init__(self, **kwargs):
@ -442,6 +448,9 @@ class MochitestOptions(optparse.OptionParser):
]
options.autorun = False
if options.debugOnFailure and not options.jsdebugger:
self.error("--debug-on-failure should be used together with --jsdebugger.")
# Try to guess the testing modules directory.
# This somewhat grotesque hack allows the buildbot machines to find the
# modules directory without having to configure the buildbot hosts. This

Просмотреть файл

@ -342,6 +342,8 @@ class MochitestUtilsMixin(object):
self.urlOpts.append("failureFile=%s" % self.getFullPath(options.failureFile))
if options.runSlower:
self.urlOpts.append("runSlower=true")
if options.debugOnFailure:
self.urlOpts.append("debugOnFailure=true")
def buildTestPath(self, options):
""" Build the url path to the specific test harness and test file or directory

Просмотреть файл

@ -213,6 +213,12 @@ TestRunner.error = function(msg) {
} else {
dump(msg + "\n");
}
if (TestRunner.debugOnFailure) {
// You've hit this line because you requested to break into the
// debugger upon a testcase failure on your test run.
debugger;
}
};
/**

Просмотреть файл

@ -107,6 +107,11 @@ if (params.failureFile) {
TestRunner.setFailureFile(params.failureFile);
}
// Breaks execution and enters the JS debugger on a test failure
if (params.debugOnFailure) {
TestRunner.debugOnFailure = true;
}
// logFile to write our results
if (params.logFile) {
var spl = new SpecialPowersLogger(params.logFile);