зеркало из https://github.com/mozilla/pjs.git
Bug 748490 - Part 2: Register testing modules with xpcshell test runner; r=ted
This commit is contained in:
Родитель
d2d45f613b
Коммит
eed17d433e
|
@ -117,6 +117,7 @@ xpcshell-tests:
|
|||
--symbols-path=$(DIST)/crashreporter-symbols \
|
||||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--tests-root-dir=$(testxpcobjdir) \
|
||||
--tests-modules-dir=$(DEPTH)/_tests/modules \
|
||||
--xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
|
||||
--xunit-suite-name=xpcshell \
|
||||
$(EXTRA_TEST_ARGS) \
|
||||
|
@ -147,6 +148,7 @@ check-interactive:
|
|||
--symbols-path=$(DIST)/crashreporter-symbols \
|
||||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--test-path=$(SOLO_FILE) \
|
||||
--tests-modules-dir=$(DEPTH)/_tests/modules \
|
||||
--profile-name=$(MOZ_APP_NAME) \
|
||||
--interactive \
|
||||
$(LIBXUL_DIST)/bin/xpcshell \
|
||||
|
@ -160,6 +162,7 @@ check-one:
|
|||
--symbols-path=$(DIST)/crashreporter-symbols \
|
||||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--test-path=$(SOLO_FILE) \
|
||||
--tests-modules-dir=$(DEPTH)/_tests/modules \
|
||||
--profile-name=$(MOZ_APP_NAME) \
|
||||
--verbose \
|
||||
$(EXTRA_TEST_ARGS) \
|
||||
|
|
|
@ -117,6 +117,7 @@ xpcshell-tests:
|
|||
--symbols-path=$(DIST)/crashreporter-symbols \
|
||||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--tests-root-dir=$(testxpcobjdir) \
|
||||
--tests-modules-dir=$(DEPTH)/_tests/modules \
|
||||
--xunit-file=$(testxpcobjdir)/$(relativesrcdir)/results.xml \
|
||||
--xunit-suite-name=xpcshell \
|
||||
$(EXTRA_TEST_ARGS) \
|
||||
|
@ -147,6 +148,7 @@ check-interactive:
|
|||
--symbols-path=$(DIST)/crashreporter-symbols \
|
||||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--test-path=$(SOLO_FILE) \
|
||||
--tests-modules-dir=$(DEPTH)/_tests/modules \
|
||||
--profile-name=$(MOZ_APP_NAME) \
|
||||
--interactive \
|
||||
$(LIBXUL_DIST)/bin/xpcshell \
|
||||
|
@ -160,6 +162,7 @@ check-one:
|
|||
--symbols-path=$(DIST)/crashreporter-symbols \
|
||||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--test-path=$(SOLO_FILE) \
|
||||
--tests-modules-dir=$(DEPTH)/_tests/modules \
|
||||
--profile-name=$(MOZ_APP_NAME) \
|
||||
--verbose \
|
||||
$(EXTRA_TEST_ARGS) \
|
||||
|
|
|
@ -245,6 +245,7 @@ xpcshell-tests:
|
|||
--build-info-json=$(DEPTH)/mozinfo.json \
|
||||
--no-logfiles \
|
||||
--tests-root-dir=$(call core_abspath,_tests/xpcshell) \
|
||||
--tests-modules-dir=$(call core_abspath,_tests/modules) \
|
||||
--xunit-file=$(call core_abspath,_tests/xpcshell/results.xml) \
|
||||
--xunit-suite-name=xpcshell \
|
||||
$(SYMBOLS_PATH) \
|
||||
|
|
|
@ -302,7 +302,8 @@ function do_get_idle() {
|
|||
}
|
||||
|
||||
function _execute_test() {
|
||||
// Map resource://test/ to the current working directory.
|
||||
// Map resource://test/ to current working directory and
|
||||
// resource://testing/ to the shared test modules directory.
|
||||
let (ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)) {
|
||||
let protocolHandler =
|
||||
|
@ -310,6 +311,15 @@ function _execute_test() {
|
|||
.QueryInterface(Components.interfaces.nsIResProtocolHandler);
|
||||
let curDirURI = ios.newFileURI(do_get_cwd());
|
||||
protocolHandler.setSubstitution("test", curDirURI);
|
||||
|
||||
if (this._TESTING_MODULES_DIR) {
|
||||
let modulesFile = Components.classes["@mozilla.org/file/local;1"].
|
||||
createInstance(Components.interfaces.nsILocalFile);
|
||||
modulesFile.initWithPath(_TESTING_MODULES_DIR);
|
||||
|
||||
let modulesURI = ios.newFileURI(modulesFile);
|
||||
protocolHandler.setSubstitution("testing", modulesURI);
|
||||
}
|
||||
}
|
||||
|
||||
// Override idle service by default.
|
||||
|
@ -819,14 +829,21 @@ function do_load_child_test_harness()
|
|||
var quoted_tail_files = _TAIL_FILES.map(addQuotes);
|
||||
|
||||
_XPCSHELL_PROCESS = "parent";
|
||||
|
||||
sendCommand(
|
||||
|
||||
let command =
|
||||
"const _HEAD_JS_PATH='" + _HEAD_JS_PATH + "'; "
|
||||
+ "const _HTTPD_JS_PATH='" + _HTTPD_JS_PATH + "'; "
|
||||
+ "const _HEAD_FILES=[" + quoted_head_files.join() + "];"
|
||||
+ "const _TAIL_FILES=[" + quoted_tail_files.join() + "];"
|
||||
+ "const _XPCSHELL_PROCESS='child';"
|
||||
+ "load(_HEAD_JS_PATH);");
|
||||
+ "const _XPCSHELL_PROCESS='child';";
|
||||
|
||||
if (this._TESTING_MODULES_DIR) {
|
||||
command += "const _TESTING_MODULES_DIR='" + _TESTING_MODULES_DIR + "'; ";
|
||||
}
|
||||
|
||||
command += "load(_HEAD_JS_PATH);";
|
||||
|
||||
sendCommand(command);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -222,10 +222,26 @@ class XPCShellTests(object):
|
|||
# do_load_child_test_harness() in head.js
|
||||
if not self.appPath:
|
||||
self.appPath = self.xrePath
|
||||
self.xpcsCmd = [self.xpcshell, '-g', self.xrePath, '-a', self.appPath, '-r', self.httpdManifest, '-m', '-n', '-s'] + \
|
||||
['-e', 'const _HTTPD_JS_PATH = "%s";' % self.httpdJSPath,
|
||||
'-e', 'const _HEAD_JS_PATH = "%s";' % self.headJSPath,
|
||||
'-f', os.path.join(self.testharnessdir, 'head.js')]
|
||||
|
||||
self.xpcsCmd = [
|
||||
self.xpcshell,
|
||||
'-g', self.xrePath,
|
||||
'-a', self.appPath,
|
||||
'-r', self.httpdManifest,
|
||||
'-m',
|
||||
'-n',
|
||||
'-s',
|
||||
'-e', 'const _HTTPD_JS_PATH = "%s";' % self.httpdJSPath,
|
||||
'-e', 'const _HEAD_JS_PATH = "%s";' % self.headJSPath
|
||||
]
|
||||
|
||||
if self.testingModulesDir is not None:
|
||||
self.xpcsCmd.extend([
|
||||
'-e',
|
||||
'const _TESTING_MODULES_DIR = "%s";' % self.testingModulesDir
|
||||
])
|
||||
|
||||
self.xpcsCmd.extend(['-f', os.path.join(self.testharnessdir, 'head.js')])
|
||||
|
||||
if self.debuggerInfo:
|
||||
self.xpcsCmd = [self.debuggerInfo["path"]] + self.debuggerInfo["args"] + self.xpcsCmd
|
||||
|
@ -553,7 +569,7 @@ class XPCShellTests(object):
|
|||
debuggerArgs=None, debuggerInteractive=False,
|
||||
profileName=None, mozInfo=None, shuffle=False,
|
||||
testsRootDir=None, xunitFilename=None, xunitName=None,
|
||||
**otherOptions):
|
||||
testingModulesDir=None, **otherOptions):
|
||||
"""Run xpcshell tests.
|
||||
|
||||
|xpcshell|, is the xpcshell executable to use to run the tests.
|
||||
|
@ -584,6 +600,8 @@ class XPCShellTests(object):
|
|||
results.
|
||||
|xunitName|, if outputting an xUnit XML file, the str value to use for the
|
||||
testsuite name.
|
||||
|testingModulesDir|, if provided, specifies where JS modules reside.
|
||||
xpcshell will register a resource handler mapping this path.
|
||||
|otherOptions| may be present for the convenience of subclasses
|
||||
"""
|
||||
|
||||
|
@ -603,6 +621,10 @@ class XPCShellTests(object):
|
|||
raise Exception("testsRootDir path does not exists: %s" %
|
||||
testsRootDir)
|
||||
|
||||
if testingModulesDir is not None:
|
||||
if not os.path.isabs(testingModulesDir):
|
||||
testingModulesDir = os.path.abspath(testingModulesDir)
|
||||
|
||||
self.xpcshell = xpcshell
|
||||
self.xrePath = xrePath
|
||||
self.appPath = appPath
|
||||
|
@ -619,6 +641,7 @@ class XPCShellTests(object):
|
|||
self.debuggerInfo = getDebuggerInfo(self.oldcwd, debugger, debuggerArgs, debuggerInteractive)
|
||||
self.profileName = profileName or "xpcshell"
|
||||
self.mozInfo = mozInfo
|
||||
self.testingModulesDir = testingModulesDir
|
||||
|
||||
# If we have an interactive debugger, disable ctrl-c.
|
||||
if self.debuggerInfo and self.debuggerInfo["interactive"]:
|
||||
|
@ -877,6 +900,9 @@ class XPCShellOptions(OptionParser):
|
|||
self.add_option("--tests-root-dir",
|
||||
type="string", dest="testsRootDir", default=None,
|
||||
help="absolute path to directory where all tests are located. this is typically $(objdir)/_tests")
|
||||
self.add_option("--tests-modules-dir",
|
||||
dest="testingModulesDir", default=None,
|
||||
help="Directory where testing modules are located.")
|
||||
self.add_option("--total-chunks",
|
||||
type = "int", dest = "totalChunks", default=1,
|
||||
help = "how many chunks to split the tests up into")
|
||||
|
|
Загрузка…
Ссылка в новой задаче