Bug 1445624 - [test] Make sure verbose logging is enabled when running a single test, r=gbrown
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Mon, 19 Mar 2018 16:04:02 -0400
changeset 409487 a348763a5ee1eead73ff2f2701cb72f35b4a7782
parent 409486 61a14c8bcfcf095c16caf4564fdc7d879386e2ca
child 409488 2c6f444e76cee053ee27c3010d1c55d594e428e4
push id33689
push usernerli@mozilla.com
push dateThu, 22 Mar 2018 22:52:18 +0000
treeherdermozilla-central@6c82708c26ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1445624
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1445624 - [test] Make sure verbose logging is enabled when running a single test, r=gbrown This sets verbose=True (used by the mach formatter) and compact=False (used by tbplformatter) if only a single test is specified with either |mach test| or |mach mochitest|. This way all TEST_STATUS and log lines will be visible when developers are writing a new test. MozReview-Commit-ID: 2nuKs9DLnx0
testing/mach_commands.py
testing/mochitest/mach_commands.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -117,20 +117,23 @@ class Test(MachCommandBase):
         resolver = self._spawn(TestResolver)
         run_suites, run_tests = resolver.resolve_metadata(what)
 
         if not run_suites and not run_tests:
             print(UNKNOWN_TEST)
             return 1
 
         # Create shared logger
+        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
+
         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 = setup_logging('mach-test', log_args, {default_format: sys.stdout}, format_args)
         for handler in log.handlers:
             if isinstance(handler, StreamHandler):
                 handler.formatter.inner.summary_on_shutdown = True
 
         status = None
         for suite_name in run_suites:
             suite = TEST_SUITES[suite_name]
             kwargs = suite['kwargs']
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -295,37 +295,41 @@ class MachCommands(MachCommandBase):
                 if flavor in fobj['aliases']:
                     if buildapp not in fobj['enabled_apps']:
                         continue
                     flavors = [fname]
                     break
         else:
             flavors = [f for f, v in ALL_FLAVORS.iteritems() if buildapp in v['enabled_apps']]
 
-        if not kwargs.get('log'):
-            # Create shared logger
-            default_format = self._mach_context.settings['test']['format']
-            default_level = self._mach_context.settings['test']['level']
-            kwargs['log'] = setup_logging('mach-mochitest', kwargs, {default_format: sys.stdout},
-                                          {'level': default_level})
-            for handler in kwargs['log'].handlers:
-                if isinstance(handler, StreamHandler):
-                    handler.formatter.inner.summary_on_shutdown = True
-
         from mozbuild.controller.building import BuildDriver
         self._ensure_state_subdir_exists('.')
 
         test_paths = kwargs['test_paths']
         kwargs['test_paths'] = []
 
         mochitest = self._spawn(MochitestRunner)
         tests = []
         if resolve_tests:
             tests = mochitest.resolve_tests(test_paths, test_objects, cwd=self._mach_context.cwd)
 
+        if not kwargs.get('log'):
+            # Create shared logger
+            format_args = {'level': self._mach_context.settings['test']['level']}
+            if len(tests) == 1:
+                format_args['verbose'] = True
+                format_args['compact'] = False
+
+            default_format = self._mach_context.settings['test']['format']
+            kwargs['log'] = setup_logging('mach-mochitest', kwargs, {default_format: sys.stdout},
+                                          format_args)
+            for handler in kwargs['log'].handlers:
+                if isinstance(handler, StreamHandler):
+                    handler.formatter.inner.summary_on_shutdown = True
+
         driver = self._spawn(BuildDriver)
         driver.install_tests(tests)
 
         subsuite = kwargs.get('subsuite')
         if subsuite == 'default':
             kwargs['subsuite'] = None
 
         suites = defaultdict(list)