#!/usr/bin/env python # 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/.
import copy import json import os import sys
# load modules from parent dir
sys.path.insert(1, os.path.dirname(sys.path[0]))
from mozharness.base.errors import BaseErrorList, TarErrorList from mozharness.base.log import INFO from mozharness.base.script import PreScriptAction from mozharness.base.transfer import TransferMixin from mozharness.base.vcs.vcsbase import MercurialScript from mozharness.mozilla.structuredlog import StructuredOutputParser from mozharness.mozilla.testing.codecoverage import (
CodeCoverageMixin,
code_coverage_config_options,
) from mozharness.mozilla.testing.errors import HarnessErrorList, LogcatErrorList from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options from mozharness.mozilla.testing.unittest import TestSummaryOutputParserHelper
class MarionetteTest(TestingMixin, MercurialScript, TransferMixin, CodeCoverageMixin):
config_options = (
[
[
["--application"],
{ "action": "store", "dest": "application", "default": None, "help": "application name of binary",
},
],
[
["--app-arg"],
{ "action": "store", "dest": "app_arg", "default": None, "help": "Optional command-line argument to pass to the browser",
},
],
[
["--marionette-address"],
{ "action": "store", "dest": "marionette_address", "default": None, "help": "The host:port of the Marionette server running inside Gecko. " "Unused for emulator testing",
},
],
[
["--emulator"],
{ "action": "store", "type": "choice", "choices": ["arm", "x86"], "dest": "emulator", "default": None, "help": "Use an emulator for testing",
},
],
[
["--test-manifest"],
{ "action": "store", "dest": "test_manifest", "default": "unit-tests.toml", "help": "Path to test manifest to run relative to the Marionette " "tests directory",
},
],
[
["--tag"],
{ "action": "store", "dest": "test_tag", "default": "", "help": "Tag that identifies how to filter which tests to run.",
},
],
[
["--total-chunks"],
{ "action": "store", "dest": "total_chunks", "help": "Number of total chunks",
},
],
[
["--this-chunk"],
{ "action": "store", "dest": "this_chunk", "help": "Number of this chunk",
},
],
[
["--setpref"],
{ "action": "append", "metavar": "PREF=VALUE", "dest": "extra_prefs", "default": [], "help": "Extra user prefs.",
},
],
[
["--headless"],
{ "action": "store_true", "dest": "headless", "default": False, "help": "Run tests in headless mode.",
},
],
[
["--headless-width"],
{ "action": "store", "dest": "headless_width", "default": "1600", "help": "Specify headless virtual screen width (default: 1600).",
},
],
[
["--headless-height"],
{ "action": "store", "dest": "headless_height", "default": "1200", "help": "Specify headless virtual screen height (default: 1200).",
},
],
[
["--allow-software-gl-layers"],
{ "action": "store_true", "dest": "allow_software_gl_layers", "default": False, "help": "Permits a software GL implementation (such as LLVMPipe) to use the GL compositor.", # NOQA: E501
},
],
[
["--disable-fission"],
{ "action": "store_true", "dest": "disable_fission", "default": False, "help": "Run the browser without fission enabled",
},
],
[
["--subsuite"],
{ "action": "store", "dest": "subsuite", "default": "marionette", "help": "Selects test paths from test-manifests.active",
},
],
]
+ copy.deepcopy(testing_config_options)
+ copy.deepcopy(code_coverage_config_options)
)
# these are necessary since self.config is read only
c = self.config
self.installer_url = c.get("installer_url")
self.installer_path = c.get("installer_path")
self.binary_path = c.get("binary_path")
self.test_url = c.get("test_url")
self.test_packages_url = c.get("test_packages_url")
self.subsuite = c.get("subsuite")
self.test_suite = self._get_test_suite(c.get("emulator")) if self.test_suite notin self.config["suite_definitions"]:
self.fatal("{} is not defined in the config!".format(self.test_suite))
if c.get("structured_output"):
self.parser_class = StructuredOutputParser else:
self.parser_class = TestSummaryOutputParserHelper
def _pre_config_lock(self, rw_config):
super(MarionetteTest, self)._pre_config_lock(rw_config) ifnot self.config.get("emulator") andnot self.config.get( "marionette_address"
):
self.fatal( "You need to specify a --marionette-address for non-emulator tests! " "(Try --marionette-address localhost:2828 )"
)
def _get_test_suite(self, is_emulator): """
Determine which in tree options group to use andreturn the
appropriate key. """
platform = "emulator"if is_emulator else"desktop" # Currently running marionette on an emulator means webapi # tests. This method will need to change if this does.
testsuite = "webapi"if is_emulator else"marionette" return"{}_{}".format(testsuite, platform)
if self.config.get("app_arg"):
config_fmt_args["app_arg"] = self.config["app_arg"]
cmd.extend(["--setpref={}".format(p) for p in self.config["extra_prefs"]])
cmd.append("--gecko-log=-")
if self.config.get("structured_output"):
cmd.append("--log-raw=-")
if self.config["disable_fission"]:
cmd.append("--disable-fission")
cmd.extend(["--setpref=fission.autostart=false"])
for arg in self.config["suite_definitions"][self.test_suite]["options"]:
cmd.append(arg % config_fmt_args)
if self.mkdir_p(dirs["abs_blob_upload_dir"]) == -1: # Make sure that the logging directory exists
self.fatal("Could not create blobber upload directory")
suite = self.subsuite if test_paths and suite in test_paths:
suite_test_paths = test_paths[suite] if confirm_paths and suite in confirm_paths and confirm_paths[suite]:
suite_test_paths = confirm_paths[suite]
paths = [
os.path.join(dirs["abs_test_install_dir"], "marionette", "tests", p) for p in suite_test_paths
]
cmd.extend(paths) else:
cmd.append(manifest)
# Causes Firefox to crash when using non-local connections.
env["MOZ_DISABLE_NONLOCAL_CONNECTIONS"] = "1"
# Avoid issues when printing messages containing unicode characters on # windows (Bug 1800035). if self._is_windows():
env["PYTHONIOENCODING"] = "utf-8"
env = self.query_env(partial_env=env)
try:
cwd = self._query_tests_dir() except Exception as e:
self.fatal( "Don't know how to run --test-suite '{0}': {1}!".format(
self.test_suite, e
)
)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.