Bug 1243546 - Add mach command for external-media-tests - r?gps draft
authorSyd Polk <spolk@mozilla.com>
Wed, 10 Feb 2016 11:48:25 -0600
changeset 330115 cce6138811232d723f77c6e069f06c90cc961351
parent 329978 0f3d064ce06dcc894ff11944681eae6c59405a51
child 514102 c4ed35fb8f0c116841228d00a23dbf3792012c66
push id10680
push userspolk@mozilla.com
push dateWed, 10 Feb 2016 18:04:40 +0000
reviewersgps
bugs1243546
milestone47.0a1
Bug 1243546 - Add mach command for external-media-tests - r?gps MozReview-Commit-ID: 5BcunutbebG
build/mach_bootstrap.py
dom/media/test/external/mach_commands.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -62,16 +62,17 @@ SEARCH_PATHS = [
     'python/pystache',
     'python/pyyaml/lib',
     'python/requests',
     'python/slugid',
     'build',
     'config',
     'dom/bindings',
     'dom/bindings/parser',
+    'dom/media/test/external',
     'layout/tools/reftest',
     'other-licenses/ply',
     'testing',
     'testing/firefox-ui/harness',
     'testing/firefox-ui/tests',
     'testing/luciddream',
     'testing/marionette/client',
     'testing/marionette/client/marionette/runner/mixins/browsermob-proxy-py',
@@ -104,16 +105,17 @@ SEARCH_PATHS = [
     'xpcom/idl-parser',
 ]
 
 # Individual files providing mach commands.
 MACH_MODULES = [
     'addon-sdk/mach_commands.py',
     'build/valgrind/mach_commands.py',
     'dom/bindings/mach_commands.py',
+    'dom/media/test/external/mach_commands.py',
     'layout/tools/reftest/mach_commands.py',
     'python/mach_commands.py',
     'python/mach/mach/commands/commandinfo.py',
     'python/compare-locales/mach_commands.py',
     'python/mozboot/mozboot/mach_commands.py',
     'python/mozbuild/mozbuild/mach_commands.py',
     'python/mozbuild/mozbuild/backend/mach_commands.py',
     'python/mozbuild/mozbuild/compilation/codecomplete.py',
new file mode 100644
--- /dev/null
+++ b/dom/media/test/external/mach_commands.py
@@ -0,0 +1,73 @@
+# 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, unicode_literals
+
+import os
+import sys
+
+from mozbuild.base import (
+    MachCommandBase,
+    MachCommandConditions as conditions,
+)
+
+from mach.decorators import (
+    CommandProvider,
+    Command,
+)
+
+def setup_argument_parser():
+    from external_media_harness.runtests import MediaTestArguments
+    return MediaTestArguments()
+
+
+def run_external_media_test(tests, testtype=None, topsrcdir=None, **kwargs):
+    from external_media_harness.runtests import (
+        FirefoxMediaHarness,
+        MediaTestArguments,
+        MediaTestRunner,
+        mn_cli,
+    )
+
+    from mozlog.structured import commandline
+
+    parser = MediaTestArguments()
+    commandline.add_logging_group(parser)
+    args = parser.parse_args()
+
+    if not tests:
+        tests = [os.path.join(topsrcdir,
+                 'dom/media/test/external/external_media_tests/manifest.ini')]
+    args.tests = tests
+
+    if not args.binary:
+        args.binary = kwargs['binary']
+
+    for k, v in kwargs.iteritems():
+        setattr(args, k, v)
+
+    parser.verify_usage(args)
+
+    args.logger = commandline.setup_logging("Firefox External Media Tests",
+                                            args,
+                                            {"mach": sys.stdout})
+    failed = mn_cli(MediaTestRunner, MediaTestArguments, FirefoxMediaHarness,
+                    args=args)
+
+    if failed > 0:
+        return 1
+    else:
+        return 0
+
+
+@CommandProvider
+class MachCommands(MachCommandBase):
+    @Command('external-media-tests', category='testing',
+             description='Run Firefox external media tests.',
+             conditions=[conditions.is_firefox],
+             parser=setup_argument_parser,
+             )
+    def run_external_media_test(self, tests, **kwargs):
+        kwargs['binary'] = self.get_binary_path('app')
+        return run_external_media_test(tests, topsrcdir=self.topsrcdir, **kwargs)