[llvm] fb066c4 - [sancov] fix coverage-report-server cannot display coverage detail
Congcong Cai via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 19 06:10:35 PDT 2023
Author: Congcong Cai
Date: 2023-03-19T21:09:48+08:00
New Revision: fb066c4622c8665612961cc74d2715ff32943272
URL: https://github.com/llvm/llvm-project/commit/fb066c4622c8665612961cc74d2715ff32943272
DIFF: https://github.com/llvm/llvm-project/commit/fb066c4622c8665612961cc74d2715ff32943272.diff
LOG: [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 https://github.com/python/cpython/pull/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
Added:
Modified:
llvm/tools/sancov/coverage-report-server.py
Removed:
################################################################################
diff --git a/llvm/tools/sancov/coverage-report-server.py b/llvm/tools/sancov/coverage-report-server.py
index 5ea978fae642a..4c666dbc111d8 100755
--- a/llvm/tools/sancov/coverage-report-server.py
+++ b/llvm/tools/sancov/coverage-report-server.py
@@ -71,6 +71,8 @@
</html>
"""
+FILE_URI_PREFIX = "/file/"
+
class SymcovData:
def __init__(self, symcov_json):
self.covered_points = frozenset(symcov_json['covered-points'])
@@ -129,7 +131,7 @@ class ServerHandler(http.server.BaseHTTPRequestHandler):
src_path = None
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 == '/':
self.send_response(200)
self.send_header("Content-type", "text/html; charset=utf-8")
@@ -141,8 +143,9 @@ def do_GET(self):
if not file_coverage:
continue
filelist.append(
- "<tr><td><a href=\"./{name}\">{name}</a></td>"
+ "<tr><td><a href=\"{prefix}{name}\">{name}</a></td>"
"<td>{coverage}%</td></tr>".format(
+ prefix=FILE_URI_PREFIX,
name=html.escape(filename, quote=True),
coverage=format_pct(file_coverage)))
More information about the llvm-commits
mailing list