2015-12-07 15:28:40 +03:00
|
|
|
# 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, print_function, unicode_literals
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import mozinfo
|
2019-07-16 04:21:55 +03:00
|
|
|
from six.moves.urllib.parse import urljoin
|
|
|
|
from six.moves.urllib.request import pathname2url
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
from mach.decorators import (
|
|
|
|
CommandArgument,
|
|
|
|
CommandProvider,
|
|
|
|
Command,
|
|
|
|
)
|
|
|
|
|
|
|
|
from mozbuild.base import MachCommandBase, MozbuildObject
|
|
|
|
from mozbuild.base import MachCommandConditions as conditions
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
|
|
|
def get_parser():
|
|
|
|
parser = argparse.ArgumentParser()
|
2020-10-24 03:36:18 +03:00
|
|
|
parser.add_argument("suite_name", nargs=1, type=str, action="store",
|
|
|
|
help="Suite to run in mozharness")
|
|
|
|
parser.add_argument("mozharness_args", nargs=argparse.REMAINDER,
|
|
|
|
help="Extra arguments to pass to mozharness")
|
2015-12-07 15:28:40 +03:00
|
|
|
return parser
|
|
|
|
|
|
|
|
class MozharnessRunner(MozbuildObject):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
MozbuildObject.__init__(self, *args, **kwargs)
|
|
|
|
|
2020-10-24 03:36:18 +03:00
|
|
|
|
2016-02-25 23:45:25 +03:00
|
|
|
self.test_packages_url = self._test_packages_url()
|
2015-12-07 15:28:40 +03:00
|
|
|
self.installer_url = self._installer_url()
|
|
|
|
|
|
|
|
desktop_unittest_config = [
|
2020-10-24 03:36:18 +03:00
|
|
|
"--config-file", lambda: self.config_path("unittests",
|
|
|
|
"%s_unittest.py" % mozinfo.info['os']),
|
|
|
|
"--config-file", lambda: self.config_path("developer_config.py")]
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
self.config = {
|
|
|
|
"__defaults__": {
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": ["--download-symbols", "ondemand",
|
|
|
|
"--installer-url", self.installer_url,
|
|
|
|
"--test-packages-url", self.test_packages_url]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
2020-10-24 03:36:18 +03:00
|
|
|
|
2016-02-03 20:43:05 +03:00
|
|
|
"mochitest-valgrind": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--mochitest-suite", "valgrind-plain"]
|
2016-02-03 20:43:05 +03:00
|
|
|
},
|
2015-12-07 15:28:40 +03:00
|
|
|
"mochitest": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--mochitest-suite", "plain"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"mochitest-chrome": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--mochitest-suite", "chrome"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"mochitest-browser-chrome": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--mochitest-suite", "browser-chrome"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"mochitest-devtools-chrome": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--mochitest-suite", "mochitest-devtools-chrome"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
2019-06-17 16:57:03 +03:00
|
|
|
"mochitest-remote": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--mochitest-suite", "mochitest-remote"]
|
2019-06-17 16:57:03 +03:00
|
|
|
},
|
2015-12-07 15:28:40 +03:00
|
|
|
"crashtest": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--reftest-suite", "crashtest"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"jsreftest": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--reftest-suite", "jsreftest"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
2016-11-07 16:59:49 +03:00
|
|
|
"reftest": {
|
2015-12-07 15:28:40 +03:00
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--reftest-suite", "reftest"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"reftest-no-accel": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--reftest-suite", "reftest-no-accel"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"cppunittest": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--cppunittest-suite", "cppunittest"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"xpcshell": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--xpcshell-suite", "xpcshell"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"xpcshell-addons": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--xpcshell-suite", "xpcshell-addons"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"jittest": {
|
|
|
|
"script": "desktop_unittest.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": desktop_unittest_config + [
|
|
|
|
"--jittest-suite", "jittest"]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"marionette": {
|
|
|
|
"script": "marionette.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": ["--config-file", self.config_path("marionette",
|
|
|
|
"test_config.py")]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
"web-platform-tests": {
|
|
|
|
"script": "web_platform_tests.py",
|
2020-10-24 03:36:18 +03:00
|
|
|
"config": ["--config-file", self.config_path("web_platform_tests",
|
|
|
|
self.wpt_config)]
|
2015-12-07 15:28:40 +03:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-10-24 03:36:18 +03:00
|
|
|
|
2015-12-07 15:28:40 +03:00
|
|
|
def path_to_url(self, path):
|
2020-10-24 03:36:18 +03:00
|
|
|
return urljoin('file:', pathname2url(path))
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
def _installer_url(self):
|
|
|
|
package_re = {
|
|
|
|
"linux": re.compile("^firefox-\d+\..+\.tar\.bz2$"),
|
|
|
|
"win": re.compile("^firefox-\d+\..+\.installer\.exe$"),
|
|
|
|
"mac": re.compile("^firefox-\d+\..+\.mac(?:64)?\.dmg$"),
|
2020-10-24 03:36:18 +03:00
|
|
|
}[mozinfo.info['os']]
|
2015-12-07 15:28:40 +03:00
|
|
|
dist_path = os.path.join(self.topobjdir, "dist")
|
2020-10-24 03:36:18 +03:00
|
|
|
filenames = [item for item in os.listdir(dist_path) if
|
|
|
|
package_re.match(item)]
|
2015-12-07 15:28:40 +03:00
|
|
|
assert len(filenames) == 1
|
|
|
|
return self.path_to_url(os.path.join(dist_path, filenames[0]))
|
|
|
|
|
2016-02-25 23:45:25 +03:00
|
|
|
def _test_packages_url(self):
|
|
|
|
dist_path = os.path.join(self.topobjdir, "dist")
|
2020-10-24 03:36:18 +03:00
|
|
|
filenames = [item for item in os.listdir(dist_path) if
|
|
|
|
item.endswith('test_packages.json')]
|
2016-02-25 23:45:25 +03:00
|
|
|
assert len(filenames) == 1
|
|
|
|
return self.path_to_url(os.path.join(dist_path, filenames[0]))
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
def config_path(self, *parts):
|
2020-10-24 03:36:18 +03:00
|
|
|
return self.path_to_url(os.path.join(self.topsrcdir, "testing", "mozharness",
|
|
|
|
"configs", *parts))
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
@property
|
|
|
|
def wpt_config(self):
|
2020-10-24 03:36:18 +03:00
|
|
|
return "test_config.py" if mozinfo.info['os'] != "win" else "test_config_windows.py"
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
def run_suite(self, suite, **kwargs):
|
|
|
|
default_config = self.config.get("__defaults__")
|
|
|
|
suite_config = self.config.get(suite)
|
|
|
|
|
|
|
|
if suite_config is None:
|
|
|
|
print("Unknown suite %s" % suite)
|
|
|
|
return 1
|
|
|
|
|
2020-10-24 03:36:18 +03:00
|
|
|
script = os.path.join(self.topsrcdir, "testing", "mozharness",
|
|
|
|
"scripts", suite_config["script"])
|
|
|
|
options = [item() if callable(item) else item
|
|
|
|
for item in default_config["config"] + suite_config["config"]]
|
2015-12-07 15:28:40 +03:00
|
|
|
|
|
|
|
cmd = [script] + options
|
|
|
|
|
|
|
|
rv = subprocess.call(cmd, cwd=os.path.dirname(script))
|
|
|
|
return rv
|
|
|
|
|
|
|
|
|
|
|
|
@CommandProvider
|
|
|
|
class MozharnessCommands(MachCommandBase):
|
2020-10-24 03:36:18 +03:00
|
|
|
@Command('mozharness', category='testing',
|
|
|
|
description='Run tests using mozharness.',
|
|
|
|
conditions=[conditions.is_firefox_or_android],
|
|
|
|
parser=get_parser)
|
2015-12-07 15:28:40 +03:00
|
|
|
def mozharness(self, **kwargs):
|
|
|
|
runner = self._spawn(MozharnessRunner)
|
|
|
|
return runner.run_suite(kwargs.pop("suite_name")[0], **kwargs)
|