From 922d92002d5c53d21c2e084d4cb63b8b8c145085 Mon Sep 17 00:00:00 2001 From: Syd Polk Date: Tue, 9 Feb 2016 18:10:19 -0600 Subject: [PATCH] Bug 1243546 - Add mach command for external-media-tests - r=gps --HG-- extra : rebase_source : 04045035246948854cc91284dfad430cec1373fb --- build/mach_bootstrap.py | 2 + .../external_media_harness/runtests.py | 4 +- dom/media/test/external/mach_commands.py | 73 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 dom/media/test/external/mach_commands.py diff --git a/build/mach_bootstrap.py b/build/mach_bootstrap.py index dd52fb91be6f..8d3de7acca4a 100644 --- a/build/mach_bootstrap.py +++ b/build/mach_bootstrap.py @@ -67,6 +67,7 @@ SEARCH_PATHS = [ 'config', 'dom/bindings', 'dom/bindings/parser', + 'dom/media/test/external', 'layout/tools/reftest', 'other-licenses/ply', 'testing', @@ -109,6 +110,7 @@ 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', diff --git a/dom/media/test/external/external_media_harness/runtests.py b/dom/media/test/external/external_media_harness/runtests.py index 554d437f28d0..e1946d6ee54e 100644 --- a/dom/media/test/external/external_media_harness/runtests.py +++ b/dom/media/test/external/external_media_harness/runtests.py @@ -91,7 +91,9 @@ class FirefoxMediaHarness(MarionetteHarness): def cli(): - mn_cli(MediaTestRunner, MediaTestArguments, FirefoxMediaHarness) + mn_cli(runner_class=MediaTestRunner, + parser_class=FirefoxMediaHarness, + args=args) if __name__ == '__main__': cli() diff --git a/dom/media/test/external/mach_commands.py b/dom/media/test/external/mach_commands.py new file mode 100644 index 000000000000..d51bcc3da746 --- /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)