2012-09-26 09:43:53 -07:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
2012-10-10 11:08:09 -07:00
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2012-10-10 11:08:09 -07:00
|
|
|
# Integrates the xpcshell test runner with mach.
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2013-08-19 16:07:40 -07:00
|
|
|
from __future__ import unicode_literals, print_function
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2013-03-06 20:41:22 -08:00
|
|
|
import mozpack.path
|
2013-08-22 18:54:26 -07:00
|
|
|
import logging
|
2012-10-10 11:08:09 -07:00
|
|
|
import os
|
2013-08-21 09:26:46 -07:00
|
|
|
import shutil
|
2012-11-14 10:05:18 -08:00
|
|
|
import sys
|
2014-03-11 07:08:25 -07:00
|
|
|
import urllib2
|
2012-09-26 09:43:53 -07:00
|
|
|
|
|
|
|
from StringIO import StringIO
|
|
|
|
|
2012-11-06 16:57:41 -08:00
|
|
|
from mozbuild.base import (
|
|
|
|
MachCommandBase,
|
|
|
|
MozbuildObject,
|
2013-12-13 20:20:39 -08:00
|
|
|
MachCommandConditions as conditions,
|
2012-11-06 16:57:41 -08:00
|
|
|
)
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2012-11-06 16:57:41 -08:00
|
|
|
from mach.decorators import (
|
2012-10-10 11:08:09 -07:00
|
|
|
CommandArgument,
|
|
|
|
CommandProvider,
|
|
|
|
Command,
|
|
|
|
)
|
|
|
|
|
2014-03-11 07:08:25 -07:00
|
|
|
ADB_NOT_FOUND = '''
|
|
|
|
The %s command requires the adb binary to be on your path.
|
|
|
|
|
|
|
|
If you have a B2G build, this can be found in
|
|
|
|
'%s/out/host/<platform>/bin'.
|
|
|
|
'''.lstrip()
|
|
|
|
|
|
|
|
BUSYBOX_URL = 'http://www.busybox.net/downloads/binaries/latest/busybox-armv7l'
|
|
|
|
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2012-11-14 10:05:18 -08:00
|
|
|
if sys.version_info[0] < 3:
|
|
|
|
unicode_type = unicode
|
|
|
|
else:
|
|
|
|
unicode_type = str
|
|
|
|
|
2013-08-22 18:54:26 -07:00
|
|
|
# Simple filter to omit the message emitted as a test file begins.
|
|
|
|
class TestStartFilter(logging.Filter):
|
|
|
|
def filter(self, record):
|
|
|
|
return not record.params['msg'].endswith("running test ...")
|
2012-11-14 10:05:18 -08:00
|
|
|
|
2012-11-28 12:19:32 -08:00
|
|
|
# This should probably be consolidated with similar classes in other test
|
|
|
|
# runners.
|
|
|
|
class InvalidTestPathError(Exception):
|
|
|
|
"""Exception raised when the test path is not valid."""
|
|
|
|
|
|
|
|
|
2012-09-26 09:43:53 -07:00
|
|
|
class XPCShellRunner(MozbuildObject):
|
|
|
|
"""Run xpcshell tests."""
|
2012-10-31 10:29:26 -07:00
|
|
|
def run_suite(self, **kwargs):
|
2014-02-10 13:11:23 -08:00
|
|
|
from manifestparser import TestManifest
|
|
|
|
manifest = TestManifest(manifests=[os.path.join(self.topobjdir,
|
|
|
|
'_tests', 'xpcshell', 'xpcshell.ini')])
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2012-12-05 15:42:11 -08:00
|
|
|
return self._run_xpcshell_harness(manifest=manifest, **kwargs)
|
2012-10-31 10:29:26 -07:00
|
|
|
|
2014-03-24 16:19:57 -07:00
|
|
|
def run_test(self, test_paths, interactive=False,
|
2013-08-19 16:07:40 -07:00
|
|
|
keep_going=False, sequential=False, shuffle=False,
|
2013-08-21 09:26:46 -07:00
|
|
|
debugger=None, debuggerArgs=None, debuggerInteractive=None,
|
2013-12-13 20:20:39 -08:00
|
|
|
rerun_failures=False,
|
|
|
|
# ignore parameters from other platforms' options
|
|
|
|
**kwargs):
|
2012-09-26 09:43:53 -07:00
|
|
|
"""Runs an individual xpcshell test."""
|
2013-10-22 16:54:40 -07:00
|
|
|
from mozbuild.testing import TestResolver
|
|
|
|
from manifestparser import TestManifest
|
|
|
|
|
2012-12-20 00:43:19 -08:00
|
|
|
# TODO Bug 794506 remove once mach integrates with virtualenv.
|
|
|
|
build_path = os.path.join(self.topobjdir, 'build')
|
|
|
|
if build_path not in sys.path:
|
|
|
|
sys.path.append(build_path)
|
2012-10-31 10:29:26 -07:00
|
|
|
|
2014-03-24 16:19:57 -07:00
|
|
|
if test_paths == ['all']:
|
2013-08-19 16:07:40 -07:00
|
|
|
self.run_suite(interactive=interactive,
|
|
|
|
keep_going=keep_going, shuffle=shuffle, sequential=sequential,
|
|
|
|
debugger=debugger, debuggerArgs=debuggerArgs,
|
2013-08-21 09:26:46 -07:00
|
|
|
debuggerInteractive=debuggerInteractive,
|
|
|
|
rerun_failures=rerun_failures)
|
2012-09-26 09:43:53 -07:00
|
|
|
return
|
|
|
|
|
2013-10-22 16:54:40 -07:00
|
|
|
resolver = self._spawn(TestResolver)
|
2014-03-24 16:19:57 -07:00
|
|
|
tests = list(resolver.resolve_tests(paths=test_paths, flavor='xpcshell',
|
2013-10-22 16:54:40 -07:00
|
|
|
cwd=self.cwd))
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2013-10-22 16:54:40 -07:00
|
|
|
if not tests:
|
|
|
|
raise InvalidTestPathError('We could not find an xpcshell test '
|
|
|
|
'for the passed test path. Please select a path that is '
|
|
|
|
'a test file or is a directory containing xpcshell tests.')
|
2013-03-19 09:42:08 -07:00
|
|
|
|
2013-10-22 16:54:40 -07:00
|
|
|
# Dynamically write out a manifest holding all the discovered tests.
|
|
|
|
manifest = TestManifest()
|
|
|
|
manifest.tests.extend(tests)
|
2012-11-28 12:19:32 -08:00
|
|
|
|
2012-09-26 09:43:53 -07:00
|
|
|
args = {
|
2012-10-31 10:29:26 -07:00
|
|
|
'interactive': interactive,
|
|
|
|
'keep_going': keep_going,
|
|
|
|
'shuffle': shuffle,
|
2013-08-14 10:17:11 -07:00
|
|
|
'sequential': sequential,
|
2013-08-19 16:07:40 -07:00
|
|
|
'debugger': debugger,
|
|
|
|
'debuggerArgs': debuggerArgs,
|
|
|
|
'debuggerInteractive': debuggerInteractive,
|
2013-10-22 16:54:40 -07:00
|
|
|
'rerun_failures': rerun_failures,
|
|
|
|
'manifest': manifest,
|
2012-09-26 09:43:53 -07:00
|
|
|
}
|
|
|
|
|
2012-12-05 15:42:11 -08:00
|
|
|
return self._run_xpcshell_harness(**args)
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2014-01-27 10:14:09 -08:00
|
|
|
def _run_xpcshell_harness(self, manifest,
|
2013-08-19 16:07:40 -07:00
|
|
|
test_path=None, shuffle=False, interactive=False,
|
|
|
|
keep_going=False, sequential=False,
|
2013-08-21 09:26:46 -07:00
|
|
|
debugger=None, debuggerArgs=None, debuggerInteractive=None,
|
|
|
|
rerun_failures=False):
|
2012-09-26 09:43:53 -07:00
|
|
|
|
|
|
|
# Obtain a reference to the xpcshell test runner.
|
|
|
|
import runxpcshelltests
|
|
|
|
|
|
|
|
dummy_log = StringIO()
|
|
|
|
xpcshell = runxpcshelltests.XPCShellTests(log=dummy_log)
|
|
|
|
self.log_manager.enable_unstructured()
|
|
|
|
|
2013-08-22 18:54:26 -07:00
|
|
|
xpcshell_filter = TestStartFilter()
|
|
|
|
self.log_manager.terminal_handler.addFilter(xpcshell_filter)
|
|
|
|
|
2012-09-26 09:43:53 -07:00
|
|
|
tests_dir = os.path.join(self.topobjdir, '_tests', 'xpcshell')
|
|
|
|
modules_dir = os.path.join(self.topobjdir, '_tests', 'modules')
|
2014-02-05 18:51:00 -08:00
|
|
|
# We want output from the test to be written immediately if we are only
|
|
|
|
# running a single test.
|
|
|
|
verbose_output = test_path is not None or (manifest and len(manifest.test_paths())==1)
|
2012-09-26 09:43:53 -07:00
|
|
|
|
|
|
|
args = {
|
2014-01-27 10:14:09 -08:00
|
|
|
'manifest': manifest,
|
2012-09-26 09:43:53 -07:00
|
|
|
'xpcshell': os.path.join(self.bindir, 'xpcshell'),
|
|
|
|
'mozInfo': os.path.join(self.topobjdir, 'mozinfo.json'),
|
|
|
|
'symbolsPath': os.path.join(self.distdir, 'crashreporter-symbols'),
|
2012-10-31 10:29:26 -07:00
|
|
|
'interactive': interactive,
|
|
|
|
'keepGoing': keep_going,
|
2012-09-26 09:43:53 -07:00
|
|
|
'logfiles': False,
|
2013-08-14 10:17:11 -07:00
|
|
|
'sequential': sequential,
|
2012-10-31 10:29:26 -07:00
|
|
|
'shuffle': shuffle,
|
2012-09-26 09:43:53 -07:00
|
|
|
'testsRootDir': tests_dir,
|
|
|
|
'testingModulesDir': modules_dir,
|
|
|
|
'profileName': 'firefox',
|
|
|
|
'verbose': test_path is not None,
|
2012-10-31 10:29:26 -07:00
|
|
|
'xunitFilename': os.path.join(self.statedir, 'xpchsell.xunit.xml'),
|
|
|
|
'xunitName': 'xpcshell',
|
2013-02-19 09:13:38 -08:00
|
|
|
'pluginsPath': os.path.join(self.distdir, 'plugins'),
|
2013-08-19 16:07:40 -07:00
|
|
|
'debugger': debugger,
|
|
|
|
'debuggerArgs': debuggerArgs,
|
|
|
|
'debuggerInteractive': debuggerInteractive,
|
2013-10-16 20:59:53 -07:00
|
|
|
'on_message': (lambda obj, msg: xpcshell.log.info(msg.decode('utf-8', 'replace'))) \
|
2014-02-05 18:51:00 -08:00
|
|
|
if verbose_output else None,
|
2012-09-26 09:43:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if test_path is not None:
|
|
|
|
args['testPath'] = test_path
|
|
|
|
|
2013-08-21 09:26:46 -07:00
|
|
|
# A failure manifest is written by default. If --rerun-failures is
|
|
|
|
# specified and a prior failure manifest is found, the prior manifest
|
|
|
|
# will be run. A new failure manifest is always written over any
|
|
|
|
# prior failure manifest.
|
|
|
|
failure_manifest_path = os.path.join(self.statedir, 'xpcshell.failures.ini')
|
|
|
|
rerun_manifest_path = os.path.join(self.statedir, 'xpcshell.rerun.ini')
|
|
|
|
if os.path.exists(failure_manifest_path) and rerun_failures:
|
|
|
|
shutil.move(failure_manifest_path, rerun_manifest_path)
|
|
|
|
args['manifest'] = rerun_manifest_path
|
|
|
|
elif os.path.exists(failure_manifest_path):
|
|
|
|
os.remove(failure_manifest_path)
|
|
|
|
elif rerun_failures:
|
|
|
|
print("No failures were found to re-run.")
|
|
|
|
return 0
|
|
|
|
args['failureManifest'] = failure_manifest_path
|
|
|
|
|
2012-11-14 10:05:18 -08:00
|
|
|
# Python through 2.7.2 has issues with unicode in some of the
|
|
|
|
# arguments. Work around that.
|
|
|
|
filtered_args = {}
|
|
|
|
for k, v in args.items():
|
|
|
|
if isinstance(v, unicode_type):
|
|
|
|
v = v.encode('utf-8')
|
|
|
|
|
|
|
|
if isinstance(k, unicode_type):
|
|
|
|
k = k.encode('utf-8')
|
|
|
|
|
|
|
|
filtered_args[k] = v
|
|
|
|
|
2012-12-05 15:42:11 -08:00
|
|
|
result = xpcshell.runTests(**filtered_args)
|
2012-09-26 09:43:53 -07:00
|
|
|
|
2013-08-22 18:54:26 -07:00
|
|
|
self.log_manager.terminal_handler.removeFilter(xpcshell_filter)
|
2012-09-26 09:43:53 -07:00
|
|
|
self.log_manager.disable_unstructured()
|
2012-10-10 11:08:09 -07:00
|
|
|
|
2013-08-20 16:07:33 -07:00
|
|
|
if not result and not xpcshell.sequential:
|
2013-08-15 15:22:35 -07:00
|
|
|
print("Tests were run in parallel. Try running with --sequential "
|
|
|
|
"to make sure the failures were not caused by this.")
|
2012-12-05 15:42:11 -08:00
|
|
|
return int(not result)
|
|
|
|
|
2013-12-13 20:20:39 -08:00
|
|
|
class AndroidXPCShellRunner(MozbuildObject):
|
|
|
|
"""Get specified DeviceManager"""
|
|
|
|
def get_devicemanager(self, devicemanager, ip, port, remote_test_root):
|
|
|
|
from mozdevice import devicemanagerADB, devicemanagerSUT
|
|
|
|
dm = None
|
|
|
|
if devicemanager == "adb":
|
|
|
|
if ip:
|
|
|
|
dm = devicemanagerADB.DeviceManagerADB(ip, port, packageName=None, deviceRoot=remote_test_root)
|
|
|
|
else:
|
|
|
|
dm = devicemanagerADB.DeviceManagerADB(packageName=None, deviceRoot=remote_test_root)
|
|
|
|
else:
|
|
|
|
if ip:
|
|
|
|
dm = devicemanagerSUT.DeviceManagerSUT(ip, port, deviceRoot=remote_test_root)
|
|
|
|
else:
|
|
|
|
raise Exception("You must provide a device IP to connect to via the --ip option")
|
|
|
|
return dm
|
|
|
|
|
|
|
|
"""Run Android xpcshell tests."""
|
|
|
|
def run_test(self,
|
2014-03-24 16:19:57 -07:00
|
|
|
test_paths, keep_going,
|
2013-12-13 20:20:39 -08:00
|
|
|
devicemanager, ip, port, remote_test_root, no_setup, local_apk,
|
|
|
|
# ignore parameters from other platforms' options
|
|
|
|
**kwargs):
|
|
|
|
# TODO Bug 794506 remove once mach integrates with virtualenv.
|
|
|
|
build_path = os.path.join(self.topobjdir, 'build')
|
|
|
|
if build_path not in sys.path:
|
|
|
|
sys.path.append(build_path)
|
|
|
|
|
|
|
|
import remotexpcshelltests
|
|
|
|
|
|
|
|
dm = self.get_devicemanager(devicemanager, ip, port, remote_test_root)
|
|
|
|
|
|
|
|
options = remotexpcshelltests.RemoteXPCShellOptions()
|
|
|
|
options.shuffle = False
|
|
|
|
options.sequential = True
|
|
|
|
options.interactive = False
|
|
|
|
options.debugger = None
|
|
|
|
options.debuggerArgs = None
|
|
|
|
options.setup = not no_setup
|
|
|
|
options.keepGoing = keep_going
|
|
|
|
options.objdir = self.topobjdir
|
|
|
|
options.localLib = os.path.join(self.topobjdir, 'dist/fennec')
|
|
|
|
options.localBin = os.path.join(self.topobjdir, 'dist/bin')
|
|
|
|
options.testingModulesDir = os.path.join(self.topobjdir, '_tests/modules')
|
|
|
|
options.mozInfo = os.path.join(self.topobjdir, 'mozinfo.json')
|
|
|
|
options.manifest = os.path.join(self.topobjdir, '_tests/xpcshell/xpcshell_android.ini')
|
|
|
|
options.symbolsPath = os.path.join(self.distdir, 'crashreporter-symbols')
|
|
|
|
if local_apk:
|
|
|
|
options.localAPK = local_apk
|
|
|
|
else:
|
|
|
|
for file in os.listdir(os.path.join(options.objdir, "dist")):
|
|
|
|
if file.endswith(".apk") and file.startswith("fennec"):
|
|
|
|
options.localAPK = os.path.join(options.objdir, "dist")
|
|
|
|
options.localAPK = os.path.join(options.localAPK, file)
|
|
|
|
print ("using APK: " + options.localAPK)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise Exception("You must specify an APK")
|
|
|
|
|
2014-03-24 16:19:57 -07:00
|
|
|
if test_paths == ['all']:
|
2013-12-13 20:20:39 -08:00
|
|
|
testdirs = []
|
|
|
|
options.testPath = None
|
|
|
|
options.verbose = False
|
|
|
|
else:
|
2014-03-24 16:19:57 -07:00
|
|
|
if len(test_paths) > 1:
|
|
|
|
print('Warning: only the first test path argument will be used.')
|
|
|
|
testdirs = test_paths[0]
|
|
|
|
options.testPath = test_paths[0]
|
2013-12-13 20:20:39 -08:00
|
|
|
options.verbose = True
|
|
|
|
dummy_log = StringIO()
|
|
|
|
xpcshell = remotexpcshelltests.XPCShellRemote(dm, options, args=testdirs, log=dummy_log)
|
|
|
|
self.log_manager.enable_unstructured()
|
|
|
|
|
|
|
|
xpcshell_filter = TestStartFilter()
|
|
|
|
self.log_manager.terminal_handler.addFilter(xpcshell_filter)
|
|
|
|
|
|
|
|
result = xpcshell.runTests(xpcshell='xpcshell',
|
|
|
|
testClass=remotexpcshelltests.RemoteXPCShellTestThread,
|
|
|
|
testdirs=testdirs,
|
|
|
|
mobileArgs=xpcshell.mobileArgs,
|
|
|
|
**options.__dict__)
|
|
|
|
|
|
|
|
self.log_manager.terminal_handler.removeFilter(xpcshell_filter)
|
|
|
|
self.log_manager.disable_unstructured()
|
|
|
|
|
|
|
|
return int(not result)
|
2012-10-10 11:08:09 -07:00
|
|
|
|
2014-03-11 07:08:25 -07:00
|
|
|
class B2GXPCShellRunner(MozbuildObject):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
MozbuildObject.__init__(self, *args, **kwargs)
|
|
|
|
|
|
|
|
# TODO Bug 794506 remove once mach integrates with virtualenv.
|
|
|
|
build_path = os.path.join(self.topobjdir, 'build')
|
|
|
|
if build_path not in sys.path:
|
|
|
|
sys.path.append(build_path)
|
|
|
|
|
|
|
|
build_path = os.path.join(self.topsrcdir, 'build')
|
|
|
|
if build_path not in sys.path:
|
|
|
|
sys.path.append(build_path)
|
|
|
|
|
|
|
|
self.tests_dir = os.path.join(self.topobjdir, '_tests')
|
|
|
|
self.xpcshell_dir = os.path.join(self.tests_dir, 'xpcshell')
|
|
|
|
self.bin_dir = os.path.join(self.distdir, 'bin')
|
|
|
|
|
|
|
|
def _download_busybox(self, b2g_home):
|
|
|
|
system_bin = os.path.join(b2g_home, 'out', 'target', 'product', 'generic', 'system', 'bin')
|
|
|
|
busybox_path = os.path.join(system_bin, 'busybox')
|
|
|
|
|
|
|
|
if os.path.isfile(busybox_path):
|
|
|
|
return busybox_path
|
|
|
|
|
|
|
|
if not os.path.isdir(system_bin):
|
|
|
|
os.makedirs(system_bin)
|
|
|
|
|
|
|
|
try:
|
|
|
|
data = urllib2.urlopen(BUSYBOX_URL)
|
|
|
|
except urllib2.URLError:
|
|
|
|
print('There was a problem downloading busybox. Proceeding without it,' \
|
|
|
|
'initial setup will be slow.')
|
|
|
|
return
|
|
|
|
|
|
|
|
with open(busybox_path, 'wb') as f:
|
|
|
|
f.write(data.read())
|
|
|
|
return busybox_path
|
|
|
|
|
2014-03-24 16:19:57 -07:00
|
|
|
def run_test(self, test_paths, b2g_home=None, busybox=None,
|
2014-03-11 07:08:25 -07:00
|
|
|
# ignore parameters from other platforms' options
|
|
|
|
**kwargs):
|
|
|
|
try:
|
|
|
|
import which
|
|
|
|
which.which('adb')
|
|
|
|
except which.WhichError:
|
|
|
|
# TODO Find adb automatically if it isn't on the path
|
|
|
|
print(ADB_NOT_FOUND % ('mochitest-remote', b2g_home))
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
test_path = None
|
2014-03-24 16:19:57 -07:00
|
|
|
if test_paths:
|
|
|
|
if len(test_paths) > 1:
|
|
|
|
print('Warning: Only the first test path will be used.')
|
|
|
|
|
|
|
|
test_path = self._wrap_path_argument(test_paths[0]).relpath()
|
2014-03-11 07:08:25 -07:00
|
|
|
|
|
|
|
import runtestsb2g
|
|
|
|
parser = runtestsb2g.B2GOptions()
|
|
|
|
options, args = parser.parse_args([])
|
|
|
|
|
|
|
|
options.b2g_path = b2g_home
|
|
|
|
options.busybox = busybox or os.environ.get('BUSYBOX')
|
|
|
|
options.emulator = 'arm'
|
|
|
|
options.localLib = self.bin_dir
|
|
|
|
options.localBin = self.bin_dir
|
|
|
|
options.logcat_dir = self.xpcshell_dir
|
|
|
|
options.manifest = os.path.join(self.xpcshell_dir, 'xpcshell_b2g.ini')
|
|
|
|
options.mozInfo = os.path.join(self.topobjdir, 'mozinfo.json')
|
|
|
|
options.objdir = self.topobjdir
|
|
|
|
options.symbolsPath = os.path.join(self.distdir, 'crashreporter-symbols'),
|
|
|
|
options.testingModulesDir = os.path.join(self.tests_dir, 'modules')
|
|
|
|
options.testsRootDir = self.xpcshell_dir
|
|
|
|
options.testPath = test_path
|
|
|
|
options.use_device_libs = True
|
|
|
|
|
|
|
|
if not options.busybox:
|
|
|
|
options.busybox = self._download_busybox(b2g_home)
|
|
|
|
|
|
|
|
return runtestsb2g.run_remote_xpcshell(parser, options, args)
|
|
|
|
|
|
|
|
def is_platform_supported(cls):
|
|
|
|
"""Must have a Firefox, Android or B2G build."""
|
|
|
|
return conditions.is_android(cls) or \
|
|
|
|
conditions.is_b2g(cls) or \
|
|
|
|
conditions.is_firefox(cls)
|
|
|
|
|
2012-10-10 11:08:09 -07:00
|
|
|
@CommandProvider
|
2012-11-06 16:57:41 -08:00
|
|
|
class MachCommands(MachCommandBase):
|
2014-03-11 07:08:25 -07:00
|
|
|
def __init__(self, context):
|
|
|
|
MachCommandBase.__init__(self, context)
|
|
|
|
|
|
|
|
for attr in ('b2g_home', 'device_name'):
|
|
|
|
setattr(self, attr, getattr(context, attr, None))
|
|
|
|
|
2013-05-08 17:56:30 -07:00
|
|
|
@Command('xpcshell-test', category='testing',
|
2014-03-11 07:08:25 -07:00
|
|
|
conditions=[is_platform_supported],
|
2013-05-08 17:56:30 -07:00
|
|
|
description='Run XPCOM Shell tests.')
|
2014-03-24 16:19:57 -07:00
|
|
|
@CommandArgument('test_paths', default='all', nargs='*', metavar='TEST',
|
2012-10-10 11:08:09 -07:00
|
|
|
help='Test to run. Can be specified as a single JS file, a directory, '
|
|
|
|
'or omitted. If omitted, the entire test suite is executed.')
|
2013-08-19 16:07:40 -07:00
|
|
|
@CommandArgument("--debugger", default=None, metavar='DEBUGGER',
|
|
|
|
help = "Run xpcshell under the given debugger.")
|
|
|
|
@CommandArgument("--debugger-args", default=None, metavar='ARGS', type=str,
|
|
|
|
dest = "debuggerArgs",
|
|
|
|
help = "pass the given args to the debugger _before_ "
|
|
|
|
"the application on the command line")
|
|
|
|
@CommandArgument("--debugger-interactive", action = "store_true",
|
|
|
|
dest = "debuggerInteractive",
|
|
|
|
help = "prevents the test harness from redirecting "
|
|
|
|
"stdout and stderr for interactive debuggers")
|
2012-10-31 10:29:26 -07:00
|
|
|
@CommandArgument('--interactive', '-i', action='store_true',
|
|
|
|
help='Open an xpcshell prompt before running tests.')
|
|
|
|
@CommandArgument('--keep-going', '-k', action='store_true',
|
|
|
|
help='Continue running tests after a SIGINT is received.')
|
2013-08-14 10:17:11 -07:00
|
|
|
@CommandArgument('--sequential', action='store_true',
|
|
|
|
help='Run the tests sequentially.')
|
2012-10-31 10:29:26 -07:00
|
|
|
@CommandArgument('--shuffle', '-s', action='store_true',
|
|
|
|
help='Randomize the execution order of tests.')
|
2013-08-21 09:26:46 -07:00
|
|
|
@CommandArgument('--rerun-failures', action='store_true',
|
|
|
|
help='Reruns failures from last time.')
|
2013-12-13 20:20:39 -08:00
|
|
|
@CommandArgument('--devicemanager', default='adb', type=str,
|
|
|
|
help='(Android) Type of devicemanager to use for communication: adb or sut')
|
|
|
|
@CommandArgument('--ip', type=str, default=None,
|
|
|
|
help='(Android) IP address of device')
|
|
|
|
@CommandArgument('--port', type=int, default=20701,
|
|
|
|
help='(Android) Port of device')
|
|
|
|
@CommandArgument('--remote_test_root', type=str, default=None,
|
|
|
|
help='(Android) Remote test root such as /mnt/sdcard or /data/local')
|
|
|
|
@CommandArgument('--no-setup', action='store_true',
|
|
|
|
help='(Android) Do not copy files to device')
|
|
|
|
@CommandArgument('--local-apk', type=str, default=None,
|
|
|
|
help='(Android) Use specified Fennec APK')
|
2014-03-11 07:08:25 -07:00
|
|
|
@CommandArgument('--busybox', type=str, default=None,
|
|
|
|
help='(B2G) Path to busybox binary (speeds up installation of tests).')
|
2012-10-10 11:08:09 -07:00
|
|
|
def run_xpcshell_test(self, **params):
|
2013-10-01 09:36:44 -07:00
|
|
|
from mozbuild.controller.building import BuildDriver
|
|
|
|
|
2012-11-02 10:32:40 -07:00
|
|
|
# We should probably have a utility function to ensure the tree is
|
|
|
|
# ready to run tests. Until then, we just create the state dir (in
|
|
|
|
# case the tree wasn't built with mach).
|
|
|
|
self._ensure_state_subdir_exists('.')
|
|
|
|
|
2013-10-01 09:36:44 -07:00
|
|
|
driver = self._spawn(BuildDriver)
|
|
|
|
driver.install_tests(remove=False)
|
|
|
|
|
2013-12-13 20:20:39 -08:00
|
|
|
if conditions.is_android(self):
|
|
|
|
xpcshell = self._spawn(AndroidXPCShellRunner)
|
2014-03-11 07:08:25 -07:00
|
|
|
elif conditions.is_b2g(self):
|
|
|
|
xpcshell = self._spawn(B2GXPCShellRunner)
|
|
|
|
params['b2g_home'] = self.b2g_home
|
2013-12-13 20:20:39 -08:00
|
|
|
else:
|
|
|
|
xpcshell = self._spawn(XPCShellRunner)
|
2013-10-22 16:54:40 -07:00
|
|
|
xpcshell.cwd = self._mach_context.cwd
|
2012-11-28 12:19:32 -08:00
|
|
|
|
|
|
|
try:
|
|
|
|
return xpcshell.run_test(**params)
|
|
|
|
except InvalidTestPathError as e:
|
|
|
|
print(e.message)
|
|
|
|
return 1
|