Bug 809561 - Integrate xpcshell test harness with chrome remote debugging. r=past/chmanchester

This commit is contained in:
Mark Hammond
2014-11-29 10:40:58 +11:00
parent 5bda50d8c6
commit a0302a0353
7 changed files with 226 additions and 15 deletions

View File

@@ -19,7 +19,7 @@ import sys
import time
import traceback
from collections import deque
from collections import deque, namedtuple
from distutils import dir_util
from multiprocessing import cpu_count
from optparse import OptionParser
@@ -111,6 +111,7 @@ class XPCShellTestThread(Thread):
self.xrePath = kwargs.get('xrePath')
self.testingModulesDir = kwargs.get('testingModulesDir')
self.debuggerInfo = kwargs.get('debuggerInfo')
self.jsDebuggerInfo = kwargs.get('jsDebuggerInfo')
self.pluginsPath = kwargs.get('pluginsPath')
self.httpdManifest = kwargs.get('httpdManifest')
self.httpdJSPath = kwargs.get('httpdJSPath')
@@ -366,10 +367,15 @@ class XPCShellTestThread(Thread):
for f in headfiles])
cmdT = ", ".join(['"' + f.replace('\\', '/') + '"'
for f in tailfiles])
dbgport = 0 if self.jsDebuggerInfo is None else self.jsDebuggerInfo.port
return xpcscmd + \
['-e', 'const _SERVER_ADDR = "localhost"',
'-e', 'const _HEAD_FILES = [%s];' % cmdH,
'-e', 'const _TAIL_FILES = [%s];' % cmdT]
'-e', 'const _TAIL_FILES = [%s];' % cmdT,
'-e', 'const _JSDEBUGGER_PORT = %d;' % dbgport,
]
def getHeadAndTailFiles(self, test_object):
"""Obtain the list of head and tail files.
@@ -632,7 +638,7 @@ class XPCShellTestThread(Thread):
testTimeoutInterval *= int(self.test_object['requesttimeoutfactor'])
testTimer = None
if not self.interactive and not self.debuggerInfo:
if not self.interactive and not self.debuggerInfo and not self.jsDebuggerInfo:
testTimer = Timer(testTimeoutInterval, lambda: self.testTimeout(proc))
testTimer.start()
@@ -1004,7 +1010,8 @@ class XPCShellTests(object):
profileName=None, mozInfo=None, sequential=False, shuffle=False,
testsRootDir=None, testingModulesDir=None, pluginsPath=None,
testClass=XPCShellTestThread, failureManifest=None,
log=None, stream=None, **otherOptions):
log=None, stream=None, jsDebugger=False, jsDebuggerPort=0,
**otherOptions):
"""Run xpcshell tests.
|xpcshell|, is the xpcshell executable to use to run the tests.
@@ -1075,6 +1082,12 @@ class XPCShellTests(object):
if debugger:
self.debuggerInfo = mozdebug.get_debugger_info(debugger, debuggerArgs, debuggerInteractive)
self.jsDebuggerInfo = None
if jsDebugger:
# A namedtuple let's us keep .port instead of ['port']
JSDebuggerInfo = namedtuple('JSDebuggerInfo', ['port'])
self.jsDebuggerInfo = JSDebuggerInfo(port=jsDebuggerPort)
self.xpcshell = xpcshell
self.xrePath = xrePath
self.appPath = appPath
@@ -1161,6 +1174,7 @@ class XPCShellTests(object):
'xrePath': self.xrePath,
'testingModulesDir': self.testingModulesDir,
'debuggerInfo': self.debuggerInfo,
'jsDebuggerInfo': self.jsDebuggerInfo,
'pluginsPath': self.pluginsPath,
'httpdManifest': self.httpdManifest,
'httpdJSPath': self.httpdJSPath,
@@ -1190,6 +1204,13 @@ class XPCShellTests(object):
if self.debuggerInfo.interactive:
signal.signal(signal.SIGINT, lambda signum, frame: None)
if self.jsDebuggerInfo:
# The js debugger magic needs more work to do the right thing
# if debugging multiple files.
if len(self.alltests) != 1:
self.log.error("Error: --jsdebugger can only be used with a single test!")
return False
# create a queue of all tests that will run
tests_queue = deque()
# also a list for the tests that need to be run sequentially
@@ -1434,6 +1455,13 @@ class XPCShellOptions(OptionParser):
action = "store_true", dest = "debuggerInteractive",
help = "prevents the test harness from redirecting "
"stdout and stderr for interactive debuggers")
self.add_option("--jsdebugger", dest="jsDebugger", action="store_true",
help="Waits for a devtools JS debugger to connect before "
"starting the test.")
self.add_option("--jsdebugger-port", type="int", dest="jsDebuggerPort",
default=6000,
help="The port to listen on for a debugger connection if "
"--jsdebugger is specified.")
def main():
parser = XPCShellOptions()