Bug 1421799 - [test] Add mozlog logging arguments to |mach test| and |mach mochitest| r=gbrown
MozReview-Commit-ID: CaysVHzNTWo
This commit is contained in:
@@ -69,16 +69,24 @@ class TestConfig(object):
|
||||
]
|
||||
|
||||
|
||||
def get_test_parser():
|
||||
from mozlog.commandline import add_logging_group
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('what', default=None, nargs='*', help=TEST_HELP)
|
||||
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.")
|
||||
add_logging_group(parser)
|
||||
return parser
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class Test(MachCommandBase):
|
||||
@Command('test', category='testing',
|
||||
description='Run tests (detects the kind of test and runs it).')
|
||||
@CommandArgument('what', default=None, nargs='*', help=TEST_HELP)
|
||||
@CommandArgument('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.")
|
||||
def test(self, what, extra_args):
|
||||
description='Run tests (detects the kind of test and runs it).',
|
||||
parser=get_test_parser)
|
||||
def test(self, what, extra_args, **log_args):
|
||||
"""Run tests from names or paths.
|
||||
|
||||
mach test accepts arguments specifying which tests to run. Each argument
|
||||
@@ -102,9 +110,7 @@ class Test(MachCommandBase):
|
||||
you specify a directory with xpcshell and browser chrome mochitests,
|
||||
both harnesses will be invoked.
|
||||
"""
|
||||
from mozlog.commandline import log_formatters
|
||||
from mozlog.handlers import StreamHandler, LogLevelFilter
|
||||
from mozlog.structuredlog import StructuredLogger
|
||||
from mozlog.commandline import setup_logging
|
||||
from moztest.resolve import TestResolver, TEST_FLAVORS, TEST_SUITES
|
||||
|
||||
resolver = self._spawn(TestResolver)
|
||||
@@ -115,12 +121,11 @@ class Test(MachCommandBase):
|
||||
return 1
|
||||
|
||||
# Create shared logger
|
||||
formatter = log_formatters[self._mach_context.settings['test']['format']][0]()
|
||||
formatter.summary_on_shutdown = True
|
||||
|
||||
level = self._mach_context.settings['test']['level']
|
||||
log = StructuredLogger('mach-test')
|
||||
log.add_handler(StreamHandler(sys.stdout, LogLevelFilter(formatter, level)))
|
||||
default_format = self._mach_context.settings['test']['format']
|
||||
default_level = self._mach_context.settings['test']['level']
|
||||
log = setup_logging('mach-test', log_args, {default_format: sys.stdout},
|
||||
{'level': default_level})
|
||||
log.handlers[0].formatter.inner.summary_on_shutdown = True
|
||||
|
||||
status = None
|
||||
for suite_name in run_suites:
|
||||
|
||||
Reference in New Issue
Block a user