def set_defaults(args): args.include_manifest = args.include_manifest if args.include_manifest else wptsubdir( "include.ini") args.product = "servo" rv = vars(args) wptcommandline.check_args(rv) return rv
def set_defaults(kwargs): if kwargs["product"] is None: kwargs["product"] = "servo" if kwargs["config"] is None and "config" in paths: kwargs["config"] = paths["config"] if kwargs["include_manifest"] is None and "include_manifest" in paths: kwargs["include_manifest"] = paths["include_manifest"] if kwargs["binary"] is None: bin_dir = "release" if kwargs["release"] else "debug" bin_name = "servo" if sys.platform == "win32": bin_name += ".exe" bin_path = servo_path("target", bin_dir, bin_name) kwargs["binary"] = bin_path kwargs["webdriver_binary"] = bin_path if kwargs["processes"] is None: kwargs["processes"] = multiprocessing.cpu_count() kwargs["user_stylesheets"].append(servo_path("resources", "ahem.css")) wptcommandline.check_args(kwargs)
def setup_wptrunner(venv, prompt=True, install=False, **kwargs): from wptrunner import wptrunner, wptcommandline global logger kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] wptrunner.setup_logging(kwargs, {"mach": sys.stdout}) logger = wptrunner.logger check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) if install: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) return kwargs
def setup_wptrunner(venv, product, tests, wptrunner_args, prompt=True,): global logger wptparser = wptcommandline.create_parser() kwargs = utils.Kwargs(vars(wptparser.parse_args(wptrunner_args)).iteritems()) wptrunner.setup_logging(kwargs, {"mach": sys.stdout}) logger = wptrunner.logger kwargs["product"] = product kwargs["test_list"] = tests check_environ(product) args_general(kwargs) if product not in product_setup: exit("Unsupported product %s" % product) product_setup[product](venv, kwargs, prompt) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) return kwargs
def setup_wptrunner(venv, product, tests, wptrunner_args, prompt=True,): from wptrunner import wptrunner, wptcommandline global logger wptparser = wptcommandline.create_parser() kwargs = utils.Kwargs(vars(wptparser.parse_args(wptrunner_args)).iteritems()) wptrunner.setup_logging(kwargs, {"mach": sys.stdout}) logger = wptrunner.logger kwargs["product"] = product kwargs["test_list"] = tests check_environ(product) args_general(kwargs) if product not in product_setup: raise WptrunError("Unsupported product %s" % product) product_setup[product](venv, kwargs, prompt) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) return kwargs
def run(config, args): logger = structuredlog.StructuredLogger("web-platform-tests") logger.add_handler(ResultHandler(logger=logger, verbose=args.verbose)) setup_wptrunner_logging(logger) parser = wptcommandline.create_parser() logger.suite_start(tests=[]) for product, product_settings in config["products"].iteritems(): if args.product and product not in args.product: continue settings = test_settings() settings.update(config["general"]) settings.update(product_settings) settings["product"] = product set_from_args(settings, args) kwargs = vars(parser.parse_args(settings_to_argv(settings))) wptcommandline.check_args(kwargs) logger.send_message("wptrunner-test", "set-product", product) run_tests(product, kwargs) logger.send_message("wptrunner-test", "set-product", None) logger.suite_end()
def set_defaults(paths, kwargs): if kwargs["product"] is None: kwargs["product"] = "servo" if kwargs["config"] is None and "config" in paths: kwargs["config"] = paths["config"] if kwargs["include_manifest"] is None and "include_manifest" in paths: kwargs["include_manifest"] = paths["include_manifest"] if kwargs["binary"] is None: bin_dir = "release" if kwargs["release"] else "debug" bin_name = "servo" if sys.platform == "win32": bin_name += ".exe" bin_path = servo_path("target", bin_dir, bin_name) kwargs["binary"] = bin_path if kwargs["processes"] is None: kwargs["processes"] = multiprocessing.cpu_count() kwargs["user_stylesheets"].append(servo_path("resources", "ahem.css")) wptcommandline.check_args(kwargs)
def run(config, args): logger = structuredlog.StructuredLogger("web-platform-tests") logger.add_handler(ResultHandler(logger=logger, verbose=args.verbose)) setup_wptrunner_logging(logger) parser = wptcommandline.create_parser() logger.suite_start(tests=[]) for product, product_settings in config["products"].items(): if args.product and product not in args.product: continue settings = test_settings() settings.update(config["general"]) settings.update(product_settings) settings["product"] = product set_from_args(settings, args) kwargs = vars(parser.parse_args(settings_to_argv(settings))) wptcommandline.check_args(kwargs) logger.send_message("wptrunner-test", "set-product", product) run_tests(product, kwargs) logger.send_message("wptrunner-test", "set-product", None) logger.suite_end()
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptrunner, wptcommandline import mozlog global logger kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] # Use the grouped formatter by default where mozlog 3.9+ is installed if hasattr(mozlog.formatters, "GroupingFormatter"): default_formatter = "grouped" else: default_formatter = "mach" wptrunner.setup_logging(kwargs, {default_formatter: sys.stdout}) logger = wptrunner.logger check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() if install_browser and not kwargs["channel"]: logger.info("--install-browser is given but --channel is not set, default to nightly channel") kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel is not None: if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel else: logger.info("Valid channels for %s not known; using argument unmodified" % kwargs["product"]) del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version(binary=kwargs.get("binary"), webdriver_binary=kwargs.get("webdriver_binary")) return kwargs
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptrunner, wptcommandline import mozlog global logger kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] # Use the grouped formatter by default where mozlog 3.9+ is installed if hasattr(mozlog.formatters, "GroupingFormatter"): default_formatter = "grouped" else: default_formatter = "mach" wptrunner.setup_logging(kwargs, {default_formatter: sys.stdout}) logger = wptrunner.logger check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() if install_browser and not kwargs["channel"]: logger.info("--install-browser is given but --channel is not set, default to nightly channel") kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version(kwargs.get("binary")) return kwargs
def set_defaults(kwargs): if kwargs["product"] is None: kwargs["product"] = "servo" if kwargs["config"] is None and "config" in paths: kwargs["config"] = paths["config"] if kwargs["include_manifest"] is None and "include_manifest" in paths: kwargs["include_manifest"] = paths["include_manifest"] if kwargs["manifest_update"] is None: kwargs["manifest_update"] = False if kwargs["binary"] is None: bin_dir = "release" if kwargs["release"] else "debug" bin_name = "servo" if sys.platform == "win32": bin_name += ".exe" if "CARGO_TARGET_DIR" in os.environ: bin_path = path.join(os.environ["CARGO_TARGET_DIR"], bin_dir, bin_name) else: bin_path = servo_path("target", bin_dir, bin_name) kwargs["binary"] = bin_path kwargs["webdriver_binary"] = bin_path if kwargs["processes"] is None: kwargs["processes"] = multiprocessing.cpu_count() if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = paths["ca-cert-path"] if kwargs["host_key_path"] is None: kwargs["host_key_path"] = paths["host-key-path"] if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = paths["host-cert-path"] if kwargs["ssl_type"] is None: kwargs["ssl_type"] = "pregenerated" kwargs["user_stylesheets"].append(servo_path("resources", "ahem.css")) wptcommandline.check_args(kwargs) if kwargs.pop("layout_2020"): kwargs["test_paths"]["/"]["metadata_path"] = wpt_path( "metadata-layout-2020") kwargs["test_paths"]["/_mozilla/"]["metadata_path"] = wpt_path( "mozilla/meta-layout-2020") kwargs["include_manifest"] = wpt_path("include-layout-2020.ini")
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptrunner, wptcommandline global logger kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] wptrunner.setup_logging(kwargs, {"mach": sys.stdout}) logger = wptrunner.logger check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() if install_browser and not kwargs["channel"]: logger.info( "--install-browser is given but --channel is not set, default to nightly channel" ) kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version(kwargs.get("binary")) return kwargs
def wptrunner_args(root, files_changed, iterations, browser): parser = wptcommandline.create_parser([browser.product]) args = vars(parser.parse_args([])) args.update(browser.wptrunner_args(root)) args.update({ "tests_root": wpt_root, "metadata_root": wpt_root, "repeat": iterations, "config": "%s//wptrunner.default.ini" % (wptrunner_root), "test_list": files_changed, "restart_on_unexpected": False, "pause_after_test": False }) wptcommandline.check_args(args) return args
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptcommandline kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() if install_browser and not kwargs["channel"]: logger.info("--install-browser is given but --channel is not set, default to nightly channel") kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel is not None: if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel else: logger.info("Valid channels for %s not known; using argument unmodified" % kwargs["product"]) del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version(binary=kwargs.get("binary"), webdriver_binary=kwargs.get("webdriver_binary")) return kwargs
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptrunner, wptcommandline global logger kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] wptrunner.setup_logging(kwargs, {"mach": sys.stdout}) logger = wptrunner.logger check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() if install_browser and not kwargs["channel"]: kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version(kwargs.get("binary")) return kwargs
def kwargs_firefox(self, kwargs): import mozinfo from wptrunner import wptcommandline kwargs = self.kwargs_common(kwargs) if kwargs["binary"] is None: kwargs["binary"] = self.get_binary_path() if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = self.get_binary_path('certutil') if kwargs["webdriver_binary"] is None: kwargs["webdriver_binary"] = self.get_binary_path( "geckodriver", validate_exists=False) if kwargs["install_fonts"] is None: kwargs["install_fonts"] = True if kwargs["install_fonts"] and mozinfo.info[ "os"] == "win" and mozinfo.info["os_version"] == "6.1": # On Windows 7 --install-fonts fails, so fall back to a Firefox-specific codepath self.setup_fonts_firefox() kwargs["install_fonts"] = False kwargs = wptcommandline.check_args(kwargs) return kwargs
def wptrunner_args(root, files_changed, iterations, browser): """Derive and return arguments for wpt-runner.""" parser = wptcommandline.create_parser([browser.product]) args = vars(parser.parse_args([])) args.update(browser.wptrunner_args(root)) args.update({ "tests_root": wpt_root, "metadata_root": wpt_root, "repeat": iterations, "config": "%s//wptrunner.default.ini" % (wptrunner_root), "test_list": files_changed, "restart_on_unexpected": False, "pause_after_test": False }) wptcommandline.check_args(args) return args
def setup_kwargs(self, kwargs): build_path = os.path.join(self.topobjdir, 'build') if build_path not in sys.path: sys.path.append(build_path) if kwargs["config"] is None: kwargs["config"] = os.path.join(self.topsrcdir, 'testing', 'web-platform', 'wptrunner.ini') if kwargs["binary"] is None: kwargs["binary"] = self.get_binary_path('app') if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.topobjdir, '_tests', 'web-platform', "prefs") if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = self.get_binary_path('certutil') here = os.path.split(__file__)[0] if kwargs["ssl_type"] in (None, "pregenerated"): if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = os.path.join(here, "certs", "cacert.pem") if kwargs["host_key_path"] is None: kwargs["host_key_path"] = os.path.join(here, "certs", "web-platform.test.key") if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = os.path.join(here, "certs", "web-platform.test.pem") kwargs["capture_stdio"] = True kwargs = wptcommandline.check_args(kwargs)
def kwargs_firefox(self, kwargs): from wptrunner import wptcommandline if kwargs["config"] is None: kwargs["config"] = os.path.join(self.context.package_root, 'web-platform', 'wptrunner.ini') if kwargs["binary"] is None: kwargs["binary"] = self.context.firefox_bin if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.context.package_root, 'web-platform', "prefs") if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = os.path.join(self.context.bin_dir, 'certutil') if kwargs["stackfix_dir"] is None: kwargs["stackfix_dir"] = self.context.bin_dir if kwargs["ssl_type"] in (None, "pregenerated"): cert_root = os.path.join(self.context.package_root, "web-platform", "tests", "tools", "certs") if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = os.path.join(cert_root, "cacert.pem") if kwargs["host_key_path"] is None: kwargs["host_key_path"] = os.path.join(cert_root, "web-platform.test.key") if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = os.path.join(cert_root, "web-platform.test.pem") kwargs["capture_stdio"] = True if kwargs["exclude"] is None and kwargs["include"] is None and not sys.platform.startswith("linux"): kwargs["exclude"] = ["css"] if kwargs["webdriver_binary"] is None: kwargs["webdriver_binary"] = os.path.join(self.context.bin_dir, "geckodriver") return wptcommandline.check_args(kwargs)
def kwargs_firefox(self, kwargs): from wptrunner import wptcommandline if kwargs["config"] is None: kwargs["config"] = os.path.join(self.context.package_root, 'web-platform', 'wptrunner.ini') if kwargs["binary"] is None: kwargs["binary"] = self.context.firefox_bin if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.context.package_root, 'web-platform', "prefs") if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = os.path.join(self.context.bin_dir, 'certutil') if kwargs["stackfix_dir"] is None: kwargs["stackfix_dir"] = self.context.bin_dir if kwargs["ssl_type"] in (None, "pregenerated"): if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = os.path.join(self.context.package_root, "web-platform", "certs", "cacert.pem") if kwargs["host_key_path"] is None: kwargs["host_key_path"] = os.path.join(self.context.package_root, "web-platform", "certs", "web-platform.test.key") if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = os.path.join(self.context.package_root, "web-platform", "certs", "web-platform.test.pem") kwargs["capture_stdio"] = True if kwargs["exclude"] is None and kwargs["include"] is None and not sys.platform.startswith("linux"): kwargs["exclude"] = ["css"] if kwargs["webdriver_binary"] is None: kwargs["webdriver_binary"] = os.path.join(self.context.bin_dir, "geckodriver") return wptcommandline.check_args(kwargs)
def setup_kwargs(self, kwargs): from wptrunner import wptcommandline build_path = os.path.join(self.topobjdir, 'build') if build_path not in sys.path: sys.path.append(build_path) if kwargs["config"] is None: kwargs["config"] = os.path.join(self.topsrcdir, 'testing', 'web-platform', 'wptrunner.ini') if kwargs["binary"] is None: kwargs["binary"] = self.get_binary_path('app') if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.topobjdir, '_tests', 'web-platform', "prefs") if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = self.get_binary_path('certutil') here = os.path.split(__file__)[0] if kwargs["ssl_type"] in (None, "pregenerated"): if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = os.path.join(here, "certs", "cacert.pem") if kwargs["host_key_path"] is None: kwargs["host_key_path"] = os.path.join(here, "certs", "web-platform.test.key") if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = os.path.join(here, "certs", "web-platform.test.pem") kwargs["capture_stdio"] = True kwargs = wptcommandline.check_args(kwargs)
def wptrunner_args(root, files_changed, iterations, browser): parser = wptcommandline.create_parser([browser.product]) args = vars(parser.parse_args([])) wpt_root = os.path.join(root, "w3c", "web-platform-tests") args.update(browser.wptrunner_args(root)) args.update({ "tests_root": wpt_root, "metadata_root": wpt_root, "repeat": iterations, "config": "%s/w3c/wptrunner/wptrunner.default.ini" % root, "test_list": files_changed, "restart_on_unexpected": False, "pause_after_test": False }) wptcommandline.check_args(args) return args
def run(self, logger, **kwargs): from wptrunner import wptrunner from mozbuild.base import BinaryNotFoundException if kwargs["manifest_update"] is not False: self.update_manifest(logger) kwargs["manifest_update"] = False if kwargs["product"] in ["firefox", None]: try: kwargs = self.setup.kwargs_firefox(kwargs) except BinaryNotFoundException as e: logger.error(e) logger.info(e.help()) return 1 elif kwargs["product"] == "firefox_android": from wptrunner import wptcommandline kwargs = wptcommandline.check_args( self.setup.kwargs_common(kwargs)) elif kwargs["product"] in ("chrome", "edge", "servo"): kwargs = self.setup.kwargs_wptrun(kwargs) else: raise ValueError("Unknown product %s" % kwargs["product"]) result = wptrunner.start(**kwargs) return int(result)
def kwargs_firefox(self, kwargs): from wptrunner import wptcommandline build_path = os.path.join(self.topobjdir, 'build') if build_path not in sys.path: sys.path.append(build_path) if kwargs["config"] is None: kwargs["config"] = os.path.join(self.topsrcdir, 'testing', 'web-platform', 'wptrunner.ini') if kwargs["binary"] is None: kwargs["binary"] = self.get_binary_path() if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.topobjdir, '_tests', 'web-platform', "prefs") if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = self.get_binary_path('certutil') if kwargs["stackfix_dir"] is None: kwargs["stackfix_dir"] = os.path.split( self.get_binary_path(validate_exists=False))[0] here = os.path.split(__file__)[0] if kwargs["exclude"] is None and kwargs[ "include"] is None and not sys.platform.startswith("linux"): kwargs["exclude"] = ["css"] if kwargs["ssl_type"] in (None, "pregenerated"): if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = os.path.join(here, "certs", "cacert.pem") if kwargs["host_key_path"] is None: kwargs["host_key_path"] = os.path.join( here, "certs", "web-platform.test.key") if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = os.path.join( here, "certs", "web-platform.test.pem") kwargs["capture_stdio"] = True if kwargs["webdriver_binary"] is None: kwargs["webdriver_binary"] = self.get_binary_path( "geckodriver", validate_exists=False) self.setup_fonts_firefox() kwargs = wptcommandline.check_args(kwargs) return kwargs
def set_defaults(paths, kwargs): if kwargs["product"] is None: kwargs["product"] = "servo" if kwargs["config"] is None and "config" in paths: kwargs["config"] = paths["config"] if kwargs["include_manifest"] is None and "include_manifest" in paths: kwargs["include_manifest"] = paths["include_manifest"] if kwargs["binary"] is None: bin_dir = "release" if kwargs["release"] else "debug" bin_path = servo_path("components", "servo", "target", bin_dir, "servo") kwargs["binary"] = bin_path if kwargs["processes"] is None: kwargs["processes"] = multiprocessing.cpu_count() wptcommandline.check_args(kwargs)
def set_defaults(paths, kwargs): if kwargs["product"] is None: kwargs["product"] = "servo" if kwargs["config"] is None and "config" in paths: kwargs["config"] = paths["config"] if kwargs["include_manifest"] is None and "include_manifest" in paths: kwargs["include_manifest"] = paths["include_manifest"] if kwargs["binary"] is None: bin_dir = "release" if kwargs["release"] else "debug" bin_path = servo_path("target", bin_dir, "servo") kwargs["binary"] = bin_path if kwargs["processes"] is None: kwargs["processes"] = multiprocessing.cpu_count() wptcommandline.check_args(kwargs)
def set_defaults(kwargs): if kwargs["product"] is None: kwargs["product"] = "servo" if kwargs["config"] is None and "config" in paths: kwargs["config"] = paths["config"] if kwargs["include_manifest"] is None and "include_manifest" in paths: kwargs["include_manifest"] = paths["include_manifest"] if kwargs["manifest_update"] is None: kwargs["manifest_update"] = False if kwargs["binary"] is None: bin_dir = "release" if kwargs["release"] else "debug" bin_name = "servo" if sys.platform == "win32": bin_name += ".exe" bin_path = servo_path("target", bin_dir, bin_name) kwargs["binary"] = bin_path kwargs["webdriver_binary"] = bin_path if kwargs["processes"] is None: kwargs["processes"] = multiprocessing.cpu_count() if kwargs["ca_cert_path"] is None: kwargs["ca_cert_path"] = paths["ca-cert-path"] if kwargs["host_key_path"] is None: kwargs["host_key_path"] = paths["host-key-path"] if kwargs["host_cert_path"] is None: kwargs["host_cert_path"] = paths["host-cert-path"] if kwargs["ssl_type"] is None: kwargs["ssl_type"] = "pregenerated" kwargs["user_stylesheets"].append(servo_path("resources", "ahem.css")) wptcommandline.check_args(kwargs)
def run(self, logger, **kwargs): from wptrunner import wptrunner if kwargs["product"] in ["firefox", None]: kwargs = self.setup.kwargs_firefox(kwargs) elif kwargs["product"] == "fennec": from wptrunner import wptcommandline kwargs = wptcommandline.check_args( self.setup.kwargs_common(kwargs)) elif kwargs["product"] in ("chrome", "edge", "servo"): kwargs = self.setup.kwargs_wptrun(kwargs) else: raise ValueError("Unknown product %s" % kwargs["product"]) result = wptrunner.start(**kwargs) return int(not result)
def setup_kwargs(self, kwargs): build_path = os.path.join(self.topobjdir, 'build') if build_path not in sys.path: sys.path.append(build_path) if kwargs["config"] is None: kwargs["config"] = os.path.join(self.topsrcdir, 'testing', 'web-platform', 'wptrunner.ini') if kwargs["binary"] is None: kwargs["binary"] = os.path.join(self.get_binary_path('app')) if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.topobjdir, '_tests', 'web-platform', "prefs") kwargs["capture_stdio"] = True kwargs = wptcommandline.check_args(kwargs)
def run(self, logger, **kwargs): from wptrunner import wptrunner if kwargs["manifest_update"] is not False: self.update_manifest(logger) kwargs["manifest_update"] = False if kwargs["product"] in ["firefox", None]: kwargs = self.setup.kwargs_firefox(kwargs) elif kwargs["product"] == "firefox_android": from wptrunner import wptcommandline kwargs = wptcommandline.check_args(self.setup.kwargs_common(kwargs)) elif kwargs["product"] in ("chrome", "edge", "servo"): kwargs = self.setup.kwargs_wptrun(kwargs) else: raise ValueError("Unknown product %s" % kwargs["product"]) result = wptrunner.start(**kwargs) return int(result)
def kwargs_firefox(self, kwargs): from wptrunner import wptcommandline kwargs = self.kwargs_common(kwargs) if kwargs["binary"] is None: kwargs["binary"] = self.get_binary_path() if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = self.get_binary_path('certutil') if kwargs["webdriver_binary"] is None: kwargs["webdriver_binary"] = self.get_binary_path("geckodriver", validate_exists=False) self.setup_fonts_firefox() kwargs = wptcommandline.check_args(kwargs) return kwargs
def kwargs_wptrun(self, kwargs): from wptrunner import wptcommandline here = os.path.join(self.topsrcdir, 'testing', 'web-platform') sys.path.insert(0, os.path.join(here, "tests", "tools")) import wptrun product = kwargs["product"] setup_func = { "chrome": wptrun.setup_chrome, "edge": wptrun.setup_edge, "servo": wptrun.setup_servo, }[product] try: wptrun.check_environ(product) setup_func( wptrun.virtualenv.Virtualenv( self.virtualenv_manager.virtualenv_root), kwargs, True) except wptrun.WptrunError as e: print(e.message, file=sys.stderr) sys.exit(1) kwargs["tests_root"] = os.path.join(here, "tests") if kwargs["metadata_root"] is None: metadir = os.path.join(here, "products", kwargs["product"]) if not os.path.exists(metadir): os.makedirs(metadir) kwargs["metadata_root"] = metadir src_manifest = os.path.join(here, "meta", "MANIFEST.json") dest_manifest = os.path.join(kwargs["metadata_root"], "MANIFEST.json") if not os.path.exists(dest_manifest) and os.path.exists(src_manifest): with open(src_manifest) as src, open(dest_manifest, "w") as dest: dest.write(src.read()) kwargs = wptcommandline.check_args(kwargs)
def kwargs_firefox(self, kwargs): """Setup kwargs specific to running Firefox and other gecko browsers""" import mozinfo from wptrunner import wptcommandline kwargs = self.kwargs_common(kwargs) if kwargs["binary"] is None: kwargs["binary"] = self.get_binary_path() if kwargs["certutil_binary"] is None: kwargs["certutil_binary"] = self.get_binary_path("certutil") if kwargs["webdriver_binary"] is None: kwargs["webdriver_binary"] = self.get_binary_path( "geckodriver", validate_exists=False ) if kwargs["install_fonts"] is None: kwargs["install_fonts"] = True if ( kwargs["install_fonts"] and mozinfo.info["os"] == "win" and mozinfo.info["os_version"] == "6.1" ): # On Windows 7 --install-fonts fails, so fall back to a Firefox-specific codepath self.setup_fonts_firefox() kwargs["install_fonts"] = False if kwargs["preload_browser"] is None: kwargs["preload_browser"] = False if kwargs["prefs_root"] is None: kwargs["prefs_root"] = os.path.join(self.topsrcdir, "testing", "profiles") if kwargs["stackfix_dir"] is None: kwargs["stackfix_dir"] = self.bindir kwargs = wptcommandline.check_args(kwargs) return kwargs
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptcommandline kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0].replace("-", "_") sub_product = product_parts[1:] check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() affected_revish = kwargs.pop("affected", None) if affected_revish is not None: # TODO: Consolidate with `./wpt tests-affected --ignore-rules`: # https://github.com/web-platform-tests/wpt/issues/14560 files_changed, _ = testfiles.files_changed( affected_revish, ignore_rules=["resources/testharness*"], include_uncommitted=True, include_new=True) # TODO: Perhaps use wptrunner.testloader.ManifestLoader here # and remove the manifest-related code from testfiles. # https://github.com/web-platform-tests/wpt/issues/14421 tests_changed, tests_affected = testfiles.affected_testfiles( files_changed, manifest_path=kwargs.get("manifest_path"), manifest_update=kwargs["manifest_update"]) test_list = tests_changed | tests_affected logger.info("Identified %s affected tests" % len(test_list)) test_list = [os.path.relpath(item, wpt_root) for item in test_list] kwargs["test_list"] += test_list kwargs["default_exclude"] = True if install_browser and not kwargs["channel"]: logger.info( "--install-browser is given but --channel is not set, default to nightly channel" ) kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel is not None: if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel else: logger.info( "Valid channels for %s not known; using argument unmodified" % kwargs["product"]) kwargs["browser_channel"] = kwargs["channel"] del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") if not venv.skip_virtualenv_setup: venv.install_requirements( os.path.join(wptrunner_path, "requirements.txt")) # Only update browser_version if it was not given as a command line # argument, so that it can be overridden on the command line. if not kwargs["browser_version"]: kwargs["browser_version"] = setup_cls.browser.version( binary=kwargs.get("binary") or kwargs.get("package_name"), webdriver_binary=kwargs.get("webdriver_binary"), ) return kwargs
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptcommandline kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() affected_revish = kwargs.pop("affected", None) if affected_revish is not None: files_changed, _ = testfiles.files_changed(affected_revish, include_uncommitted=True, include_new=True) # TODO: Perhaps use wptrunner.testloader.ManifestLoader here # and remove the manifest-related code from testfiles. # https://github.com/web-platform-tests/wpt/issues/14421 tests_changed, tests_affected = testfiles.affected_testfiles( files_changed, manifest_path=kwargs.get("manifest_path"), manifest_update=kwargs["manifest_update"]) test_list = tests_changed | tests_affected logger.info("Identified %s affected tests" % len(test_list)) if not test_list and not kwargs["test_list"]: logger.info("Quitting because no tests were affected.") exit() test_list = [os.path.relpath(item, wpt_root) for item in test_list] kwargs["test_list"] += test_list if install_browser and not kwargs["channel"]: logger.info( "--install-browser is given but --channel is not set, default to nightly channel" ) kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel is not None: if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel else: logger.info( "Valid channels for %s not known; using argument unmodified" % kwargs["product"]) del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version( binary=kwargs.get("binary"), webdriver_binary=kwargs.get("webdriver_binary")) return kwargs
def set_defaults(args): args.include_manifest = args.include_manifest if args.include_manifest else wptsubdir("include.ini") args.product = "servo" rv = vars(args) wptcommandline.check_args(rv) return rv
def setup_wptrunner(venv, prompt=True, install_browser=False, **kwargs): from wptrunner import wptcommandline kwargs = utils.Kwargs(kwargs.iteritems()) product_parts = kwargs["product"].split(":") kwargs["product"] = product_parts[0] sub_product = product_parts[1:] check_environ(kwargs["product"]) args_general(kwargs) if kwargs["product"] not in product_setup: raise WptrunError("Unsupported product %s" % kwargs["product"]) setup_cls = product_setup[kwargs["product"]](venv, prompt, sub_product) setup_cls.install_requirements() affected_revish = kwargs.pop("affected", None) if affected_revish is not None: # TODO: Consolidate with `./wpt tests-affected --ignore-rules`: # https://github.com/web-platform-tests/wpt/issues/14560 files_changed, _ = testfiles.files_changed( affected_revish, ignore_rules=["resources/testharness*"], include_uncommitted=True, include_new=True) # TODO: Perhaps use wptrunner.testloader.ManifestLoader here # and remove the manifest-related code from testfiles. # https://github.com/web-platform-tests/wpt/issues/14421 tests_changed, tests_affected = testfiles.affected_testfiles( files_changed, manifest_path=kwargs.get("manifest_path"), manifest_update=kwargs["manifest_update"]) test_list = tests_changed | tests_affected logger.info("Identified %s affected tests" % len(test_list)) if not test_list and not kwargs["test_list"]: logger.info("Quitting because no tests were affected.") exit() test_list = [os.path.relpath(item, wpt_root) for item in test_list] kwargs["test_list"] += test_list if install_browser and not kwargs["channel"]: logger.info("--install-browser is given but --channel is not set, default to nightly channel") kwargs["channel"] = "nightly" if kwargs["channel"]: channel = install.get_channel(kwargs["product"], kwargs["channel"]) if channel is not None: if channel != kwargs["channel"]: logger.info("Interpreting channel '%s' as '%s'" % (kwargs["channel"], channel)) kwargs["browser_channel"] = channel else: logger.info("Valid channels for %s not known; using argument unmodified" % kwargs["product"]) del kwargs["channel"] if install_browser: logger.info("Installing browser") kwargs["binary"] = setup_cls.install(venv, channel=channel) setup_cls.setup(kwargs) wptcommandline.check_args(kwargs) wptrunner_path = os.path.join(wpt_root, "tools", "wptrunner") venv.install_requirements(os.path.join(wptrunner_path, "requirements.txt")) kwargs['browser_version'] = setup_cls.browser.version(binary=kwargs.get("binary"), webdriver_binary=kwargs.get("webdriver_binary")) return kwargs