Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
# A body is read for these rather than trusted, because every reader below keys on one of them.
# A heading this script has no spelling for is a section it will not find, reported as absent.
# That is the shape of all three failures already on record here, each caught after it landed.
# The lists are small because the output is regular: 8 headings, 6 summaries and 3 labels.
# The lists are small because the output is regular: 9 headings, 6 summaries and 3 labels.
# Counts are normalized to `(N)` and non-ASCII is dropped before comparing.
# The verdict headings carry a colored circle, so the emoji is what would drift most cheaply.
# Dropping it also keeps this file inside the charset rule that governs the repository.
Expand All @@ -206,6 +206,7 @@
"### Approval recommended",
"### Ready to approve",
"### Changes recommended",
"### Needs a closer look",
"### Not ready to approve",
"### Human review recommended",
"### Suppressed comments (N)",
Expand Down
25 changes: 23 additions & 2 deletions scripts/tests/test_pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ def nested(
)


def closer_look() -> str:
"""The findings verdict with stable coverage and nested review details."""
return (
"### \U0001f535 Needs a closer look\n\nThe change needs attention.\n"
"<!-- fleet-review: reviewed=3 changed=3 findings=1 -->\n\n"
"<details>\n<summary>Review details</summary>\n\n"
"### Suppressed comments (1)\n\n**a.py:12**\n* Validate the input.\n\n"
"- **Files reviewed:** 3/3 changed files\n"
"- **Comments generated:** 0 new\n"
"- **Review effort level:** Lite\n</details>\n"
)


def summarized(paths: list[str], covers: str = COVERED) -> str:
"""A round carrying its coverage line and the file table naming `paths`.

Expand Down Expand Up @@ -1017,7 +1030,7 @@ class TestUnrecognizedShapes(GqlCase):
coverage line nothing parsed. Each was caught after it had already reported a clean pass.

The inventory is measured rather than imagined. Over the same 333 review bodies, with fenced
blocks removed and text reduced to ASCII, the whole corpus is 8 headings, 6 summaries and 3
blocks removed and text reduced to ASCII, the whole corpus is 9 headings, 6 summaries and 3
metadata labels, and every body carries at least one of them.
"""

Expand All @@ -1043,6 +1056,14 @@ def test_approval_recommended_heading_is_vetted(self) -> None:
body = "### \U0001f7e2 Approval recommended\n\nDocumentation updates are consistent.\n"
self.assertEqual([], pr_review.unrecognized_in(body))

def test_needs_a_closer_look_heading_is_vetted(self) -> None:
"""The findings verdict stays readable with its marker and nested details."""
body = closer_look()
self.assertEqual([], pr_review.unrecognized_in(body))
out = self.digest_for(review(body=body))
self.assertIn("coverage=full", out)
self.assertIn("shapes=ok", out)

def test_a_details_summary_that_is_not_in_the_inventory_blocks(self) -> None:
"""The suppressed section has already moved between wrappers once."""
body = OVERVIEW + "\n<details>\n<summary>Withheld findings</summary>\n\nx\n</details>\n"
Expand Down Expand Up @@ -1219,7 +1240,7 @@ def test_status_exits_forty_three_on_a_wording_it_does_not_read(self) -> None:
def test_status_still_exits_zero_on_a_full_round(self) -> None:
"""Both the legacy coverage prose and the stable marker close the coverage gate."""
marker = OVERVIEW + "\n<!-- fleet-review: reviewed=1 changed=1 findings=0 -->"
for body in (OVERVIEW + "\n" + COVERED, nested(), marker):
for body in (OVERVIEW + "\n" + COVERED, nested(), closer_look(), marker):
with self.subTest(body=body[:40]):
self.answer(payload([review(body=body)]))
self.assertEqual(0, pr_review.main(["status", "7", "--repo", "o/r"]))
Expand Down