Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/tools/sancov/coverage-report-server.py
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
<body> | <body> | ||||
<pre> | <pre> | ||||
$content | $content | ||||
</pre> | </pre> | ||||
</body> | </body> | ||||
</html> | </html> | ||||
""" | """ | ||||
FILE_URI_PREFIX = "/file/" | |||||
class SymcovData: | class SymcovData: | ||||
def __init__(self, symcov_json): | def __init__(self, symcov_json): | ||||
self.covered_points = frozenset(symcov_json['covered-points']) | self.covered_points = frozenset(symcov_json['covered-points']) | ||||
self.point_symbol_info = symcov_json['point-symbol-info'] | self.point_symbol_info = symcov_json['point-symbol-info'] | ||||
self.file_coverage = self.compute_filecoverage() | self.file_coverage = self.compute_filecoverage() | ||||
def filenames(self): | def filenames(self): | ||||
return self.point_symbol_info.keys() | return self.point_symbol_info.keys() | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if zeroes: | ||||
zeroes = '<span class="lz">{0}</span>'.format(zeroes) | zeroes = '<span class="lz">{0}</span>'.format(zeroes) | ||||
return zeroes + pct_str | return zeroes + pct_str | ||||
class ServerHandler(http.server.BaseHTTPRequestHandler): | class ServerHandler(http.server.BaseHTTPRequestHandler): | ||||
symcov_data = None | symcov_data = None | ||||
src_path = None | src_path = None | ||||
def do_GET(self): | def do_GET(self): | ||||
norm_path = os.path.normpath(urllib.parse.unquote(self.path[1:])) | norm_path = os.path.normpath(urllib.parse.unquote(self.path[len(FILE_URI_PREFIX):])) | ||||
if self.path == '/': | if self.path == '/': | ||||
self.send_response(200) | self.send_response(200) | ||||
self.send_header("Content-type", "text/html; charset=utf-8") | self.send_header("Content-type", "text/html; charset=utf-8") | ||||
self.end_headers() | self.end_headers() | ||||
filelist = [] | filelist = [] | ||||
for filename in sorted(self.symcov_data.filenames()): | for filename in sorted(self.symcov_data.filenames()): | ||||
file_coverage = self.symcov_data.file_coverage[filename] | file_coverage = self.symcov_data.file_coverage[filename] | ||||
if not file_coverage: | if not file_coverage: | ||||
continue | continue | ||||
filelist.append( | filelist.append( | ||||
"<tr><td><a href=\"./{name}\">{name}</a></td>" | "<tr><td><a href=\"{prefix}{name}\">{name}</a></td>" | ||||
"<td>{coverage}%</td></tr>".format( | "<td>{coverage}%</td></tr>".format( | ||||
prefix=FILE_URI_PREFIX, | |||||
name=html.escape(filename, quote=True), | name=html.escape(filename, quote=True), | ||||
coverage=format_pct(file_coverage))) | coverage=format_pct(file_coverage))) | ||||
response = string.Template(INDEX_PAGE_TMPL).safe_substitute( | response = string.Template(INDEX_PAGE_TMPL).safe_substitute( | ||||
filenames='\n'.join(filelist)) | filenames='\n'.join(filelist)) | ||||
self.wfile.write(response.encode('UTF-8', 'replace')) | self.wfile.write(response.encode('UTF-8', 'replace')) | ||||
elif self.symcov_data.has_file(norm_path): | elif self.symcov_data.has_file(norm_path): | ||||
filename = norm_path | filename = norm_path | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |