From 6f2f8e12655d47f67948cc8198db86b44fb644a5 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 1 Nov 2026 02:33:24 +0800 Subject: [PATCH] ci: report hashed Rust panic locations without private paths --- scripts/private-ci-diagnostics.py | 7 +++++++ scripts/tests/test_private_ci.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/scripts/private-ci-diagnostics.py b/scripts/private-ci-diagnostics.py index d0cb0b8..65852b6 100644 --- a/scripts/private-ci-diagnostics.py +++ b/scripts/private-ci-diagnostics.py @@ -27,6 +27,13 @@ def report_tests(output): names = set(re.findall(r'^test (.+?) \.\.\. FAILED\r?$', output, re.MULTILINE)) for fingerprint in sorted(hashlib.sha256(name.encode()).hexdigest() for name in names): print(f'::error::Rust test failure fingerprint: {fingerprint}') + panics = re.findall( + r"^thread '([^'\r\n]+)'(?: \([0-9]+\))? panicked at [^\r\n]+:([0-9]+):([0-9]+):\r?$", + output, re.MULTILINE) + locations = {(hashlib.sha256(name.encode()).hexdigest(), int(line), int(column)) + for name, line, column in panics} + for fingerprint, line, column in sorted(locations): + print(f'::error::Rust test panic location: {fingerprint} {line}:{column}') def main(): diff --git a/scripts/tests/test_private_ci.py b/scripts/tests/test_private_ci.py index 4706fcd..ae6c0e2 100644 --- a/scripts/tests/test_private_ci.py +++ b/scripts/tests/test_private_ci.py @@ -238,6 +238,22 @@ class PrivateTestStageTests(unittest.TestCase): self.assertEqual(result.stdout, f'::error::Rust test failure fingerprint: {digest}\n') self.assertEqual(result.stderr, '') + def test_panic_diagnostics_hide_filename_and_payload(self): + for thread_id in ('', ' (1234)'): + with self.subTest(thread_id=thread_id), tempfile.TemporaryDirectory() as temporary: + log = Path(temporary) / 'private.log' + log.write_text('test private::one ... FAILED\n' + f"thread 'private::one'{thread_id} panicked at PRIVATE_FILENAME.rs:321:9:\n" + 'PRIVATE_PANIC_PAYLOAD\n') + result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'), + 'tests', str(log)], capture_output=True, text=True) + self.assertEqual(result.returncode, 0, result.stderr) + digest = hashlib.sha256(b'private::one').hexdigest() + self.assertEqual(result.stdout, + f'::error::Rust test failure fingerprint: {digest}\n' + f'::error::Rust test panic location: {digest} 321:9\n') + self.assertEqual(result.stderr, '') + class MacOSArtifactSelectionTests(unittest.TestCase): def select(self, jobs, artifacts=None):