Bug 762837 - Try to find modules directory if not defined; r=ted

This is a workaround to enable modules to be found on the buildbot test
runners.
This commit is contained in:
Gregory Szorc 2012-06-29 13:27:11 -07:00
Родитель 81ffe71470
Коммит 0bd4aaec66
2 изменённых файлов: 37 добавлений и 2 удалений

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

@ -281,7 +281,18 @@ function _register_protocol_handlers() {
createInstance(Components.interfaces.nsILocalFile);
modulesFile.initWithPath(_TESTING_MODULES_DIR);
if (!modulesFile.exists()) {
throw new Error("Specified modules directory does not exist: " +
_TESTING_MODULES_DIR);
}
if (!modulesFile.isDirectory()) {
throw new Error("Specified modules directory is not a directory: " +
_TESTING_MODULES_DIR);
}
let modulesURI = ios.newFileURI(modulesFile);
protocolHandler.setSubstitution("testing-common", modulesURI);
}
}
@ -814,7 +825,8 @@ function do_load_child_test_harness()
+ "const _XPCSHELL_PROCESS='child';";
if (this._TESTING_MODULES_DIR) {
command += "const _TESTING_MODULES_DIR='" + _TESTING_MODULES_DIR + "'; ";
normalized = this._TESTING_MODULES_DIR.replace('\\', '\\\\', 'g');
command += "const _TESTING_MODULES_DIR='" + normalized + "'; ";
}
command += "load(_HEAD_JS_PATH);";

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

@ -202,9 +202,11 @@ class XPCShellTests(object):
]
if self.testingModulesDir:
# Escape backslashes in string literal.
sanitized = self.testingModulesDir.replace('\\', '\\\\')
self.xpcsCmd.extend([
'-e',
'const _TESTING_MODULES_DIR = "%s";' % self.testingModulesDir
'const _TESTING_MODULES_DIR = "%s";' % sanitized
])
self.xpcsCmd.extend(['-f', os.path.join(self.testharnessdir, 'head.js')])
@ -587,10 +589,30 @@ class XPCShellTests(object):
raise Exception("testsRootDir path does not exists: %s" %
testsRootDir)
# Try to guess modules directory.
# This somewhat grotesque hack allows the buildbot machines to find the
# modules directory without having to configure the buildbot hosts. This
# code path should never be executed in local runs because the build system
# should always set this argument.
if not testingModulesDir:
ourDir = os.path.dirname(__file__)
possible = os.path.join(ourDir, os.path.pardir, 'modules')
if os.path.isdir(possible):
testingModulesDir = possible
if testingModulesDir:
# The resource loader expects native paths. Depending on how we were
# invoked, a UNIX style path may sneak in on Windows. We try to
# normalize that.
testingModulesDir = os.path.normpath(testingModulesDir)
if not os.path.isabs(testingModulesDir):
testingModulesDir = os.path.abspath(testingModulesDir)
if not testingModulesDir.endswith(os.path.sep):
testingModulesDir += os.path.sep
self.xpcshell = xpcshell
self.xrePath = xrePath
self.appPath = appPath
@ -664,6 +686,7 @@ class XPCShellTests(object):
# dir and the test with path characters replaced with '.' (using Java
# class notation).
if testsRootDir is not None:
testsRootDir = os.path.normpath(testsRootDir)
if test["here"].find(testsRootDir) != 0:
raise Exception("testsRootDir is not a parent path of %s" %
test["here"])