From 4994da1dd080d3855ad8516c1ace87a780bb59de Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Fri, 6 Nov 2026 03:52:43 -0600 Subject: [PATCH 1/2] fix(mcpx): validate quarantine notices in test reports --- pkgs/mcpx/scripts/gotest-report.py | 48 +++++++++++++++++++-- pkgs/mcpx/scripts/test_gotest_report.py | 57 ++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/pkgs/mcpx/scripts/gotest-report.py b/pkgs/mcpx/scripts/gotest-report.py index 3970210ec1..6ff65675c8 100755 --- a/pkgs/mcpx/scripts/gotest-report.py +++ b/pkgs/mcpx/scripts/gotest-report.py @@ -24,11 +24,51 @@ """ import collections +import datetime import json +import re import sys +from urllib.parse import urlsplit -def read(path): +QUARANTINE_NOTICE = re.compile( + r"quarantined until (?P\d{4}-\d{2}-\d{2}) " + r"\((?P[^()\s]+)\)" +) +GITHUB_ISSUE_PATH = re.compile(r"/[^/\s?#]+/[^/\s?#]+/issues/[1-9]\d*") + + +def is_valid_quarantine_notice(reason, today): + match = QUARANTINE_NOTICE.fullmatch(reason) + if not match: + return False + + expiry_text = match.group("expiry") + try: + expiry = datetime.date.fromisoformat(expiry_text) + issue = urlsplit(match.group("issue")) + except ValueError: + return False + + return ( + expiry.isoformat() == expiry_text + and expiry >= today + and issue.scheme == "https" + and issue.netloc == "github.com" + and GITHUB_ISSUE_PATH.fullmatch(issue.path) is not None + and not issue.query + and not issue.fragment + ) + + +def utc_date(now): + parsed = datetime.datetime.fromisoformat(now.replace("Z", "+00:00")) + if parsed.tzinfo is None: + parsed = parsed.replace(tzinfo=datetime.timezone.utc) + return parsed.astimezone(datetime.timezone.utc).date() + + +def read(path, today): counts = collections.Counter() out = collections.defaultdict(list) skipped, failed, package_failed = [], [], [] @@ -60,7 +100,9 @@ def read(path): if o.strip() and not o.lstrip().startswith(("=== ", "--- ")) ] reasons[k] = (lines[-1] if lines else "(no reason given)")[:200] - quarantined = sorted(k for k in skipped if "quarantined until " in reasons[k]) + quarantined = sorted( + k for k in skipped if is_valid_quarantine_notice(reasons[k], today) + ) counted = sorted(k for k in skipped if k not in quarantined) # A failing test also emits a package-level fail for its package; only # packages without their own test failure are independent package failures @@ -105,7 +147,7 @@ def decide(skipped, passed, failed_n, stored, run, now): def main(path, stored_raw, run, now, summary, new_file): counts, skipped, failed, reasons, quarantined, all_skipped, package_failed = read( - path + path, utc_date(now) ) stored = json.loads(stored_raw) if stored_raw.strip() else None failed_n = counts["fail"] + len(package_failed) diff --git a/pkgs/mcpx/scripts/test_gotest_report.py b/pkgs/mcpx/scripts/test_gotest_report.py index ddebc5c61b..a85db08bbb 100644 --- a/pkgs/mcpx/scripts/test_gotest_report.py +++ b/pkgs/mcpx/scripts/test_gotest_report.py @@ -166,7 +166,7 @@ def test_quarantine_skip_remains_exempt_from_skip_record(self): "Action": "output", "Package": "example.test/mcpx/widgets", "Test": "TestQuarantined", - "Output": "quarantined until 2027-01-01 (https://github.com/example/1)\n", + "Output": "quarantined until 2027-01-01 (https://github.com/developing-today/code/issues/1973)\n", }, ], stored="", @@ -174,6 +174,61 @@ def test_quarantine_skip_remains_exempt_from_skip_record(self): self.assertEqual(result.returncode, 0) self.assertEqual(record["skipped_count"], 0) + def test_quarantine_expiring_today_remains_exempt(self): + result, summary, record = self.run_report( + [ + { + "Action": "skip", + "Package": "example.test/mcpx/widgets", + "Test": "TestQuarantined", + }, + { + "Action": "output", + "Package": "example.test/mcpx/widgets", + "Test": "TestQuarantined", + "Output": "quarantined until 2026-11-02 (https://github.com/developing-today/code/issues/1973)\n", + }, + ], + stored="", + ) + self.assertEqual(result.returncode, 0) + self.assertEqual(record["skipped_count"], 0) + self.assertIn("1 quarantined under #1973", summary) + + def test_invalid_quarantine_notices_count_against_skip_record(self): + invalid_notices = [ + "quarantined until banana (https://github.com/developing-today/code/issues/1973)", + "quarantined until 2026-02-30 (https://github.com/developing-today/code/issues/1973)", + "quarantined until 2000-01-01 (https://github.com/developing-today/code/issues/1973)", + "this mentions quarantined until 2027-01-01 (https://github.com/developing-today/code/issues/1973)", + "quarantined until 2027-01-01 (https://github.com.github.invalid/developing-today/code/issues/1973)", + "quarantined until 2027-01-01 (https://github.com/developing-today/code/pull/1973)", + ] + empty_record = json.dumps({"skipped_count": 0, "skipped": [], "run": "previous"}) + + for reason in invalid_notices: + with self.subTest(reason=reason): + result, summary, record = self.run_report( + [ + { + "Action": "skip", + "Package": "example.test/mcpx/widgets", + "Test": "TestQuarantined", + }, + { + "Action": "output", + "Package": "example.test/mcpx/widgets", + "Test": "TestQuarantined", + "Output": reason + "\n", + }, + ], + stored=empty_record, + ) + self.assertNotEqual(result.returncode, 0) + self.assertIn("More tests skipped than the record", summary) + self.assertNotIn("quarantined under #1973", summary) + self.assertIsNone(record) + if __name__ == "__main__": unittest.main() From 8716009bba155541b63b502a46b989aa8a230ca6 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Wed, 11 Nov 2026 01:56:57 -0600 Subject: [PATCH 2/2] fix(mcpx): strip Go source-location prefix before validating quarantine notices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the real go test -json stream a testsupport.Quarantine skip arrives as "widgets_test.go:42: quarantined until ..." — the t.Skipf call-site prefix Go generates. The validator fullmatched the unstripped reason, so every genuine quarantine counted against the skip ceiling. Strip exactly the source-prefix shape (.go:: ) before the fullmatch; a prefixed notice must still be complete and unexpired to exempt. Tests: prefixed genuine notice exempt; prefixed expired and prefixed mention-only notices still count. Suite: 10 passed. --- pkgs/mcpx/scripts/gotest-report.py | 8 +++++++- pkgs/mcpx/scripts/test_gotest_report.py | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pkgs/mcpx/scripts/gotest-report.py b/pkgs/mcpx/scripts/gotest-report.py index 6ff65675c8..d2e826d456 100755 --- a/pkgs/mcpx/scripts/gotest-report.py +++ b/pkgs/mcpx/scripts/gotest-report.py @@ -36,10 +36,16 @@ r"\((?P[^()\s]+)\)" ) GITHUB_ISSUE_PATH = re.compile(r"/[^/\s?#]+/[^/\s?#]+/issues/[1-9]\d*") +# In the real `go test -json` stream, a test's skip message carries the +# Go-generated source location of the t.Skipf call site: +# "widgets_test.go:42: quarantined until ...". That prefix is part of +# the output format, not of the notice, so strip exactly that shape +# before validating the complete notice. +GO_SOURCE_PREFIX = re.compile(r"[^\s/:]+\.go:\d+: ") def is_valid_quarantine_notice(reason, today): - match = QUARANTINE_NOTICE.fullmatch(reason) + match = QUARANTINE_NOTICE.fullmatch(GO_SOURCE_PREFIX.sub("", reason, count=1)) if not match: return False diff --git a/pkgs/mcpx/scripts/test_gotest_report.py b/pkgs/mcpx/scripts/test_gotest_report.py index a85db08bbb..7251af775a 100644 --- a/pkgs/mcpx/scripts/test_gotest_report.py +++ b/pkgs/mcpx/scripts/test_gotest_report.py @@ -174,6 +174,29 @@ def test_quarantine_skip_remains_exempt_from_skip_record(self): self.assertEqual(result.returncode, 0) self.assertEqual(record["skipped_count"], 0) + def test_quarantine_skip_with_go_source_prefix_remains_exempt(self): + # The actual `go test -json` output format: Go prefixes the + # skip message with the t.Skipf call site ("file.go:line: "). + result, summary, record = self.run_report( + [ + { + "Action": "skip", + "Package": "example.test/mcpx/widgets", + "Test": "TestQuarantined", + }, + { + "Action": "output", + "Package": "example.test/mcpx/widgets", + "Test": "TestQuarantined", + "Output": "widgets_test.go:42: quarantined until 2027-01-01 (https://github.com/developing-today/code/issues/1973)\n", + }, + ], + stored="", + ) + self.assertEqual(result.returncode, 0) + self.assertEqual(record["skipped_count"], 0) + self.assertIn("1 quarantined under #1973", summary) + def test_quarantine_expiring_today_remains_exempt(self): result, summary, record = self.run_report( [ @@ -203,6 +226,8 @@ def test_invalid_quarantine_notices_count_against_skip_record(self): "this mentions quarantined until 2027-01-01 (https://github.com/developing-today/code/issues/1973)", "quarantined until 2027-01-01 (https://github.com.github.invalid/developing-today/code/issues/1973)", "quarantined until 2027-01-01 (https://github.com/developing-today/code/pull/1973)", + "widgets_test.go:42: quarantined until 2000-01-01 (https://github.com/developing-today/code/issues/1973)", + "widgets_test.go:42: this mentions quarantined until 2027-01-01 (https://github.com/developing-today/code/issues/1973)", ] empty_record = json.dumps({"skipped_count": 0, "skipped": [], "run": "previous"})