Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: tools/checkteamtags/owners_file_tags.py

Issue 2648883002: Add coverage statistic (Closed)
Patch Set: update Docstring Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/checkteamtags/extract_components_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/checkteamtags/owners_file_tags.py
diff --git a/tools/checkteamtags/owners_file_tags.py b/tools/checkteamtags/owners_file_tags.py
index fc8d1f57ebc5ecb8a8d315aa2f0819f75e34061f..d2e3fe968e17ec8822e9b41651aa163dd37bd169 100644
--- a/tools/checkteamtags/owners_file_tags.py
+++ b/tools/checkteamtags/owners_file_tags.py
@@ -39,11 +39,26 @@ def aggregate_components_from_owners(root):
root (str): the path to the src directory.
Returns:
- A pair (data, warnings) where data is a dict of the form
+ A tuple (data, warnings, errors, stats) where data is a dict of the form
{'component-to-team': {'Component1': 'team1@chr...', ...},
'dir-to-component': {'/path/to/1': 'Component1', ...}}
- and warnings is a list of strings.
+ , warnings is a list of strings, stats is a dict of form
+ {'OWNERS-count': total number of OWNERS files,
+ 'OWNERS-with-component-only-count': number of OWNERS have # COMPONENT,
+ 'OWNERS-with-team-and-component-count': number of
+ OWNERS have TEAM and COMPONENT,
+ 'OWNERS-count-by-depth': {directory depth: number of OWNERS},
+ 'OWNERS-with-component-only-count-by-depth': {directory depth: number
+ of OWNERS have COMPONENT at this depth},
+ 'OWNERS-with-team-and-component-count-by-depth':{directory depth: ...}}
"""
+ stats = {}
+ num_total = 0
+ num_with_component = 0
+ num_with_team_component = 0
+ num_total_by_depth = defaultdict(int)
+ num_with_component_by_depth = defaultdict(int)
+ num_with_team_component_by_depth = defaultdict(int)
warnings = []
component_to_team = defaultdict(set)
dir_to_component = {}
@@ -51,19 +66,34 @@ def aggregate_components_from_owners(root):
# Proofing against windows casing oddities.
owners_file_names = [f for f in files if f.upper() == 'OWNERS']
if owners_file_names:
+ file_depth = dirname[len(root) + len(os.path.sep):].count(os.path.sep)
+ num_total += 1
+ num_total_by_depth[file_depth] += 1
owners_full_path = os.path.join(dirname, owners_file_names[0])
owners_rel_path = os.path.relpath(owners_full_path, root)
team, component = parse(owners_full_path)
if component:
+ num_with_component += 1
+ num_with_component_by_depth[file_depth] += 1
dir_to_component[os.path.relpath(dirname, root)] = component
if team:
+ num_with_team_component += 1
+ num_with_team_component_by_depth[file_depth] += 1
component_to_team[component].add(team)
else:
warnings.append('%s has no COMPONENT tag' % owners_rel_path)
mappings = {'component-to-team': component_to_team,
'dir-to-component': dir_to_component}
errors = validate_one_team_per_component(mappings)
- return unwrap(mappings), warnings, errors
+ stats = {'OWNERS-count': num_total,
+ 'OWNERS-with-component-only-count': num_with_component,
+ 'OWNERS-with-team-and-component-count': num_with_team_component,
+ 'OWNERS-count-by-depth': num_total_by_depth,
+ 'OWNERS-with-component-only-count-by-depth':
+ num_with_component_by_depth,
+ 'OWNERS-with-team-and-component-count-by-depth':
+ num_with_team_component_by_depth}
+ return unwrap(mappings), warnings, errors, stats
def validate_one_team_per_component(m):
« no previous file with comments | « tools/checkteamtags/extract_components_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698