Bug 1572794 - Add --no-component-report option to 'mach test-info report'; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Sat, 10 Aug 2019 21:52:39 +0000
changeset 487359 1d84685d68ae393622d16b3b047ebb69cd1b9fd4
parent 487358 1f67a34dfe693ec3d903c66d1a99507d355de228
child 487360 451992f4d9aff84ffa8aecb86c96398f381eae1a
push id36417
push userrmaries@mozilla.com
push dateSun, 11 Aug 2019 09:56:40 +0000
treeherdermozilla-central@e8fe8b0af1a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1572794
milestone70.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 1572794 - Add --no-component-report option to 'mach test-info report'; r=jmaher Keep the existing report format by default, but provide an option to generate a report that is not broken down by component. Differential Revision: https://phabricator.services.mozilla.com/D41427
testing/mach_commands.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -1170,21 +1170,24 @@ class TestInfoCommand(MachCommandBase):
                      help='Include individual tests in report.')
     @CommandArgument('--filter-values',
                      help='Comma-separated list of values to filter on; '
                           '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.')
+    @CommandArgument('--no-component-report', action='store_false',
+                     dest="show_components", default=True,
+                     help='Do not categorize by bugzilla component.')
     @CommandArgument('--output-file',
                      help='Path to report file.')
     def test_report(self, components, flavor, subsuite, paths,
                     show_manifests, show_tests,
-                    filter_values, filter_keys, output_file):
+                    filter_values, filter_keys, show_components, output_file):
         import mozpack.path as mozpath
         from moztest.resolve import TestResolver
 
         def matches_filters(test):
             '''
                Return True if all of the requested filter_values are found in this test;
                if filter_keys are specified, restrict search to those test keys.
             '''
@@ -1234,20 +1237,21 @@ class TestInfoCommand(MachCommandBase):
                     bug_component = info.get('BUG_COMPONENT')
                     key = "{}::{}".format(bug_component.product, bug_component.component)
                     if (info_path == relpath) and ((not components) or (key in components)):
                         manifest_info = {
                             'manifest': relpath,
                             'tests': 0,
                             'skipped': 0
                         }
-                        if key in by_component['manifests']:
-                            by_component['manifests'][key].append(manifest_info)
+                        rkey = key if show_components else 'all'
+                        if rkey in by_component['manifests']:
+                            by_component['manifests'][rkey].append(manifest_info)
                         else:
-                            by_component['manifests'][key] = [manifest_info]
+                            by_component['manifests'][rkey] = [manifest_info]
                         break
                 if manifest_info:
                     for t in tests:
                         if t['manifest'] == manifest_path:
                             manifest_info['tests'] += 1
                             if t.get('skip-if'):
                                 manifest_info['skipped'] += 1
             for key in by_component['manifests']:
@@ -1264,20 +1268,21 @@ class TestInfoCommand(MachCommandBase):
                     bug_component = info.get('BUG_COMPONENT')
                     key = "{}::{}".format(bug_component.product, bug_component.component)
                     if (info_path == relpath) and ((not components) or (key in components)):
                         test_info = {'test': relpath}
                         for test_key in ['skip-if', 'fail-if']:
                             value = t.get(test_key)
                             if value:
                                 test_info[test_key] = value
-                        if key in by_component['tests']:
-                            by_component['tests'][key].append(test_info)
+                        rkey = key if show_components else 'all'
+                        if rkey in by_component['tests']:
+                            by_component['tests'][rkey].append(test_info)
                         else:
-                            by_component['tests'][key] = [test_info]
+                            by_component['tests'][rkey] = [test_info]
                         break
             for key in by_component['tests']:
                 by_component['tests'][key].sort()
 
         json_report = json.dumps(by_component, indent=2, sort_keys=True)
         if output_file:
             with open(output_file, 'w') as f:
                 f.write(json_report)