Bug 1453707 - Add mach command for running TPS
This is a work in progress, and not ready to land. I just wanted to see what would be needed to introduce a mach command for running TPS. This will run the TPS tests against the local build, unless --binary is specified with a valid path. It still requires a configuration file, and some values are currently hard-coded, which should probably be configurable. It uses the in-tree mozbase dependencies to avoid issues with downloading from and publishing these packages to/from PyPI.
MozReview-Commit-ID: 9fc5aiWoPwN
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -49,16 +49,17 @@ MACH_MODULES = [
'taskcluster/mach_commands.py',
'testing/awsy/mach_commands.py',
'testing/firefox-ui/mach_commands.py',
'testing/geckodriver/mach_commands.py',
'testing/mach_commands.py',
'testing/marionette/mach_commands.py',
'testing/mochitest/mach_commands.py',
'testing/mozharness/mach_commands.py',
+ 'testing/tps/mach_commands.py',
'testing/talos/mach_commands.py',
'testing/web-platform/mach_commands.py',
'testing/xpcshell/mach_commands.py',
'tools/compare-locales/mach_commands.py',
'tools/docs/mach_commands.py',
'tools/lint/mach_commands.py',
'tools/mach_commands.py',
'tools/power/mach_commands.py',
new file mode 100644
--- /dev/null
+++ b/testing/tps/mach_commands.py
@@ -0,0 +1,54 @@
+# 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/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+import json
+import os
+import sys
+from threading import RLock
+
+
+from mach.decorators import (
+ Command,
+ CommandArgument,
+ CommandArgumentGroup,
+ CommandProvider,
+)
+
+from mozbuild.base import MachCommandBase
+
+from tps import TPSTestRunner
+
+
+@CommandProvider
+class MachCommands(MachCommandBase):
+ """Helps manage in-tree documentation."""
+
+ @Command('tps', category='testing', description='Run TPS tests.')
+ @CommandArgumentGroup('TPS')
+ @CommandArgument("--binary", help="Firefox binary (defaults to the local build).")
+ @CommandArgument("--config", help="Configuration file.")
+ @CommandArgument("--testfile", default='all_tests.json',
+ help="Test file to run (defaults to all_tests.json).")
+ def tps(self, binary, config, testfile):
+ self._activate_virtualenv()
+ binary = binary or self.get_binary_path()
+ syncdir = os.path.join(self.topsrcdir, 'services', 'sync')
+ runner = TPSTestRunner(
+ os.path.join(syncdir, 'tps', 'extensions'),
+ binary=binary,
+ config=json.load(open(config)),
+ debug=False,
+ ignore_unused_engines=False,
+ logfile='tps.log',
+ mobile=False,
+ resultfile='tps_result.json',
+ rlock=RLock(),
+ testfile=os.path.join(syncdir, 'tests', 'tps', testfile),
+ stop_on_error=False)
+ runner.run_tests()
+
+ if runner.numfailed > 0 or runner.numpassed == 0:
+ sys.exit(1)