Skip to content

Commit fb066c4

Browse files
committed
[sancov] fix coverage-report-server cannot display coverage detail
This patch make following change for coverage-report-server.py - using uri `./{name}` from root in the old version python http.server can be handled as `//{name}`. But due to python/cpython#93879, it will be handled as `/{name}` now. So I want to use a prefix to avoid double slashes issue. Differential Revision: https://reviews.llvm.org/D146010
1 parent e6cc0fa commit fb066c4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/tools/sancov/coverage-report-server.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
</html>
7272
"""
7373

74+
FILE_URI_PREFIX = "/file/"
75+
7476
class SymcovData:
7577
def __init__(self, symcov_json):
7678
self.covered_points = frozenset(symcov_json['covered-points'])
@@ -129,7 +131,7 @@ class ServerHandler(http.server.BaseHTTPRequestHandler):
129131
src_path = None
130132

131133
def do_GET(self):
132-
norm_path = os.path.normpath(urllib.parse.unquote(self.path[1:]))
134+
norm_path = os.path.normpath(urllib.parse.unquote(self.path[len(FILE_URI_PREFIX):]))
133135
if self.path == '/':
134136
self.send_response(200)
135137
self.send_header("Content-type", "text/html; charset=utf-8")
@@ -141,8 +143,9 @@ def do_GET(self):
141143
if not file_coverage:
142144
continue
143145
filelist.append(
144-
"<tr><td><a href=\"./{name}\">{name}</a></td>"
146+
"<tr><td><a href=\"{prefix}{name}\">{name}</a></td>"
145147
"<td>{coverage}%</td></tr>".format(
148+
prefix=FILE_URI_PREFIX,
146149
name=html.escape(filename, quote=True),
147150
coverage=format_pct(file_coverage)))
148151

0 commit comments

Comments
 (0)