def test_harness_sets_up_default_test_handlers(mach_parsed_kwargs): """ If the necessary TestCase is not in test_handlers, tests are omitted silently """ harness = MarionetteHarness(args=mach_parsed_kwargs) mach_parsed_kwargs.pop('tests') runner = harness._runner_class(**mach_parsed_kwargs) assert marionette_test.MarionetteTestCase in runner.test_handlers
def test_args_passed_to_runner_class(mach_parsed_kwargs, runner_class): arg_list = mach_parsed_kwargs.keys() arg_list.remove('tests') mach_parsed_kwargs.update([(a, getattr(sentinel, a)) for a in arg_list]) harness = MarionetteHarness(runner_class, args=mach_parsed_kwargs) harness.process_args = Mock() harness.run() for arg in arg_list: assert harness._runner_class.call_args[1][arg] is getattr(sentinel, arg)
def __init__(self, runner_class=FirefoxUITestRunner, parser_class=FirefoxUIArguments): # workaround until next marionette-client release - Bug 1227918 try: MarionetteHarness.__init__(self, runner_class, parser_class) except Exception: logger = mozlog.commandline.setup_logging('Firefox UI harness', {}) logger.error('Failure setting up harness', exc_info=True) raise
def test_args_passed_to_runner_class(mach_parsed_kwargs, runner_class): arg_list = mach_parsed_kwargs.keys() arg_list.remove('tests') mach_parsed_kwargs.update([(a, getattr(sentinel, a)) for a in arg_list]) harness = MarionetteHarness(runner_class, args=mach_parsed_kwargs) harness.process_args = Mock() harness.run() for arg in arg_list: assert harness._runner_class.call_args[1][arg] is getattr( sentinel, arg)
def __init__(self, runner_class=MediaTestRunner, parser_class=MediaTestArguments): # workaround until next marionette-client release - Bug 1227918 try: MarionetteHarness.__init__(self, runner_class, parser_class) except Exception: logger = mozlog.commandline.setup_logging('Media-test harness', {}) logger.error('Failure setting up harness', exc_info=True) raise
def run_marionette(context, **kwargs): from marionette.runtests import MarionetteTestRunner, MarionetteHarness from mozlog.structured import commandline args = argparse.Namespace(**kwargs) args.binary = args.binary or context.firefox_bin test_root = os.path.join(context.package_root, "marionette", "tests") if not args.tests: args.tests = [ os.path.join( test_root, "testing", "marionette", "harness", "marionette_harness", "tests", "unit-tests.ini", ) ] normalize = partial(context.normalize_test_path, test_root) args.tests = list(map(normalize, args.tests)) commandline.add_logging_group(parser) parser.verify_usage(args) args.logger = commandline.setup_logging("Marionette Unit Tests", args, {"mach": sys.stdout}) status = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run() return 1 if status else 0
def run_marionette(context, **kwargs): from marionette.runtests import (MarionetteTestRunner, MarionetteHarness) from mozlog.structured import commandline args = argparse.Namespace(**kwargs) args.binary = args.binary or context.firefox_bin args.e10s = context.mozharness_config.get('e10s', args.e10s) test_root = os.path.join(context.package_root, 'marionette', 'tests') if not args.tests: args.tests = [ os.path.join(test_root, 'testing', 'marionette', 'harness', 'marionette', 'tests', 'unit-tests.ini') ] normalize = partial(context.normalize_test_path, test_root) args.tests = map(normalize, args.tests) commandline.add_logging_group(parser) parser.verify_usage(args) args.logger = commandline.setup_logging("Marionette Unit Tests", args, {"mach": sys.stdout}) status = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run() return 1 if status else 0
def test_call_harness_with_no_args_yields_num_failures(runner_class): with patch( 'marionette.runtests.MarionetteHarness.parse_args') as parse_args: parse_args.return_value = {'tests': []} failed_or_crashed = MarionetteHarness(runner_class).run() assert parse_args.call_count == 1 assert failed_or_crashed == 0
def run_marionette(tests, binary=None, topsrcdir=None, **kwargs): from mozlog.structured import commandline from marionette.runtests import ( MarionetteTestRunner, MarionetteHarness ) parser = setup_marionette_argument_parser() if not tests: tests = [os.path.join(topsrcdir, 'testing/marionette/harness/marionette/tests/unit-tests.ini')] args = argparse.Namespace(tests=tests) args.binary = binary for k, v in kwargs.iteritems(): setattr(args, k, v) parser.verify_usage(args) args.logger = commandline.setup_logging("Marionette Unit Tests", args, {"mach": sys.stdout}) failed = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run() if failed > 0: return 1 else: return 0
def test_call_harness_with_parsed_args_yields_num_failures( mach_parsed_kwargs, runner_class, num_failures): with patch( 'marionette.runtests.MarionetteHarness.parse_args') as parse_args: failed = MarionetteHarness(runner_class, args=mach_parsed_kwargs).run() parse_args.assert_not_called() assert failed == num_failures
def run_marionette(tests, b2g_path=None, emulator=None, testtype=None, address=None, binary=None, topsrcdir=None, **kwargs): from mozlog.structured import commandline from marionette.runtests import (MarionetteTestRunner, BaseMarionetteArguments, MarionetteHarness) parser = BaseMarionetteArguments() commandline.add_logging_group(parser) args = parser.parse_args() if not tests: tests = [ os.path.join( topsrcdir, 'testing/marionette/client/marionette/tests/unit-tests.ini') ] args.tests = tests if b2g_path: args.homedir = b2g_path if emulator: args.emulator = emulator else: args.binary = binary path, exe = os.path.split(args.binary) for k, v in kwargs.iteritems(): setattr(args, k, v) parser.verify_usage(args) args.logger = commandline.setup_logging("Marionette Unit Tests", args, {"mach": sys.stdout}) failed = MarionetteHarness(MarionetteTestRunner, args=args).run() if failed > 0: return 1 else: return 0
def run_session(tests, testtype=None, address=None, binary=None, topsrcdir=None, **kwargs): from mozlog.structured import commandline from marionette.runtests import (MarionetteHarness) from session.runtests import ( SessionTestRunner, BaseSessionArguments, SessionArguments, SessionTestCase, ) parser = BaseSessionArguments() commandline.add_logging_group(parser) if not tests: tests = [ os.path.join( topsrcdir, 'testing/marionette/harness/session/tests/unit-tests.ini') ] args = argparse.Namespace(tests=tests) args.binary = binary for k, v in kwargs.iteritems(): setattr(args, k, v) parser.verify_usage(args) args.logger = commandline.setup_logging("Session Unit Tests", args, {"mach": sys.stdout}) failed = MarionetteHarness(runner_class=SessionTestRunner, parser_class=SessionArguments, testcase_class=SessionTestCase, args=vars(args)).run() if failed > 0: return 1 else: return 0
def run_firefox_ui_test(tests, testtype=None, binary=None, topsrcdir=None, **kwargs): from marionette.runtests import MarionetteHarness from mozlog.structured import commandline from firefox_ui_harness.cli_functional import FirefoxUITestRunner from firefox_ui_harness.arguments import FirefoxUIArguments parser = FirefoxUIArguments() commandline.add_logging_group(parser) args = parser.parse_args() if not tests: tests = [ os.path.join( topsrcdir, 'testing/firefox-ui/tests/firefox_ui_tests/manifest.ini') ] args.tests = tests args.binary = binary path, exe = os.path.split(args.binary) for k, v in kwargs.iteritems(): setattr(args, k, v) parser.verify_usage(args) args.logger = commandline.setup_logging("Firefox UI - Functional Tests", args, {"mach": sys.stdout}) try: failed = MarionetteHarness(FirefoxUITestRunner, FirefoxUIArguments, args=args).run() if failed > 0: sys.exit(10) except Exception: args.logger.error('Failure during harness setup', exc_info=True) sys.exit(1) sys.exit(0)
def parse_args(self, *args, **kwargs): return MarionetteHarness.parse_args(self, {'mach': sys.stdout})