2012-04-27 11:44:59 -07:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# 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/.
|
|
|
|
|
2013-10-01 07:32:58 -07:00
|
|
|
import json
|
2012-04-27 11:44:59 -07:00
|
|
|
import os
|
2013-07-26 11:40:04 -07:00
|
|
|
import posixpath
|
2013-01-04 10:41:34 -08:00
|
|
|
import shutil
|
2012-04-27 11:44:59 -07:00
|
|
|
import sys
|
|
|
|
import tempfile
|
2013-01-04 10:41:34 -08:00
|
|
|
import threading
|
2012-06-15 14:13:04 -07:00
|
|
|
import traceback
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2013-08-26 14:17:51 -07:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
2013-03-28 13:42:49 -07:00
|
|
|
sys.path.insert(0, here)
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2013-08-14 10:57:43 -07:00
|
|
|
from runtests import Mochitest
|
2013-07-26 11:40:04 -07:00
|
|
|
from runtests import MochitestUtilsMixin
|
2014-07-17 00:02:00 -07:00
|
|
|
from runtests import MessageLogger
|
|
|
|
from runtests import MochitestFormatter
|
2013-07-26 11:40:04 -07:00
|
|
|
from mochitest_options import B2GOptions, MochitestOptions
|
2012-04-27 11:44:59 -07:00
|
|
|
from marionette import Marionette
|
2013-08-14 10:57:43 -07:00
|
|
|
from mozprofile import Profile, Preferences
|
2013-07-26 11:40:04 -07:00
|
|
|
import mozinfo
|
2014-07-17 00:02:00 -07:00
|
|
|
from mozlog.structured.handlers import StreamHandler
|
|
|
|
from mozlog.structured.structuredlog import StructuredLogger
|
2013-07-26 11:40:04 -07:00
|
|
|
|
2014-07-17 00:02:00 -07:00
|
|
|
log = StructuredLogger('Mochitest')
|
|
|
|
stream_handler = StreamHandler(stream=sys.stdout, formatter=MochitestFormatter())
|
|
|
|
log.add_handler(stream_handler)
|
2013-07-26 11:40:04 -07:00
|
|
|
|
|
|
|
class B2GMochitest(MochitestUtilsMixin):
|
2014-06-19 11:17:26 -07:00
|
|
|
marionette = None
|
|
|
|
|
|
|
|
def __init__(self, marionette_args,
|
2013-07-26 11:40:04 -07:00
|
|
|
out_of_process=True,
|
|
|
|
profile_data_dir=None,
|
|
|
|
locations=os.path.join(here, 'server-locations.txt')):
|
|
|
|
super(B2GMochitest, self).__init__()
|
2014-06-19 11:17:26 -07:00
|
|
|
self.marionette_args = marionette_args
|
2013-07-26 11:40:04 -07:00
|
|
|
self.out_of_process = out_of_process
|
2014-03-14 11:25:41 -07:00
|
|
|
self.locations_file = locations
|
2013-03-28 13:42:49 -07:00
|
|
|
self.preferences = []
|
|
|
|
self.webapps = None
|
2013-07-26 11:40:04 -07:00
|
|
|
self.test_script = os.path.join(here, 'b2g_start_script.js')
|
|
|
|
self.test_script_args = [self.out_of_process]
|
|
|
|
self.product = 'b2g'
|
2013-03-28 13:42:49 -07:00
|
|
|
|
2014-07-17 00:02:00 -07:00
|
|
|
# structured logging
|
|
|
|
self.message_logger = MessageLogger(logger=log)
|
|
|
|
|
2013-03-28 13:42:49 -07:00
|
|
|
if profile_data_dir:
|
|
|
|
self.preferences = [os.path.join(profile_data_dir, f)
|
|
|
|
for f in os.listdir(profile_data_dir) if f.startswith('pref')]
|
|
|
|
self.webapps = [os.path.join(profile_data_dir, f)
|
|
|
|
for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
|
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
# mozinfo is populated by the parent class
|
|
|
|
if mozinfo.info['debug']:
|
|
|
|
self.SERVER_STARTUP_TIMEOUT = 180
|
2013-01-04 10:41:34 -08:00
|
|
|
else:
|
2013-07-26 11:40:04 -07:00
|
|
|
self.SERVER_STARTUP_TIMEOUT = 90
|
2013-03-22 08:41:07 -07:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
def setup_common_options(self, options):
|
|
|
|
test_url = self.buildTestPath(options)
|
2014-06-16 11:51:22 -07:00
|
|
|
# For B2G emulators buildURLOptions has been called
|
|
|
|
# without calling buildTestPath first and that
|
|
|
|
# causes manifestFile not to be set
|
|
|
|
if not "manifestFile=tests.json" in self.urlOpts:
|
|
|
|
self.urlOpts.append("manifestFile=%s" % options.manifestFile)
|
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
if len(self.urlOpts) > 0:
|
|
|
|
test_url += "?" + "&".join(self.urlOpts)
|
|
|
|
self.test_script_args.append(test_url)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2014-07-04 04:55:00 -07:00
|
|
|
def buildTestPath(self, options, testsToFilter=None):
|
2014-06-16 11:51:22 -07:00
|
|
|
if options.manifestFile != 'tests.json':
|
2014-07-04 04:55:00 -07:00
|
|
|
super(B2GMochitest, self).buildTestPath(options, testsToFilter, disabled=False)
|
2014-03-18 08:03:51 -07:00
|
|
|
return self.buildTestURL(options)
|
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
def build_profile(self, options):
|
2013-03-28 13:42:49 -07:00
|
|
|
# preferences
|
|
|
|
prefs = {}
|
|
|
|
for path in self.preferences:
|
|
|
|
prefs.update(Preferences.read_prefs(path))
|
|
|
|
|
|
|
|
for v in options.extraPrefs:
|
|
|
|
thispref = v.split("=", 1)
|
|
|
|
if len(thispref) < 2:
|
|
|
|
print "Error: syntax error in --setpref=" + v
|
|
|
|
sys.exit(1)
|
|
|
|
prefs[thispref[0]] = thispref[1]
|
|
|
|
|
|
|
|
# interpolate the preferences
|
|
|
|
interpolation = { "server": "%s:%s" % (options.webServer, options.httpPort),
|
2013-07-26 11:40:04 -07:00
|
|
|
"OOP": "true" if self.out_of_process else "false" }
|
2013-03-28 13:42:49 -07:00
|
|
|
prefs = json.loads(json.dumps(prefs) % interpolation)
|
2013-04-09 17:31:42 -07:00
|
|
|
for pref in prefs:
|
|
|
|
prefs[pref] = Preferences.cast(prefs[pref])
|
2013-03-28 13:42:49 -07:00
|
|
|
|
2013-04-09 17:13:32 -07:00
|
|
|
kwargs = {
|
|
|
|
'addons': self.getExtensionsToInstall(options),
|
|
|
|
'apps': self.webapps,
|
2014-03-14 11:25:41 -07:00
|
|
|
'locations': self.locations_file,
|
2013-04-09 17:13:32 -07:00
|
|
|
'preferences': prefs,
|
|
|
|
'proxy': {"remote": options.webServer}
|
|
|
|
}
|
|
|
|
|
|
|
|
if options.profile:
|
|
|
|
self.profile = Profile.clone(options.profile, **kwargs)
|
|
|
|
else:
|
|
|
|
self.profile = Profile(**kwargs)
|
2013-03-28 13:42:49 -07:00
|
|
|
|
|
|
|
options.profilePath = self.profile.profile
|
|
|
|
# TODO bug 839108 - mozprofile should probably handle this
|
|
|
|
manifest = self.addChromeToProfile(options)
|
|
|
|
self.copyExtraFilesToProfile(options)
|
|
|
|
return manifest
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
def run_tests(self, options):
|
|
|
|
""" Prepare, configure, run tests and cleanup """
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
manifest = self.build_profile(options)
|
2014-06-23 02:24:00 -07:00
|
|
|
self.leak_report_file = os.path.join(options.profilePath, "runtests_leaks.log")
|
2013-01-03 17:37:26 -08:00
|
|
|
|
2014-07-17 00:02:00 -07:00
|
|
|
# configuring the message logger's buffering
|
|
|
|
self.message_logger.buffering = options.quiet
|
|
|
|
|
2013-10-18 12:47:35 -07:00
|
|
|
if options.debugger or not options.autorun:
|
2013-07-26 11:40:04 -07:00
|
|
|
timeout = None
|
|
|
|
else:
|
2013-10-18 12:47:35 -07:00
|
|
|
if not options.timeout:
|
|
|
|
if mozinfo.info['debug']:
|
|
|
|
options.timeout = 420
|
|
|
|
else:
|
|
|
|
options.timeout = 300
|
|
|
|
timeout = options.timeout + 30.0
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
log.info("runtestsb2g.py | Running tests: start.")
|
|
|
|
status = 0
|
|
|
|
try:
|
2014-07-17 00:02:00 -07:00
|
|
|
def on_output(line):
|
|
|
|
messages = self.message_logger.write(line)
|
|
|
|
for message in messages:
|
|
|
|
if message['action'] == 'test_start':
|
|
|
|
self.runner.last_test = message['test']
|
|
|
|
|
|
|
|
# The logging will be handled by on_output, so we set the stream to None
|
|
|
|
process_args = {'processOutputLine': on_output,
|
|
|
|
'stream': None}
|
|
|
|
self.marionette_args['process_args'] = process_args
|
2014-06-19 11:17:26 -07:00
|
|
|
self.marionette_args['profile'] = self.profile
|
2014-07-17 00:02:00 -07:00
|
|
|
|
2014-06-19 11:17:26 -07:00
|
|
|
self.marionette = Marionette(**self.marionette_args)
|
|
|
|
self.runner = self.marionette.runner
|
|
|
|
self.app_ctx = self.runner.app_ctx
|
|
|
|
|
|
|
|
self.remote_log = posixpath.join(self.app_ctx.remote_test_root,
|
|
|
|
'log', 'mochitest.log')
|
|
|
|
if not self.app_ctx.dm.dirExists(posixpath.dirname(self.remote_log)):
|
|
|
|
self.app_ctx.dm.mkDirs(self.remote_log)
|
|
|
|
|
|
|
|
self.startServers(options, None)
|
|
|
|
self.buildURLOptions(options, {'MOZ_HIDE_RESULTS_TABLE': '1'})
|
|
|
|
self.test_script_args.append(not options.emulator)
|
|
|
|
self.test_script_args.append(options.wifi)
|
|
|
|
|
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
self.runner.start(outputTimeout=timeout)
|
2014-06-19 11:17:26 -07:00
|
|
|
|
|
|
|
self.marionette.wait_for_port()
|
|
|
|
self.marionette.start_session()
|
|
|
|
self.marionette.set_context(self.marionette.CONTEXT_CHROME)
|
|
|
|
|
|
|
|
# Disable offline status management (bug 777145), otherwise the network
|
|
|
|
# will be 'offline' when the mochitests start. Presumably, the network
|
|
|
|
# won't be offline on a real device, so we only do this for emulators.
|
|
|
|
self.marionette.execute_script("""
|
|
|
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
|
|
|
Services.io.manageOfflineStatus = false;
|
|
|
|
Services.io.offline = false;
|
|
|
|
""")
|
|
|
|
|
|
|
|
if os.path.isfile(self.test_script):
|
|
|
|
with open(self.test_script, 'r') as script:
|
|
|
|
self.marionette.execute_script(script.read(),
|
|
|
|
script_args=self.test_script_args)
|
|
|
|
else:
|
|
|
|
self.marionette.execute_script(self.test_script,
|
|
|
|
script_args=self.test_script_args)
|
2013-09-30 08:05:46 -07:00
|
|
|
status = self.runner.wait()
|
2014-07-17 00:02:00 -07:00
|
|
|
|
2013-09-30 08:05:46 -07:00
|
|
|
if status is None:
|
|
|
|
# the runner has timed out
|
|
|
|
status = 124
|
2013-07-26 11:40:04 -07:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
log.info("runtests.py | Received keyboard interrupt.\n");
|
|
|
|
status = -1
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
2013-09-19 05:20:17 -07:00
|
|
|
log.error("Automation Error: Received unexpected exception while running application\n")
|
2014-06-19 11:17:26 -07:00
|
|
|
if hasattr(self, 'runner'):
|
|
|
|
self.runner.check_for_crashes()
|
2013-07-26 11:40:04 -07:00
|
|
|
status = 1
|
|
|
|
|
2014-03-14 11:25:41 -07:00
|
|
|
self.stopServers()
|
2013-07-26 11:40:04 -07:00
|
|
|
|
|
|
|
log.info("runtestsb2g.py | Running tests: end.")
|
|
|
|
|
|
|
|
if manifest is not None:
|
|
|
|
self.cleanup(manifest, options)
|
|
|
|
return status
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-07-25 04:01:13 -07:00
|
|
|
def getGMPPluginPath(self, options):
|
|
|
|
# TODO: bug 1043403
|
|
|
|
return None
|
|
|
|
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-06-16 11:51:22 -07:00
|
|
|
class B2GDeviceMochitest(B2GMochitest, Mochitest):
|
2014-06-19 11:17:26 -07:00
|
|
|
remote_log = None
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-06-19 11:17:26 -07:00
|
|
|
def __init__(self, marionette_args, profile_data_dir,
|
2013-07-26 11:40:04 -07:00
|
|
|
local_binary_dir, remote_test_root=None, remote_log_file=None):
|
2014-06-19 11:17:26 -07:00
|
|
|
B2GMochitest.__init__(self, marionette_args, out_of_process=True, profile_data_dir=profile_data_dir)
|
2013-07-26 11:40:04 -07:00
|
|
|
self.local_log = None
|
|
|
|
self.local_binary_dir = local_binary_dir
|
2012-08-08 17:29:26 -07:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
def cleanup(self, manifest, options):
|
|
|
|
if self.local_log:
|
2014-06-19 11:17:26 -07:00
|
|
|
self.app_ctx.dm.getFile(self.remote_log, self.local_log)
|
|
|
|
self.app_ctx.dm.removeFile(self.remote_log)
|
2012-06-05 15:17:26 -07:00
|
|
|
|
2012-04-27 11:44:59 -07:00
|
|
|
if options.pidFile != "":
|
|
|
|
try:
|
|
|
|
os.remove(options.pidFile)
|
|
|
|
os.remove(options.pidFile + ".xpcshell.pid")
|
|
|
|
except:
|
|
|
|
print "Warning: cleaning up pidfile '%s' was unsuccessful from the test harness" % options.pidFile
|
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
# stop and clean up the runner
|
|
|
|
if getattr(self, 'runner', False):
|
2014-06-19 11:17:26 -07:00
|
|
|
if self.local_log:
|
|
|
|
self.app_ctx.dm.getFile(self.remote_log, self.local_log)
|
|
|
|
self.app_ctx.dm.removeFile(self.remote_log)
|
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
self.runner.cleanup()
|
|
|
|
self.runner = None
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-03-14 11:25:41 -07:00
|
|
|
def startServers(self, options, debuggerInfo):
|
|
|
|
""" Create the servers on the host and start them up """
|
|
|
|
savedXre = options.xrePath
|
|
|
|
savedUtility = options.utilityPath
|
|
|
|
savedProfie = options.profilePath
|
|
|
|
options.xrePath = self.local_binary_dir
|
|
|
|
options.utilityPath = self.local_binary_dir
|
|
|
|
options.profilePath = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
MochitestUtilsMixin.startServers(self, options, debuggerInfo)
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-03-14 11:25:41 -07:00
|
|
|
options.xrePath = savedXre
|
|
|
|
options.utilityPath = savedUtility
|
|
|
|
options.profilePath = savedProfie
|
2012-04-27 11:44:59 -07:00
|
|
|
|
|
|
|
def buildURLOptions(self, options, env):
|
2013-07-26 11:40:04 -07:00
|
|
|
self.local_log = options.logFile
|
|
|
|
options.logFile = self.remote_log
|
2013-03-28 13:42:49 -07:00
|
|
|
options.profilePath = self.profile.profile
|
2014-06-16 11:51:22 -07:00
|
|
|
super(B2GDeviceMochitest, self).buildURLOptions(options, env)
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
self.setup_common_options(options)
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-06-19 11:17:26 -07:00
|
|
|
options.profilePath = self.app_ctx.remote_profile
|
2013-07-26 11:40:04 -07:00
|
|
|
options.logFile = self.local_log
|
2012-04-27 11:44:59 -07:00
|
|
|
|
|
|
|
|
2013-08-14 10:57:43 -07:00
|
|
|
class B2GDesktopMochitest(B2GMochitest, Mochitest):
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2014-06-19 11:17:26 -07:00
|
|
|
def __init__(self, marionette_args, profile_data_dir):
|
|
|
|
B2GMochitest.__init__(self, marionette_args, out_of_process=False, profile_data_dir=profile_data_dir)
|
2013-09-26 06:58:08 -07:00
|
|
|
Mochitest.__init__(self)
|
2014-03-14 11:25:41 -07:00
|
|
|
self.certdbNew = True
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2013-08-14 10:57:43 -07:00
|
|
|
def runMarionetteScript(self, marionette, test_script, test_script_args):
|
2013-01-04 10:41:34 -08:00
|
|
|
assert(marionette.wait_for_port())
|
|
|
|
marionette.start_session()
|
|
|
|
marionette.set_context(marionette.CONTEXT_CHROME)
|
2013-08-14 10:57:43 -07:00
|
|
|
|
|
|
|
if os.path.isfile(test_script):
|
|
|
|
f = open(test_script, 'r')
|
|
|
|
test_script = f.read()
|
|
|
|
f.close()
|
|
|
|
self.marionette.execute_script(test_script,
|
|
|
|
script_args=test_script_args)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
|
|
|
def startTests(self):
|
|
|
|
# This is run in a separate thread because otherwise, the app's
|
|
|
|
# stdout buffer gets filled (which gets drained only after this
|
|
|
|
# function returns, by waitForFinish), which causes the app to hang.
|
2014-06-19 11:17:26 -07:00
|
|
|
self.marionette = Marionette(**self.marionette_args)
|
2013-01-04 10:41:34 -08:00
|
|
|
thread = threading.Thread(target=self.runMarionetteScript,
|
2013-07-26 11:40:04 -07:00
|
|
|
args=(self.marionette,
|
2013-08-14 10:57:43 -07:00
|
|
|
self.test_script,
|
|
|
|
self.test_script_args))
|
2013-01-04 10:41:34 -08:00
|
|
|
thread.start()
|
|
|
|
|
|
|
|
def buildURLOptions(self, options, env):
|
2014-06-16 11:51:22 -07:00
|
|
|
super(B2GDesktopMochitest, self).buildURLOptions(options, env)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
self.setup_common_options(options)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
|
|
|
# Copy the extensions to the B2G bundles dir.
|
|
|
|
extensionDir = os.path.join(options.profilePath, 'extensions', 'staged')
|
|
|
|
bundlesDir = os.path.join(os.path.dirname(options.app),
|
|
|
|
'distribution', 'bundles')
|
|
|
|
|
|
|
|
for filename in os.listdir(extensionDir):
|
|
|
|
shutil.rmtree(os.path.join(bundlesDir, filename), True)
|
|
|
|
shutil.copytree(os.path.join(extensionDir, filename),
|
|
|
|
os.path.join(bundlesDir, filename))
|
|
|
|
|
2013-08-14 10:57:43 -07:00
|
|
|
def buildProfile(self, options):
|
|
|
|
return self.build_profile(options)
|
|
|
|
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
def run_remote_mochitests(parser, options):
|
2012-04-27 11:44:59 -07:00
|
|
|
# create our Marionette instance
|
2014-06-19 11:17:26 -07:00
|
|
|
marionette_args = {
|
|
|
|
'adb_path': options.adbPath,
|
|
|
|
'emulator': options.emulator,
|
|
|
|
'no_window': options.noWindow,
|
|
|
|
'logdir': options.logdir,
|
|
|
|
'busybox': options.busybox,
|
|
|
|
'symbols_path': options.symbolsPath,
|
|
|
|
'sdcard': options.sdcard,
|
|
|
|
'homedir': options.b2gPath,
|
|
|
|
}
|
2012-04-27 11:44:59 -07:00
|
|
|
if options.marionette:
|
2013-01-04 10:41:34 -08:00
|
|
|
host, port = options.marionette.split(':')
|
2014-06-19 11:17:26 -07:00
|
|
|
marionette_args['host'] = host
|
|
|
|
marionette_args['port'] = int(port)
|
2014-02-20 13:56:57 -08:00
|
|
|
|
2013-07-26 11:40:04 -07:00
|
|
|
options = parser.verifyRemoteOptions(options)
|
2012-04-27 11:44:59 -07:00
|
|
|
if (options == None):
|
|
|
|
print "ERROR: Invalid options specified, use --help for a list of valid options"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2014-06-19 11:17:26 -07:00
|
|
|
mochitest = B2GDeviceMochitest(marionette_args, options.profile_data_dir, options.xrePath,
|
2013-07-26 11:40:04 -07:00
|
|
|
remote_log_file=options.remoteLogFile)
|
2012-04-27 11:44:59 -07:00
|
|
|
|
|
|
|
options = parser.verifyOptions(options, mochitest)
|
|
|
|
if (options == None):
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
retVal = 1
|
|
|
|
try:
|
2012-08-08 17:29:26 -07:00
|
|
|
mochitest.cleanup(None, options)
|
2013-07-26 11:40:04 -07:00
|
|
|
retVal = mochitest.run_tests(options)
|
2012-04-27 11:44:59 -07:00
|
|
|
except:
|
2012-11-05 05:03:55 -08:00
|
|
|
print "Automation Error: Exception caught while running tests"
|
2012-06-15 14:13:04 -07:00
|
|
|
traceback.print_exc()
|
2014-03-14 11:25:41 -07:00
|
|
|
mochitest.stopServers()
|
2012-04-27 11:44:59 -07:00
|
|
|
try:
|
|
|
|
mochitest.cleanup(None, options)
|
|
|
|
except:
|
|
|
|
pass
|
2012-11-20 07:24:28 -08:00
|
|
|
retVal = 1
|
2012-04-27 11:44:59 -07:00
|
|
|
|
2014-07-29 05:11:00 -07:00
|
|
|
mochitest.message_logger.finish()
|
|
|
|
|
2012-04-27 11:44:59 -07:00
|
|
|
sys.exit(retVal)
|
|
|
|
|
2013-01-04 10:41:34 -08:00
|
|
|
def run_desktop_mochitests(parser, options):
|
|
|
|
# create our Marionette instance
|
2014-06-19 11:17:26 -07:00
|
|
|
marionette_args = {}
|
2013-01-04 10:41:34 -08:00
|
|
|
if options.marionette:
|
|
|
|
host, port = options.marionette.split(':')
|
2014-06-19 11:17:26 -07:00
|
|
|
marionette_args['host'] = host
|
|
|
|
marionette_args['port'] = int(port)
|
|
|
|
mochitest = B2GDesktopMochitest(marionette_args, options.profile_data_dir)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2013-10-10 10:25:59 -07:00
|
|
|
# add a -bin suffix if b2g-bin exists, but just b2g was specified
|
|
|
|
if options.app[-4:] != '-bin':
|
|
|
|
if os.path.isfile("%s-bin" % options.app):
|
|
|
|
options.app = "%s-bin" % options.app
|
2013-01-04 10:41:34 -08:00
|
|
|
|
|
|
|
options = MochitestOptions.verifyOptions(parser, options, mochitest)
|
|
|
|
if options == None:
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if options.desktop and not options.profile:
|
|
|
|
raise Exception("must specify --profile when specifying --desktop")
|
|
|
|
|
2014-03-11 13:22:34 -07:00
|
|
|
options.browserArgs += ['-marionette']
|
|
|
|
|
2014-07-29 05:11:00 -07:00
|
|
|
retVal = mochitest.runTests(options, onLaunch=mochitest.startTests)
|
|
|
|
mochitest.message_logger.finish()
|
|
|
|
|
|
|
|
sys.exit(retVal)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
|
|
|
def main():
|
2013-07-26 11:40:04 -07:00
|
|
|
parser = B2GOptions()
|
2013-01-04 10:41:34 -08:00
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
|
|
|
if options.desktop:
|
|
|
|
run_desktop_mochitests(parser, options)
|
|
|
|
else:
|
2013-07-26 11:40:04 -07:00
|
|
|
run_remote_mochitests(parser, options)
|
2013-01-04 10:41:34 -08:00
|
|
|
|
2012-04-27 11:44:59 -07:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|