Skip to content

Commit

Permalink
Link test in summary
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman committed May 23, 2024
1 parent 368f004 commit 80e1856
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions post/clang_tidy_review/clang_tidy_review/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,14 +852,15 @@ def make_timing_summary(clang_tidy_profiling: Dict) -> str:
if check in [wall_key, user_key, sys_key]:
continue
base_check, time_type = check.rsplit(".", 1)
t = check_timings.get(base_check, (0.0, 0.0, 0.0))
check_name = check.split(".", 2)[2]
t = check_timings.get(check_name, (0.0, 0.0, 0.0))
if time_type == "user":
t = t[0] + timing, t[1], t[2]
elif time_type == "sys":
t = t[0], t[1] + timing, t[2]
elif time_type == "wall":
t = t[0], t[1], t[2] + timing
check_timings[base_check] = t
check_timings[check_name] = t

check_summary = ""
if check_timings:
Expand All @@ -875,7 +876,7 @@ def make_timing_summary(clang_tidy_profiling: Dict) -> str:
reverse=True,
)
for c, u, s, w in list(topchecks)[:top_amount]:
check_summary += f"|{c}|{u:.2f}|{s:.2f}|{w:.2f}|\n"
check_summary += f"|{decorate_check_names(c)}|{u:.2f}|{s:.2f}|{w:.2f}|\n"

return f"## Timing\n{file_summary}{check_summary}"

Expand Down Expand Up @@ -1194,7 +1195,7 @@ def set_summary(val: str) -> bool:
return True


def decorate_comment_body(comment: str) -> str:
def decorate_check_names(comment: str) -> str:
"""
Split on first dash into two groups of string in [] at end of line
exception: if the first group starts with 'clang' such as 'clang-diagnostic-error'
Expand All @@ -1208,7 +1209,7 @@ def decorate_comment_body(comment: str) -> str:


def decorate_comment(comment: PRReviewComment) -> PRReviewComment:
comment["body"] = decorate_comment_body(comment["body"])
comment["body"] = decorate_check_names(comment["body"])
return comment


Expand Down
12 changes: 6 additions & 6 deletions tests/test_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,20 +434,20 @@ def test_decorate_comment_body():
error_message = (
"warning: no member named 'ranges' in namespace 'std' [clang-diagnostic-error]"
)
assert ctr.decorate_comment_body(error_message) == error_message
assert ctr.decorate_check_names(error_message) == error_message

todo_message = "warning: missing username/bug in TODO [google-readability-todo]"
todo_message_decorated = "warning: missing username/bug in TODO [[google-readability-todo](https://clang.llvm.org/extra/clang-tidy/checks/google/readability-todo.html)]"
assert ctr.decorate_comment_body(todo_message) == todo_message_decorated
assert ctr.decorate_check_names(todo_message) == todo_message_decorated

naming_message = "warning: invalid case style for constexpr variable 'foo' [readability-identifier-naming]"
naming_message_decorated = "warning: invalid case style for constexpr variable 'foo' [[readability-identifier-naming](https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html)]"
assert ctr.decorate_comment_body(naming_message) == naming_message_decorated
assert ctr.decorate_check_names(naming_message) == naming_message_decorated

clang_analyzer_message = "warning: Array access (from variable 'foo') results in a null pointer dereference [clang-analyzer-core.NullDereference]"
clang_analyzer_message_decorated = "warning: Array access (from variable 'foo') results in a null pointer dereference [[clang-analyzer-core.NullDereference](https://clang.llvm.org/extra/clang-tidy/checks/clang-analyzer/core.NullDereference.html)]"
assert (
ctr.decorate_comment_body(clang_analyzer_message)
ctr.decorate_check_names(clang_analyzer_message)
== clang_analyzer_message_decorated
)

Expand All @@ -456,12 +456,12 @@ def test_decorate_comment_body():
# version_message_pre_15_version = "14.0.0"
# version_message_pre_15 = "warning: missing username/bug in TODO [google-readability-todo]"
# version_message_pre_15_decorated = "warning: missing username/bug in TODO [[google-readability-todo](https://releases.llvm.org/14.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/google-readability-todo.html)]"
# assert ctr.decorate_comment_body(version_message_pre_15, version_message_pre_15_version) == version_message_pre_15_decorated
# assert ctr.decorate_check_names(version_message_pre_15, version_message_pre_15_version) == version_message_pre_15_decorated
#
# version_message_1500_version = "15.0.0"
# version_message_1500 = "warning: missing username/bug in TODO [google-readability-todo]"
# version_message_1500_decorated = "warning: missing username/bug in TODO [[google-readability-todo](https://releases.llvm.org/15.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/google/readability-todo.html)]"
# assert ctr.decorate_comment_body(version_message_1500, version_message_1500_version) == version_message_1500_decorated
# assert ctr.decorate_check_names(version_message_1500, version_message_1500_version) == version_message_1500_decorated


def test_timing_summary(monkeypatch):
Expand Down

0 comments on commit 80e1856

Please sign in to comment.