mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1474531 - Replace iteritems with viewitems in lcov_rewriter.py. r=marco
MozReview-Commit-ID: FKEHK8dyQSC --HG-- extra : rebase_source : faf77a17fd7888f9a685c3fd692c2e8eff205afb
This commit is contained in:
parent
3e043423dd
commit
cd6fa5ad82
@ -11,6 +11,8 @@ try:
|
||||
except ImportError:
|
||||
import urllib.parse as urlparse
|
||||
|
||||
from six import viewitems
|
||||
|
||||
from mozpack.chrome.manifest import parse_manifest
|
||||
import mozpack.path as mozpath
|
||||
from manifest_handler import ChromeManifestHandler
|
||||
@ -42,13 +44,13 @@ class LcovRecord(object):
|
||||
self.test_name = other.test_name
|
||||
self.functions.update(other.functions)
|
||||
|
||||
for name, count in other.function_exec_counts.iteritems():
|
||||
for name, count in viewitems(other.function_exec_counts):
|
||||
self.function_exec_counts[name] = count + self.function_exec_counts.get(name, 0)
|
||||
|
||||
for key, taken in other.branches.iteritems():
|
||||
for key, taken in viewitems(other.branches):
|
||||
self.branches[key] = taken + self.branches.get(key, 0)
|
||||
|
||||
for line, (exec_count, checksum) in other.lines.iteritems():
|
||||
for line, (exec_count, checksum) in viewitems(other.lines):
|
||||
new_exec_count = exec_count
|
||||
if line in self.lines:
|
||||
old_exec_count, _ = self.lines[line]
|
||||
@ -62,7 +64,7 @@ class LcovRecord(object):
|
||||
# Re-calculate summaries after generating or splitting a record.
|
||||
self.function_count = len(self.functions.keys())
|
||||
# Function records may have moved between files, so filter here.
|
||||
self.function_exec_counts = {fn_name: count for fn_name, count in self.function_exec_counts.iteritems()
|
||||
self.function_exec_counts = {fn_name: count for fn_name, count in viewitems(self.function_exec_counts)
|
||||
if fn_name in self.functions.values()}
|
||||
self.covered_function_count = len([c for c in self.function_exec_counts.values() if c])
|
||||
self.line_count = len(self.lines)
|
||||
@ -101,7 +103,7 @@ class RecordRewriter(object):
|
||||
|
||||
def _rewrite_lines(self, record):
|
||||
rewritten_lines = {}
|
||||
for ln, line_info in record.lines.iteritems():
|
||||
for ln, line_info in viewitems(record.lines):
|
||||
r = self._get_range(ln)
|
||||
if r is None:
|
||||
rewritten_lines[ln] = line_info
|
||||
@ -126,7 +128,7 @@ class RecordRewriter(object):
|
||||
# instance). It's not clear the records that result are well-formed, but
|
||||
# we act as though if a function has multiple FN's, the corresponding
|
||||
# FNDA's are all the same.
|
||||
for ln, fn_name in record.functions.iteritems():
|
||||
for ln, fn_name in viewitems(record.functions):
|
||||
r = self._get_range(ln)
|
||||
if r is None:
|
||||
rewritten_fns[ln] = fn_name
|
||||
@ -144,7 +146,7 @@ class RecordRewriter(object):
|
||||
|
||||
def _rewrite_branches(self, record):
|
||||
rewritten_branches = {}
|
||||
for (ln, block_number, branch_number), taken in record.branches.iteritems():
|
||||
for (ln, block_number, branch_number), taken in viewitems(record.branches):
|
||||
r = self._get_range(ln)
|
||||
if r is None:
|
||||
rewritten_branches[ln, block_number, branch_number] = taken
|
||||
@ -314,13 +316,13 @@ class LcovFile(object):
|
||||
# Sorting results gives deterministic output (and is a lot faster than
|
||||
# using OrderedDict).
|
||||
fns = []
|
||||
for start_lineno, fn_name in sorted(record.functions.iteritems()):
|
||||
for start_lineno, fn_name in sorted(viewitems(record.functions)):
|
||||
fns.append('FN:%s,%s' % (start_lineno, fn_name))
|
||||
return '\n'.join(fns)
|
||||
|
||||
def format_function_exec_counts(self, record):
|
||||
fndas = []
|
||||
for name, exec_count in sorted(record.function_exec_counts.iteritems()):
|
||||
for name, exec_count in sorted(viewitems(record.function_exec_counts)):
|
||||
fndas.append('FNDA:%s,%s' % (exec_count, name))
|
||||
return '\n'.join(fndas)
|
||||
|
||||
@ -347,7 +349,7 @@ class LcovFile(object):
|
||||
|
||||
def format_lines(self, record):
|
||||
das = []
|
||||
for line_no, (exec_count, checksum) in sorted(record.lines.iteritems()):
|
||||
for line_no, (exec_count, checksum) in sorted(viewitems(record.lines)):
|
||||
s = 'DA:%s,%s' % (line_no, exec_count)
|
||||
if checksum:
|
||||
s += ',%s' % checksum
|
||||
@ -516,7 +518,7 @@ class UrlFinder(object):
|
||||
source_path, pp_info = self._abs_objdir_install_info(term)
|
||||
return source_path, pp_info
|
||||
|
||||
for prefix, dests in self._url_prefixes.iteritems():
|
||||
for prefix, dests in viewitems(self._url_prefixes):
|
||||
if term.startswith(prefix):
|
||||
for dest in dests:
|
||||
if not dest.endswith('/'):
|
||||
|
Loading…
Reference in New Issue
Block a user