2013-09-09 23:37:38 +04: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/.
|
|
|
|
|
2015-06-22 03:39:09 +03:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2017-05-17 19:30:34 +03:00
|
|
|
import argparse
|
2017-01-20 19:15:25 +03:00
|
|
|
import logging
|
2013-09-09 23:37:38 +04:00
|
|
|
import os
|
2014-06-18 22:21:12 +04:00
|
|
|
import sys
|
2015-09-01 08:52:07 +03:00
|
|
|
import subprocess
|
2013-09-09 23:37:38 +04:00
|
|
|
|
|
|
|
from mach.decorators import (
|
|
|
|
CommandArgument,
|
|
|
|
CommandProvider,
|
|
|
|
Command,
|
2017-11-23 21:04:19 +03:00
|
|
|
SettingsProvider,
|
2018-08-07 19:05:37 +03:00
|
|
|
SubCommand,
|
2013-09-09 23:37:38 +04:00
|
|
|
)
|
|
|
|
|
2018-07-20 17:58:06 +03:00
|
|
|
from mozbuild.base import (
|
|
|
|
BuildEnvironmentNotFoundException,
|
|
|
|
MachCommandBase,
|
|
|
|
MachCommandConditions as conditions,
|
|
|
|
)
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
UNKNOWN_TEST = '''
|
2015-10-01 20:10:45 +03:00
|
|
|
I was unable to find tests from the given argument(s).
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2015-10-01 20:10:45 +03:00
|
|
|
You should specify a test directory, filename, test suite name, or
|
2020-06-09 22:35:19 +03:00
|
|
|
abbreviation.
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
It's possible my little brain doesn't know about the type of test you are
|
|
|
|
trying to execute. If you suspect this, please request support by filing
|
|
|
|
a bug at
|
|
|
|
https://bugzilla.mozilla.org/enter_bug.cgi?product=Testing&component=General.
|
|
|
|
'''.strip()
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
UNKNOWN_FLAVOR = '''
|
2018-02-13 22:16:46 +03:00
|
|
|
I know you are trying to run a %s%s test. Unfortunately, I can't run those
|
2014-06-18 22:21:12 +04:00
|
|
|
tests yet. Sorry!
|
2013-09-09 23:37:38 +04:00
|
|
|
'''.strip()
|
|
|
|
|
|
|
|
TEST_HELP = '''
|
2014-06-18 22:21:12 +04:00
|
|
|
Test or tests to run. Tests can be specified by filename, directory, suite
|
|
|
|
name or suite alias.
|
|
|
|
|
2019-07-16 04:21:55 +03:00
|
|
|
The following test suites and aliases are supported: {}
|
|
|
|
'''.strip()
|
2013-09-09 23:37:38 +04:00
|
|
|
|
|
|
|
|
2017-11-23 21:04:19 +03:00
|
|
|
@SettingsProvider
|
|
|
|
class TestConfig(object):
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def config_settings(cls):
|
|
|
|
from mozlog.commandline import log_formatters
|
|
|
|
from mozlog.structuredlog import log_levels
|
|
|
|
format_desc = "The default format to use when running tests with `mach test`."
|
|
|
|
format_choices = log_formatters.keys()
|
|
|
|
level_desc = "The default log level to use when running tests with `mach test`."
|
|
|
|
level_choices = [l.lower() for l in log_levels]
|
|
|
|
return [
|
2018-03-12 23:46:53 +03:00
|
|
|
('test.format', 'string', format_desc, 'mach', {'choices': format_choices}),
|
2017-11-23 21:04:19 +03:00
|
|
|
('test.level', 'string', level_desc, 'info', {'choices': level_choices}),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2017-12-07 01:29:23 +03:00
|
|
|
def get_test_parser():
|
|
|
|
from mozlog.commandline import add_logging_group
|
2019-07-16 04:21:55 +03:00
|
|
|
from moztest.resolve import TEST_SUITES
|
2017-12-07 01:29:23 +03:00
|
|
|
parser = argparse.ArgumentParser()
|
2019-07-16 04:21:55 +03:00
|
|
|
parser.add_argument('what', default=None, nargs='+',
|
|
|
|
help=TEST_HELP.format(', '.join(sorted(TEST_SUITES))))
|
2017-12-07 01:29:23 +03:00
|
|
|
parser.add_argument('extra_args', default=None, nargs=argparse.REMAINDER,
|
|
|
|
help="Extra arguments to pass to the underlying test command(s). "
|
|
|
|
"If an underlying command doesn't recognize the argument, it "
|
|
|
|
"will fail.")
|
2019-07-26 18:18:18 +03:00
|
|
|
parser.add_argument('--debugger', default=None, action='store',
|
|
|
|
nargs='?', help="Specify a debugger to use.")
|
2017-12-07 01:29:23 +03:00
|
|
|
add_logging_group(parser)
|
|
|
|
return parser
|
|
|
|
|
|
|
|
|
2019-04-30 18:20:51 +03:00
|
|
|
ADD_TEST_SUPPORTED_SUITES = ['mochitest-chrome', 'mochitest-plain', 'mochitest-browser-chrome',
|
2019-04-11 12:44:32 +03:00
|
|
|
'web-platform-tests-testharness', 'web-platform-tests-reftest',
|
2019-04-08 22:09:42 +03:00
|
|
|
'xpcshell']
|
|
|
|
ADD_TEST_SUPPORTED_DOCS = ['js', 'html', 'xhtml', 'xul']
|
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
SUITE_SYNONYMS = {
|
|
|
|
"wpt": "web-platform-tests-testharness",
|
|
|
|
"wpt-testharness": "web-platform-tests-testharness",
|
|
|
|
"wpt-reftest": "web-platform-tests-reftest"
|
|
|
|
}
|
|
|
|
|
|
|
|
MISSING_ARG = object()
|
|
|
|
|
|
|
|
|
|
|
|
def create_parser_addtest():
|
|
|
|
import addtest
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('--suite',
|
2020-02-13 19:56:44 +03:00
|
|
|
choices=sorted(ADD_TEST_SUPPORTED_SUITES + list(SUITE_SYNONYMS.keys())),
|
2019-04-11 12:44:32 +03:00
|
|
|
help='suite for the test. '
|
|
|
|
'If you pass a `test` argument this will be determined '
|
|
|
|
'based on the filename and the folder it is in')
|
|
|
|
parser.add_argument('-o', '--overwrite',
|
|
|
|
action='store_true',
|
|
|
|
help='Overwrite an existing file if it exists.')
|
|
|
|
parser.add_argument('--doc',
|
|
|
|
choices=ADD_TEST_SUPPORTED_DOCS,
|
|
|
|
help='Document type for the test (if applicable).'
|
|
|
|
'If you pass a `test` argument this will be determined '
|
|
|
|
'based on the filename.')
|
|
|
|
parser.add_argument("-e", "--editor", action="store", nargs="?",
|
|
|
|
default=MISSING_ARG, help="Open the created file(s) in an editor; if a "
|
|
|
|
"binary is supplied it will be used otherwise the default editor for "
|
|
|
|
"your environment will be opened")
|
|
|
|
|
|
|
|
for base_suite in addtest.TEST_CREATORS:
|
|
|
|
cls = addtest.TEST_CREATORS[base_suite]
|
|
|
|
if hasattr(cls, "get_parser"):
|
|
|
|
group = parser.add_argument_group(base_suite)
|
|
|
|
cls.get_parser(group)
|
|
|
|
|
|
|
|
parser.add_argument('test',
|
|
|
|
nargs='?',
|
|
|
|
help=('Test to create.'))
|
|
|
|
return parser
|
|
|
|
|
2019-04-08 22:09:42 +03:00
|
|
|
|
2013-09-09 23:37:38 +04:00
|
|
|
@CommandProvider
|
2019-04-08 22:09:42 +03:00
|
|
|
class AddTest(MachCommandBase):
|
|
|
|
@Command('addtest', category='testing',
|
2019-04-11 12:44:32 +03:00
|
|
|
description='Generate tests based on templates',
|
|
|
|
parser=create_parser_addtest)
|
|
|
|
def addtest(self, suite=None, test=None, doc=None, overwrite=False,
|
|
|
|
editor=MISSING_ARG, **kwargs):
|
|
|
|
import addtest
|
2020-01-24 01:46:24 +03:00
|
|
|
import io
|
2019-07-16 04:21:55 +03:00
|
|
|
from moztest.resolve import TEST_SUITES
|
2019-04-11 12:44:32 +03:00
|
|
|
|
|
|
|
if not suite and not test:
|
|
|
|
return create_parser_addtest().parse_args(["--help"])
|
|
|
|
|
|
|
|
if suite in SUITE_SYNONYMS:
|
|
|
|
suite = SUITE_SYNONYMS[suite]
|
|
|
|
|
2019-04-08 22:09:42 +03:00
|
|
|
if test:
|
|
|
|
if not overwrite and os.path.isfile(os.path.abspath(test)):
|
|
|
|
print("Error: can't generate a test that already exists:", test)
|
|
|
|
return 1
|
|
|
|
|
|
|
|
abs_test = os.path.abspath(test)
|
|
|
|
if doc is None:
|
|
|
|
doc = self.guess_doc(abs_test)
|
|
|
|
if suite is None:
|
|
|
|
guessed_suite, err = self.guess_suite(abs_test)
|
|
|
|
if err:
|
|
|
|
print(err)
|
|
|
|
return 1
|
|
|
|
suite = guessed_suite
|
|
|
|
|
|
|
|
else:
|
|
|
|
test = None
|
|
|
|
if doc is None:
|
|
|
|
doc = "html"
|
|
|
|
|
|
|
|
if not suite:
|
|
|
|
print("We couldn't automatically determine a suite. "
|
|
|
|
"Please specify `--suite` with one of the following options:\n{}\n"
|
|
|
|
"If you'd like to add support to a new suite, please file a bug "
|
|
|
|
"blocking https://bugzilla.mozilla.org/show_bug.cgi?id=1540285."
|
|
|
|
.format(ADD_TEST_SUPPORTED_SUITES))
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if doc not in ADD_TEST_SUPPORTED_DOCS:
|
|
|
|
print("Error: invalid `doc`. Either pass in a test with a valid extension"
|
|
|
|
"({}) or pass in the `doc` argument".format(ADD_TEST_SUPPORTED_DOCS))
|
|
|
|
return 1
|
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
creator_cls = addtest.creator_for_suite(suite)
|
|
|
|
|
|
|
|
if creator_cls is None:
|
2019-04-08 22:09:42 +03:00
|
|
|
print("Sorry, `addtest` doesn't currently know how to add {}".format(suite))
|
|
|
|
return 1
|
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
creator = creator_cls(self.topsrcdir, test, suite, doc, **kwargs)
|
2019-04-08 22:09:42 +03:00
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
creator.check_args()
|
2019-04-08 22:09:42 +03:00
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
paths = []
|
2019-08-27 00:06:02 +03:00
|
|
|
added_tests = False
|
2019-04-11 12:44:32 +03:00
|
|
|
for path, template in creator:
|
2019-08-27 00:06:02 +03:00
|
|
|
if not template:
|
|
|
|
continue
|
|
|
|
added_tests = True
|
2019-04-11 12:44:32 +03:00
|
|
|
if (path):
|
|
|
|
paths.append(path)
|
|
|
|
print("Adding a test file at {} (suite `{}`)".format(path, suite))
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.makedirs(os.path.dirname(path))
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
2020-01-24 01:46:24 +03:00
|
|
|
with io.open(path, "w", newline='\n') as f:
|
2019-04-11 12:44:32 +03:00
|
|
|
f.write(template)
|
|
|
|
else:
|
|
|
|
# write to stdout if you passed only suite and doc and not a file path
|
|
|
|
print(template)
|
|
|
|
|
2019-08-27 00:06:02 +03:00
|
|
|
if not added_tests:
|
|
|
|
return 1
|
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
if test:
|
|
|
|
creator.update_manifest()
|
|
|
|
|
|
|
|
# Small hack, should really do this better
|
|
|
|
if suite.startswith("wpt-"):
|
|
|
|
suite = "web-platform-tests"
|
2019-04-08 22:09:42 +03:00
|
|
|
|
|
|
|
mach_command = TEST_SUITES[suite]["mach_command"]
|
|
|
|
print('Please make sure to add the new test to your commit. '
|
|
|
|
'You can now run the test with:\n ./mach {} {}'.format(mach_command, test))
|
2019-04-11 12:44:32 +03:00
|
|
|
|
|
|
|
if editor is not MISSING_ARG:
|
|
|
|
if editor is not None:
|
|
|
|
editor = editor
|
|
|
|
elif "VISUAL" in os.environ:
|
|
|
|
editor = os.environ["VISUAL"]
|
|
|
|
elif "EDITOR" in os.environ:
|
|
|
|
editor = os.environ["EDITOR"]
|
|
|
|
else:
|
|
|
|
print('Unable to determine editor; please specify a binary')
|
|
|
|
editor = None
|
|
|
|
|
|
|
|
proc = None
|
|
|
|
if editor:
|
|
|
|
import subprocess
|
|
|
|
proc = subprocess.Popen("%s %s" % (editor, " ".join(paths)), shell=True)
|
|
|
|
|
|
|
|
if proc:
|
|
|
|
proc.wait()
|
|
|
|
|
2019-04-08 22:09:42 +03:00
|
|
|
return 0
|
|
|
|
|
|
|
|
def guess_doc(self, abs_test):
|
|
|
|
filename = os.path.basename(abs_test)
|
|
|
|
return os.path.splitext(filename)[1].strip(".")
|
|
|
|
|
|
|
|
def guess_suite(self, abs_test):
|
|
|
|
# If you pass a abs_test, try to detect the type based on the name
|
|
|
|
# and folder. This detection can be skipped if you pass the `type` arg.
|
|
|
|
err = None
|
|
|
|
guessed_suite = None
|
|
|
|
parent = os.path.dirname(abs_test)
|
|
|
|
filename = os.path.basename(abs_test)
|
|
|
|
|
|
|
|
has_browser_ini = os.path.isfile(os.path.join(parent, "browser.ini"))
|
|
|
|
has_chrome_ini = os.path.isfile(os.path.join(parent, "chrome.ini"))
|
|
|
|
has_plain_ini = os.path.isfile(os.path.join(parent, "mochitest.ini"))
|
|
|
|
has_xpcshell_ini = os.path.isfile(os.path.join(parent, "xpcshell.ini"))
|
|
|
|
|
2019-04-11 12:44:32 +03:00
|
|
|
in_wpt_folder = abs_test.startswith(
|
|
|
|
os.path.abspath(os.path.join("testing", "web-platform")))
|
|
|
|
|
|
|
|
if in_wpt_folder:
|
|
|
|
guessed_suite = "web-platform-tests-testharness"
|
|
|
|
if "/css/" in abs_test:
|
|
|
|
guessed_suite = "web-platform-tests-reftest"
|
|
|
|
elif (filename.startswith("test_") and
|
|
|
|
has_xpcshell_ini and
|
|
|
|
self.guess_doc(abs_test) == "js"):
|
2019-04-08 22:09:42 +03:00
|
|
|
guessed_suite = "xpcshell"
|
|
|
|
else:
|
|
|
|
if filename.startswith("browser_") and has_browser_ini:
|
2019-04-30 18:20:51 +03:00
|
|
|
guessed_suite = "mochitest-browser-chrome"
|
2019-04-08 22:09:42 +03:00
|
|
|
elif filename.startswith("test_"):
|
|
|
|
if has_chrome_ini and has_plain_ini:
|
|
|
|
err = ("Error: directory contains both a chrome.ini and mochitest.ini. "
|
|
|
|
"Please set --suite=mochitest-chrome or --suite=mochitest-plain.")
|
|
|
|
elif has_chrome_ini:
|
|
|
|
guessed_suite = "mochitest-chrome"
|
|
|
|
elif has_plain_ini:
|
|
|
|
guessed_suite = "mochitest-plain"
|
|
|
|
return guessed_suite, err
|
|
|
|
|
|
|
|
|
2019-04-09 12:22:22 +03:00
|
|
|
@CommandProvider
|
2013-09-09 23:37:38 +04:00
|
|
|
class Test(MachCommandBase):
|
2017-08-17 22:50:39 +03:00
|
|
|
@Command('test', category='testing',
|
2017-12-07 01:29:23 +03:00
|
|
|
description='Run tests (detects the kind of test and runs it).',
|
|
|
|
parser=get_test_parser)
|
|
|
|
def test(self, what, extra_args, **log_args):
|
2015-06-11 18:32:02 +03:00
|
|
|
"""Run tests from names or paths.
|
|
|
|
|
|
|
|
mach test accepts arguments specifying which tests to run. Each argument
|
|
|
|
can be:
|
|
|
|
|
|
|
|
* The path to a test file
|
|
|
|
* A directory containing tests
|
|
|
|
* A test suite name
|
|
|
|
* An alias to a test suite name (codes used on TreeHerder)
|
|
|
|
|
|
|
|
When paths or directories are given, they are first resolved to test
|
|
|
|
files known to the build system.
|
|
|
|
|
|
|
|
If resolved tests belong to more than one test type/flavor/harness,
|
|
|
|
the harness for each relevant type/flavor will be invoked. e.g. if
|
|
|
|
you specify a directory with xpcshell and browser chrome mochitests,
|
|
|
|
both harnesses will be invoked.
|
|
|
|
"""
|
2017-12-07 01:29:23 +03:00
|
|
|
from mozlog.commandline import setup_logging
|
2018-02-23 17:40:06 +03:00
|
|
|
from mozlog.handlers import StreamHandler
|
2018-02-13 22:16:46 +03:00
|
|
|
from moztest.resolve import get_suite_definition, TestResolver, TEST_SUITES
|
2017-11-23 21:04:19 +03:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
resolver = self._spawn(TestResolver)
|
2017-11-08 17:59:51 +03:00
|
|
|
run_suites, run_tests = resolver.resolve_metadata(what)
|
2015-10-01 20:10:45 +03:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
if not run_suites and not run_tests:
|
|
|
|
print(UNKNOWN_TEST)
|
|
|
|
return 1
|
|
|
|
|
2019-08-23 00:05:01 +03:00
|
|
|
if log_args.get('debugger', None):
|
2019-07-26 18:18:18 +03:00
|
|
|
import mozdebug
|
|
|
|
if not mozdebug.get_debugger_info(log_args.get('debugger')):
|
|
|
|
sys.exit(1)
|
2019-08-22 23:51:11 +03:00
|
|
|
extra_args_debugger_notation = '='.join([
|
|
|
|
'--debugger',
|
|
|
|
log_args.get('debugger')
|
|
|
|
]).encode('ascii')
|
|
|
|
if extra_args:
|
|
|
|
extra_args.append(extra_args_debugger_notation)
|
|
|
|
else:
|
|
|
|
extra_args = [extra_args_debugger_notation]
|
2019-07-26 18:18:18 +03:00
|
|
|
|
2017-11-23 21:04:19 +03:00
|
|
|
# Create shared logger
|
2018-03-19 23:04:02 +03:00
|
|
|
format_args = {'level': self._mach_context.settings['test']['level']}
|
|
|
|
if not run_suites and len(run_tests) == 1:
|
|
|
|
format_args['verbose'] = True
|
|
|
|
format_args['compact'] = False
|
|
|
|
|
2017-12-07 01:29:23 +03:00
|
|
|
default_format = self._mach_context.settings['test']['format']
|
2018-03-19 23:04:02 +03:00
|
|
|
log = setup_logging('mach-test', log_args, {default_format: sys.stdout}, format_args)
|
2018-02-23 17:40:06 +03:00
|
|
|
for handler in log.handlers:
|
|
|
|
if isinstance(handler, StreamHandler):
|
|
|
|
handler.formatter.inner.summary_on_shutdown = True
|
2017-11-23 21:04:19 +03:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
status = None
|
|
|
|
for suite_name in run_suites:
|
|
|
|
suite = TEST_SUITES[suite_name]
|
2017-11-23 21:04:19 +03:00
|
|
|
kwargs = suite['kwargs']
|
|
|
|
kwargs['log'] = log
|
2020-06-04 19:14:08 +03:00
|
|
|
kwargs.setdefault('subsuite', None)
|
2013-09-09 23:37:38 +04:00
|
|
|
|
|
|
|
if 'mach_command' in suite:
|
2014-06-18 22:21:12 +04:00
|
|
|
res = self._mach_context.commands.dispatch(
|
|
|
|
suite['mach_command'], self._mach_context,
|
2017-11-23 21:04:19 +03:00
|
|
|
argv=extra_args, **kwargs)
|
2014-06-18 22:21:12 +04:00
|
|
|
if res:
|
|
|
|
status = res
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2015-02-06 23:36:59 +03:00
|
|
|
buckets = {}
|
2014-06-18 22:21:12 +04:00
|
|
|
for test in run_tests:
|
2016-10-31 20:04:42 +03:00
|
|
|
key = (test['flavor'], test.get('subsuite', ''))
|
2015-02-06 23:36:59 +03:00
|
|
|
buckets.setdefault(key, []).append(test)
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2015-02-06 23:36:59 +03:00
|
|
|
for (flavor, subsuite), tests in sorted(buckets.items()):
|
2019-04-23 01:32:34 +03:00
|
|
|
_, m = get_suite_definition(flavor, subsuite)
|
2014-06-18 22:21:12 +04:00
|
|
|
if 'mach_command' not in m:
|
2018-02-13 22:16:46 +03:00
|
|
|
substr = '-{}'.format(subsuite) if subsuite else ''
|
|
|
|
print(UNKNOWN_FLAVOR % (flavor, substr))
|
2014-06-18 22:21:12 +04:00
|
|
|
status = 1
|
|
|
|
continue
|
|
|
|
|
2015-02-06 23:36:59 +03:00
|
|
|
kwargs = dict(m['kwargs'])
|
2017-11-23 21:04:19 +03:00
|
|
|
kwargs['log'] = log
|
2020-06-04 19:14:08 +03:00
|
|
|
kwargs.setdefault('subsuite', None)
|
2015-02-06 23:36:59 +03:00
|
|
|
|
2014-06-18 22:21:12 +04:00
|
|
|
res = self._mach_context.commands.dispatch(
|
2017-08-17 22:50:39 +03:00
|
|
|
m['mach_command'], self._mach_context,
|
2017-08-29 23:20:47 +03:00
|
|
|
argv=extra_args, test_objects=tests, **kwargs)
|
2014-06-18 22:21:12 +04:00
|
|
|
if res:
|
|
|
|
status = res
|
|
|
|
|
2017-11-23 21:04:19 +03:00
|
|
|
log.shutdown()
|
2014-06-18 22:21:12 +04:00
|
|
|
return status
|
2013-09-09 23:37:38 +04:00
|
|
|
|
2014-01-02 19:19:35 +04:00
|
|
|
|
|
|
|
@CommandProvider
|
|
|
|
class MachCommands(MachCommandBase):
|
|
|
|
@Command('cppunittest', category='testing',
|
2017-08-17 22:50:39 +03:00
|
|
|
description='Run cpp unit tests (C++ tests).')
|
2019-06-29 12:49:23 +03:00
|
|
|
@CommandArgument('--enable-webrender', action='store_true', default=False,
|
|
|
|
dest='enable_webrender',
|
|
|
|
help='Enable the WebRender compositor in Gecko.')
|
2014-01-02 19:19:35 +04:00
|
|
|
@CommandArgument('test_files', nargs='*', metavar='N',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Test to run. Can be specified as one or more files or '
|
|
|
|
'directories, or omitted. If omitted, the entire test suite is '
|
|
|
|
'executed.')
|
2014-01-02 19:19:35 +04:00
|
|
|
def run_cppunit_test(self, **params):
|
2015-07-16 17:38:40 +03:00
|
|
|
from mozlog import commandline
|
2017-11-23 21:04:19 +03:00
|
|
|
|
|
|
|
log = params.get('log')
|
|
|
|
if not log:
|
|
|
|
log = commandline.setup_logging("cppunittest",
|
|
|
|
{},
|
|
|
|
{"tbpl": sys.stdout})
|
2014-01-02 19:19:35 +04:00
|
|
|
|
|
|
|
# See if we have crash symbols
|
|
|
|
symbols_path = os.path.join(self.distdir, 'crashreporter-symbols')
|
|
|
|
if not os.path.isdir(symbols_path):
|
|
|
|
symbols_path = None
|
|
|
|
|
2015-09-14 17:40:35 +03:00
|
|
|
# If no tests specified, run all tests in main manifest
|
|
|
|
tests = params['test_files']
|
2020-06-10 01:32:21 +03:00
|
|
|
if not tests:
|
2015-09-14 17:40:35 +03:00
|
|
|
tests = [os.path.join(self.distdir, 'cppunittests')]
|
2017-08-17 22:50:39 +03:00
|
|
|
manifest_path = os.path.join(
|
|
|
|
self.topsrcdir, 'testing', 'cppunittest.ini')
|
2015-09-14 17:40:35 +03:00
|
|
|
else:
|
|
|
|
manifest_path = None
|
|
|
|
|
2019-05-03 22:00:46 +03:00
|
|
|
utility_path = self.bindir
|
|
|
|
|
2015-09-14 17:40:35 +03:00
|
|
|
if conditions.is_android(self):
|
2019-11-26 01:17:59 +03:00
|
|
|
from mozrunner.devices.android_device import (verify_android_device, InstallIntent)
|
|
|
|
verify_android_device(self, install=InstallIntent.NO)
|
2015-09-14 17:40:35 +03:00
|
|
|
return self.run_android_test(tests, symbols_path, manifest_path, log)
|
|
|
|
|
2019-05-03 22:00:46 +03:00
|
|
|
return self.run_desktop_test(tests, symbols_path, manifest_path,
|
|
|
|
utility_path, log)
|
2015-09-14 17:40:35 +03:00
|
|
|
|
2019-05-03 22:00:46 +03:00
|
|
|
def run_desktop_test(self, tests, symbols_path, manifest_path,
|
|
|
|
utility_path, log):
|
2015-09-14 17:40:35 +03:00
|
|
|
import runcppunittests as cppunittests
|
|
|
|
from mozlog import commandline
|
|
|
|
|
|
|
|
parser = cppunittests.CPPUnittestOptions()
|
|
|
|
commandline.add_logging_group(parser)
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
|
|
|
options.symbols_path = symbols_path
|
|
|
|
options.manifest_path = manifest_path
|
2019-05-03 22:00:46 +03:00
|
|
|
options.utility_path = utility_path
|
2015-09-14 17:40:35 +03:00
|
|
|
options.xre_path = self.bindir
|
|
|
|
|
|
|
|
try:
|
|
|
|
result = cppunittests.run_test_harness(options, tests)
|
|
|
|
except Exception as e:
|
|
|
|
log.error("Caught exception running cpp unit tests: %s" % str(e))
|
|
|
|
result = False
|
|
|
|
raise
|
|
|
|
|
|
|
|
return 0 if result else 1
|
|
|
|
|
|
|
|
def run_android_test(self, tests, symbols_path, manifest_path, log):
|
|
|
|
import remotecppunittests as remotecppunittests
|
|
|
|
from mozlog import commandline
|
|
|
|
|
|
|
|
parser = remotecppunittests.RemoteCPPUnittestOptions()
|
|
|
|
commandline.add_logging_group(parser)
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
2017-10-25 00:17:25 +03:00
|
|
|
if not options.adb_path:
|
|
|
|
from mozrunner.devices.android_device import get_adb_path
|
|
|
|
options.adb_path = get_adb_path(self)
|
2015-09-14 17:40:35 +03:00
|
|
|
options.symbols_path = symbols_path
|
|
|
|
options.manifest_path = manifest_path
|
|
|
|
options.xre_path = self.bindir
|
|
|
|
options.local_lib = self.bindir.replace('bin', 'fennec')
|
|
|
|
for file in os.listdir(os.path.join(self.topobjdir, "dist")):
|
|
|
|
if file.endswith(".apk") and file.startswith("fennec"):
|
|
|
|
options.local_apk = os.path.join(self.topobjdir, "dist", file)
|
|
|
|
log.info("using APK: " + options.local_apk)
|
|
|
|
break
|
|
|
|
|
2014-01-02 19:19:35 +04:00
|
|
|
try:
|
2015-09-14 17:40:35 +03:00
|
|
|
result = remotecppunittests.run_test_harness(options, tests)
|
2014-07-10 17:33:39 +04:00
|
|
|
except Exception as e:
|
|
|
|
log.error("Caught exception running cpp unit tests: %s" % str(e))
|
2014-01-02 19:19:35 +04:00
|
|
|
result = False
|
2015-09-14 17:40:35 +03:00
|
|
|
raise
|
2014-01-02 19:19:35 +04:00
|
|
|
|
|
|
|
return 0 if result else 1
|
2014-03-27 18:16:14 +04:00
|
|
|
|
2017-08-17 22:50:39 +03:00
|
|
|
|
2015-05-16 01:41:50 +03:00
|
|
|
def executable_name(name):
|
|
|
|
return name + '.exe' if sys.platform.startswith('win') else name
|
|
|
|
|
2017-08-17 22:50:39 +03:00
|
|
|
|
2014-03-27 18:16:14 +04:00
|
|
|
@CommandProvider
|
2019-11-05 19:24:54 +03:00
|
|
|
class SpiderMonkeyTests(MachCommandBase):
|
2018-07-05 15:42:52 +03:00
|
|
|
@Command('jstests', category='testing',
|
2019-11-06 21:53:07 +03:00
|
|
|
description='Run SpiderMonkey JS tests in the JS shell.')
|
2018-07-05 15:42:52 +03:00
|
|
|
@CommandArgument('--shell', help='The shell to be used')
|
|
|
|
@CommandArgument('params', nargs=argparse.REMAINDER,
|
|
|
|
help="Extra arguments to pass down to the test harness.")
|
|
|
|
def run_jstests(self, shell, params):
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
self.virtualenv_manager.ensure()
|
|
|
|
python = self.virtualenv_manager.python_path
|
|
|
|
|
|
|
|
js = shell or os.path.join(self.bindir, executable_name('js'))
|
|
|
|
jstest_cmd = [
|
|
|
|
python,
|
|
|
|
os.path.join(self.topsrcdir, 'js', 'src', 'tests', 'jstests.py'),
|
|
|
|
js,
|
|
|
|
] + params
|
2019-11-06 21:53:07 +03:00
|
|
|
|
2018-07-05 15:42:52 +03:00
|
|
|
return subprocess.call(jstest_cmd)
|
|
|
|
|
2019-11-04 22:46:43 +03:00
|
|
|
@Command('jit-test', category='testing',
|
2019-11-06 21:53:07 +03:00
|
|
|
description='Run SpiderMonkey jit-tests in the JS shell.')
|
2019-11-04 22:46:43 +03:00
|
|
|
@CommandArgument('--shell', help='The shell to be used')
|
|
|
|
@CommandArgument('params', nargs=argparse.REMAINDER,
|
|
|
|
help="Extra arguments to pass down to the test harness.")
|
|
|
|
def run_jittests(self, shell, params):
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
self.virtualenv_manager.ensure()
|
|
|
|
python = self.virtualenv_manager.python_path
|
|
|
|
|
|
|
|
js = shell or os.path.join(self.bindir, executable_name('js'))
|
|
|
|
jittest_cmd = [
|
|
|
|
python,
|
2019-11-06 21:53:07 +03:00
|
|
|
os.path.join(self.topsrcdir, 'js', 'src', 'jit-test', 'jit_test.py'),
|
2019-11-04 22:46:43 +03:00
|
|
|
js,
|
|
|
|
] + params
|
|
|
|
|
|
|
|
return subprocess.call(jittest_cmd)
|
|
|
|
|
2019-11-05 19:24:54 +03:00
|
|
|
@Command('jsapi-tests', category='testing',
|
2019-11-06 21:53:07 +03:00
|
|
|
description='Run SpiderMonkey JSAPI tests.')
|
2019-11-05 19:24:54 +03:00
|
|
|
@CommandArgument('test_name', nargs='?', metavar='N',
|
|
|
|
help='Test to run. Can be a prefix or omitted. If '
|
|
|
|
'omitted, the entire test suite is executed.')
|
2019-11-06 21:53:07 +03:00
|
|
|
def run_jsapitests(self, test_name=None):
|
2019-11-05 19:24:54 +03:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
jsapi_tests_cmd = [
|
|
|
|
os.path.join(self.bindir, executable_name('jsapi-tests'))
|
|
|
|
]
|
2019-11-06 21:53:07 +03:00
|
|
|
if test_name:
|
|
|
|
jsapi_tests_cmd.append(test_name)
|
2019-11-05 19:24:54 +03:00
|
|
|
|
2020-04-27 14:37:13 +03:00
|
|
|
test_env = os.environ.copy()
|
|
|
|
test_env["TOPSRCDIR"] = self.topsrcdir
|
|
|
|
|
|
|
|
return subprocess.call(jsapi_tests_cmd, env=test_env)
|
2019-11-05 19:24:54 +03:00
|
|
|
|
2019-11-06 21:53:07 +03:00
|
|
|
def run_check_js_msg(self):
|
2014-03-27 18:16:14 +04:00
|
|
|
import subprocess
|
2017-07-27 04:02:51 +03:00
|
|
|
|
|
|
|
self.virtualenv_manager.ensure()
|
|
|
|
python = self.virtualenv_manager.python_path
|
2014-03-27 18:16:14 +04:00
|
|
|
|
2019-11-06 21:53:07 +03:00
|
|
|
check_cmd = [
|
|
|
|
python,
|
|
|
|
os.path.join(self.topsrcdir, 'config', 'check_js_msg_encoding.py')
|
|
|
|
]
|
2014-04-29 18:22:50 +04:00
|
|
|
|
2019-11-06 21:53:07 +03:00
|
|
|
return subprocess.call(check_cmd)
|
|
|
|
|
|
|
|
@Command('check-spidermonkey', category='testing',
|
|
|
|
description='Run SpiderMonkey tests (JavaScript engine).')
|
|
|
|
@CommandArgument('--valgrind', action='store_true',
|
|
|
|
help='Run jit-test suite with valgrind flag')
|
|
|
|
def run_checkspidermonkey(self, valgrind=False):
|
2014-04-29 18:22:50 +04:00
|
|
|
print('Running jit-tests')
|
2019-11-04 22:46:43 +03:00
|
|
|
jittest_args = [
|
2017-07-27 04:02:51 +03:00
|
|
|
'--no-slow',
|
|
|
|
'--jitflags=all',
|
|
|
|
]
|
2019-11-06 21:53:07 +03:00
|
|
|
if valgrind:
|
2019-11-04 22:46:43 +03:00
|
|
|
jittest_args.append('--valgrind')
|
2019-11-06 21:53:07 +03:00
|
|
|
jittest_result = self.run_jittests(shell=None, params=jittest_args)
|
2014-04-29 18:22:50 +04:00
|
|
|
|
|
|
|
print('running jstests')
|
2019-11-06 21:53:07 +03:00
|
|
|
jstest_result = self.run_jstests(shell=None, params=[])
|
2014-04-29 18:22:50 +04:00
|
|
|
|
|
|
|
print('running jsapi-tests')
|
2019-11-05 19:24:54 +03:00
|
|
|
jsapi_tests_result = self.run_jsapitests(test_name=None)
|
2014-04-29 18:22:50 +04:00
|
|
|
|
2016-09-28 08:12:54 +03:00
|
|
|
print('running check-js-msg-encoding')
|
2019-11-06 21:53:07 +03:00
|
|
|
check_js_msg_result = self.run_check_js_msg()
|
2014-03-27 18:16:14 +04:00
|
|
|
|
2019-11-06 21:53:07 +03:00
|
|
|
return jittest_result and jstest_result and jsapi_tests_result and check_js_msg_result
|
2015-05-16 01:41:50 +03:00
|
|
|
|
2017-08-17 22:50:39 +03:00
|
|
|
|
2018-05-15 21:41:16 +03:00
|
|
|
def get_jsshell_parser():
|
|
|
|
from jsshell.benchmark import get_parser
|
|
|
|
return get_parser()
|
|
|
|
|
|
|
|
|
|
|
|
@CommandProvider
|
|
|
|
class JsShellTests(MachCommandBase):
|
|
|
|
@Command('jsshell-bench', category='testing',
|
|
|
|
parser=get_jsshell_parser,
|
|
|
|
description="Run benchmarks in the SpiderMonkey JS shell.")
|
|
|
|
def run_jsshelltests(self, **kwargs):
|
2020-07-28 19:06:10 +03:00
|
|
|
self.activate_virtualenv()
|
2018-05-15 21:41:16 +03:00
|
|
|
from jsshell import benchmark
|
|
|
|
return benchmark.run(**kwargs)
|
|
|
|
|
|
|
|
|
2017-01-20 19:15:25 +03:00
|
|
|
@CommandProvider
|
|
|
|
class CramTest(MachCommandBase):
|
|
|
|
@Command('cramtest', category='testing',
|
|
|
|
description="Mercurial style .t tests for command line applications.")
|
|
|
|
@CommandArgument('test_paths', nargs='*', metavar='N',
|
|
|
|
help="Test paths to run. Each path can be a test file or directory. "
|
|
|
|
"If omitted, the entire suite will be run.")
|
|
|
|
@CommandArgument('cram_args', nargs=argparse.REMAINDER,
|
|
|
|
help="Extra arguments to pass down to the cram binary. See "
|
|
|
|
"'./mach python -m cram -- -h' for a list of available options.")
|
|
|
|
def cramtest(self, cram_args=None, test_paths=None, test_objects=None):
|
2020-07-28 19:06:10 +03:00
|
|
|
self.activate_virtualenv()
|
2017-01-20 19:15:25 +03:00
|
|
|
import mozinfo
|
|
|
|
from manifestparser import TestManifest
|
|
|
|
|
|
|
|
if test_objects is None:
|
2017-11-06 16:41:42 +03:00
|
|
|
from moztest.resolve import TestResolver
|
2017-01-20 19:15:25 +03:00
|
|
|
resolver = self._spawn(TestResolver)
|
|
|
|
if test_paths:
|
|
|
|
# If we were given test paths, try to find tests matching them.
|
|
|
|
test_objects = resolver.resolve_tests(paths=test_paths, flavor='cram')
|
|
|
|
else:
|
|
|
|
# Otherwise just run everything in CRAMTEST_MANIFESTS
|
|
|
|
test_objects = resolver.resolve_tests(flavor='cram')
|
|
|
|
|
|
|
|
if not test_objects:
|
|
|
|
message = 'No tests were collected, check spelling of the test paths.'
|
|
|
|
self.log(logging.WARN, 'cramtest', {}, message)
|
|
|
|
return 1
|
|
|
|
|
|
|
|
mp = TestManifest()
|
|
|
|
mp.tests.extend(test_objects)
|
|
|
|
tests = mp.active_tests(disabled=False, **mozinfo.info)
|
|
|
|
|
|
|
|
python = self.virtualenv_manager.python_path
|
|
|
|
cmd = [python, '-m', 'cram'] + cram_args + [t['relpath'] for t in tests]
|
|
|
|
return subprocess.call(cmd, cwd=self.topsrcdir)
|
|
|
|
|
|
|
|
|
2017-02-07 19:42:29 +03:00
|
|
|
@CommandProvider
|
|
|
|
class TestInfoCommand(MachCommandBase):
|
|
|
|
from datetime import date, timedelta
|
2017-08-17 22:50:39 +03:00
|
|
|
|
2017-02-07 19:42:29 +03:00
|
|
|
@Command('test-info', category='testing',
|
2019-10-03 23:39:28 +03:00
|
|
|
description='Display historical test results.')
|
|
|
|
def test_info(self):
|
|
|
|
"""
|
|
|
|
All functions implemented as subcommands.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@SubCommand('test-info', 'tests',
|
2019-10-04 00:03:33 +03:00
|
|
|
description='Display historical test result summary for named tests.')
|
2017-05-17 19:30:34 +03:00
|
|
|
@CommandArgument('test_names', nargs=argparse.REMAINDER,
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Test(s) of interest.')
|
2017-02-07 19:42:29 +03:00
|
|
|
@CommandArgument('--branches',
|
2019-12-03 21:56:25 +03:00
|
|
|
default='mozilla-central,autoland',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Report for named branches '
|
2019-12-03 21:56:25 +03:00
|
|
|
'(default: mozilla-central,autoland)')
|
2017-02-07 19:42:29 +03:00
|
|
|
@CommandArgument('--start',
|
2017-08-17 22:50:39 +03:00
|
|
|
default=(date.today() - timedelta(7)
|
|
|
|
).strftime("%Y-%m-%d"),
|
|
|
|
help='Start date (YYYY-MM-DD)')
|
2017-02-07 19:42:29 +03:00
|
|
|
@CommandArgument('--end',
|
2017-08-17 22:50:39 +03:00
|
|
|
default=date.today().strftime("%Y-%m-%d"),
|
|
|
|
help='End date (YYYY-MM-DD)')
|
2017-05-17 19:30:37 +03:00
|
|
|
@CommandArgument('--show-info', action='store_true',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Retrieve and display general test information.')
|
2017-05-17 19:30:37 +03:00
|
|
|
@CommandArgument('--show-results', action='store_true',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Retrieve and display ActiveData test result summary.')
|
2017-05-17 19:30:37 +03:00
|
|
|
@CommandArgument('--show-durations', action='store_true',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Retrieve and display ActiveData test duration summary.')
|
2018-07-17 21:54:19 +03:00
|
|
|
@CommandArgument('--show-tasks', action='store_true',
|
|
|
|
help='Retrieve and display ActiveData test task names.')
|
2017-05-17 19:30:37 +03:00
|
|
|
@CommandArgument('--show-bugs', action='store_true',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Retrieve and display related Bugzilla bugs.')
|
2017-03-09 02:01:44 +03:00
|
|
|
@CommandArgument('--verbose', action='store_true',
|
2017-08-17 22:50:39 +03:00
|
|
|
help='Enable debug logging.')
|
2019-12-06 16:27:54 +03:00
|
|
|
def test_info_tests(self, test_names, branches, start, end,
|
|
|
|
show_info, show_results, show_durations, show_tasks, show_bugs,
|
|
|
|
verbose):
|
|
|
|
import testinfo
|
|
|
|
|
|
|
|
ti = testinfo.TestInfoTests(verbose)
|
|
|
|
ti.report(test_names, branches, start, end,
|
|
|
|
show_info, show_results, show_durations, show_tasks, show_bugs)
|
2018-08-07 19:05:37 +03:00
|
|
|
|
|
|
|
@SubCommand('test-info', 'long-tasks',
|
|
|
|
description='Find tasks approaching their taskcluster max-run-time.')
|
|
|
|
@CommandArgument('--branches',
|
2019-12-03 21:56:25 +03:00
|
|
|
default='mozilla-central,autoland',
|
2018-08-07 19:05:37 +03:00
|
|
|
help='Report for named branches '
|
2019-12-03 21:56:25 +03:00
|
|
|
'(default: mozilla-central,autoland)')
|
2018-08-07 19:05:37 +03:00
|
|
|
@CommandArgument('--start',
|
|
|
|
default=(date.today() - timedelta(7)
|
|
|
|
).strftime("%Y-%m-%d"),
|
|
|
|
help='Start date (YYYY-MM-DD)')
|
|
|
|
@CommandArgument('--end',
|
|
|
|
default=date.today().strftime("%Y-%m-%d"),
|
|
|
|
help='End date (YYYY-MM-DD)')
|
|
|
|
@CommandArgument('--max-threshold-pct',
|
|
|
|
default=90.0,
|
|
|
|
help='Count tasks exceeding this percentage of max-run-time.')
|
|
|
|
@CommandArgument('--filter-threshold-pct',
|
|
|
|
default=0.5,
|
|
|
|
help='Report tasks exceeding this percentage of long tasks.')
|
|
|
|
@CommandArgument('--verbose', action='store_true',
|
|
|
|
help='Enable debug logging.')
|
2019-12-06 16:27:54 +03:00
|
|
|
def report_long_running_tasks(self, branches, start, end,
|
|
|
|
max_threshold_pct, filter_threshold_pct, verbose):
|
|
|
|
import testinfo
|
|
|
|
|
|
|
|
max_threshold_pct = float(max_threshold_pct)
|
|
|
|
filter_threshold_pct = float(filter_threshold_pct)
|
|
|
|
|
|
|
|
ti = testinfo.TestInfoLongRunningTasks(verbose)
|
|
|
|
ti.report(branches, start, end, max_threshold_pct, filter_threshold_pct)
|
2018-11-10 18:00:28 +03:00
|
|
|
|
2019-07-31 12:21:59 +03:00
|
|
|
@SubCommand('test-info', 'report',
|
|
|
|
description='Generate a json report of test manifests and/or tests '
|
|
|
|
'categorized by Bugzilla component and optionally filtered '
|
|
|
|
'by path, component, and/or manifest annotations.')
|
|
|
|
@CommandArgument('--components', default=None,
|
|
|
|
help='Comma-separated list of Bugzilla components.'
|
|
|
|
' eg. Testing::General,Core::WebVR')
|
2019-08-09 20:31:56 +03:00
|
|
|
@CommandArgument('--flavor',
|
|
|
|
help='Limit results to tests of the specified flavor (eg. "xpcshell").')
|
|
|
|
@CommandArgument('--subsuite',
|
|
|
|
help='Limit results to tests of the specified subsuite (eg. "devtools").')
|
2019-07-31 12:21:59 +03:00
|
|
|
@CommandArgument('paths', nargs=argparse.REMAINDER,
|
|
|
|
help='File system paths of interest.')
|
|
|
|
@CommandArgument('--show-manifests', action='store_true',
|
|
|
|
help='Include test manifests in report.')
|
|
|
|
@CommandArgument('--show-tests', action='store_true',
|
|
|
|
help='Include individual tests in report.')
|
2019-08-20 19:19:40 +03:00
|
|
|
@CommandArgument('--show-summary', action='store_true',
|
|
|
|
help='Include summary in report.')
|
2019-11-14 22:11:07 +03:00
|
|
|
@CommandArgument('--show-annotations', action='store_true',
|
|
|
|
help='Include list of manifest annotation conditions in report.')
|
2019-12-03 21:56:25 +03:00
|
|
|
@CommandArgument('--show-activedata', action='store_true',
|
|
|
|
help='Include additional data from ActiveData, like run times and counts.')
|
2019-07-31 12:21:59 +03:00
|
|
|
@CommandArgument('--filter-values',
|
2019-08-20 19:19:40 +03:00
|
|
|
help='Comma-separated list of value regular expressions to filter on; '
|
2019-07-31 12:21:59 +03:00
|
|
|
'displayed tests contain all specified values.')
|
|
|
|
@CommandArgument('--filter-keys',
|
|
|
|
help='Comma-separated list of test keys to filter on, '
|
|
|
|
'like "skip-if"; only these fields will be searched '
|
|
|
|
'for filter-values.')
|
2019-08-11 00:52:39 +03:00
|
|
|
@CommandArgument('--no-component-report', action='store_false',
|
|
|
|
dest="show_components", default=True,
|
|
|
|
help='Do not categorize by bugzilla component.')
|
2019-07-31 12:21:59 +03:00
|
|
|
@CommandArgument('--output-file',
|
|
|
|
help='Path to report file.')
|
2019-12-03 21:56:25 +03:00
|
|
|
@CommandArgument('--branches',
|
|
|
|
default='mozilla-central,autoland',
|
|
|
|
help='Query ActiveData for named branches '
|
|
|
|
'(default: mozilla-central,autoland)')
|
|
|
|
@CommandArgument('--days',
|
|
|
|
type=int,
|
|
|
|
default=7,
|
|
|
|
help='Query ActiveData for specified number of days')
|
2019-12-06 16:27:54 +03:00
|
|
|
@CommandArgument('--verbose', action='store_true',
|
|
|
|
help='Enable debug logging.')
|
2019-08-09 20:31:56 +03:00
|
|
|
def test_report(self, components, flavor, subsuite, paths,
|
2019-11-14 22:11:07 +03:00
|
|
|
show_manifests, show_tests, show_summary, show_annotations,
|
2019-12-03 21:56:25 +03:00
|
|
|
show_activedata,
|
|
|
|
filter_values, filter_keys, show_components, output_file,
|
2019-12-06 16:27:54 +03:00
|
|
|
branches, days, verbose):
|
|
|
|
import testinfo
|
2019-09-19 01:04:39 +03:00
|
|
|
from mozbuild.build_commands import Build
|
2019-07-31 12:21:59 +03:00
|
|
|
|
2019-09-19 01:04:39 +03:00
|
|
|
try:
|
|
|
|
self.config_environment
|
|
|
|
except BuildEnvironmentNotFoundException:
|
|
|
|
print("Looks like configure has not run yet, running it now...")
|
|
|
|
builder = Build(self._mach_context)
|
|
|
|
builder.configure()
|
|
|
|
|
2019-12-06 16:27:54 +03:00
|
|
|
ti = testinfo.TestInfoReport(verbose)
|
|
|
|
ti.report(components, flavor, subsuite, paths,
|
|
|
|
show_manifests, show_tests, show_summary, show_annotations,
|
|
|
|
show_activedata,
|
|
|
|
filter_values, filter_keys, show_components, output_file,
|
|
|
|
branches, days)
|
2019-12-03 21:56:25 +03:00
|
|
|
|
2020-03-04 11:09:13 +03:00
|
|
|
@SubCommand('test-info', 'report-diff',
|
|
|
|
description='Compare two reports generated by "test-info reports".')
|
|
|
|
@CommandArgument('--before', default=None,
|
|
|
|
help='The first (earlier) report file; path to local file or url.')
|
|
|
|
@CommandArgument('--after',
|
|
|
|
help='The second (later) report file; path to local file or url.')
|
|
|
|
@CommandArgument('--output-file',
|
|
|
|
help='Path to report file to be written. If not specified, report'
|
|
|
|
'will be written to standard output.')
|
|
|
|
@CommandArgument('--verbose', action='store_true',
|
|
|
|
help='Enable debug logging.')
|
|
|
|
def test_report_diff(self, before, after, output_file, verbose):
|
|
|
|
import testinfo
|
|
|
|
ti = testinfo.TestInfoReport(verbose)
|
|
|
|
ti.report_diff(before, after, output_file)
|
|
|
|
|
2018-11-10 18:00:28 +03:00
|
|
|
|
|
|
|
@CommandProvider
|
|
|
|
class RustTests(MachCommandBase):
|
|
|
|
@Command('rusttests', category='testing',
|
2019-05-01 02:03:14 +03:00
|
|
|
conditions=[conditions.is_non_artifact_build],
|
2018-11-10 18:00:28 +03:00
|
|
|
description="Run rust unit tests (via cargo test).")
|
|
|
|
def run_rusttests(self, **kwargs):
|
|
|
|
return self._mach_context.commands.dispatch('build', self._mach_context,
|
|
|
|
what=['pre-export',
|
|
|
|
'export',
|
|
|
|
'recurse_rusttests'])
|
2019-08-08 14:54:30 +03:00
|
|
|
|
|
|
|
|
|
|
|
@CommandProvider
|
|
|
|
class TestFluentMigration(MachCommandBase):
|
|
|
|
@Command('fluent-migration-test', category='testing',
|
|
|
|
description="Test Fluent migration recipes.")
|
|
|
|
@CommandArgument('test_paths', nargs='*', metavar='N',
|
|
|
|
help="Recipe paths to test.")
|
|
|
|
def run_migration_tests(self, test_paths=None, **kwargs):
|
|
|
|
if not test_paths:
|
|
|
|
test_paths = []
|
2020-07-28 19:06:10 +03:00
|
|
|
self.activate_virtualenv()
|
2019-08-08 14:54:30 +03:00
|
|
|
from test_fluent_migrations import fmt
|
|
|
|
rv = 0
|
|
|
|
with_context = []
|
|
|
|
for to_test in test_paths:
|
|
|
|
try:
|
|
|
|
context = fmt.inspect_migration(to_test)
|
|
|
|
for issue in context['issues']:
|
|
|
|
self.log(logging.ERROR, 'fluent-migration-test', {
|
|
|
|
'error': issue['msg'],
|
|
|
|
'file': to_test,
|
|
|
|
}, 'ERROR in {file}: {error}')
|
|
|
|
if context['issues']:
|
|
|
|
continue
|
|
|
|
with_context.append({
|
|
|
|
'to_test': to_test,
|
|
|
|
'references': context['references'],
|
|
|
|
})
|
|
|
|
except Exception as e:
|
|
|
|
self.log(logging.ERROR, 'fluent-migration-test', {
|
|
|
|
'error': str(e),
|
|
|
|
'file': to_test
|
|
|
|
}, 'ERROR in {file}: {error}')
|
|
|
|
rv |= 1
|
|
|
|
obj_dir = fmt.prepare_object_dir(self)
|
|
|
|
for context in with_context:
|
|
|
|
rv |= fmt.test_migration(self, obj_dir, **context)
|
|
|
|
return rv
|