agent-desktop/scripts/check_rust_comments_test.py
Lahfir 4add46ab38 chore: checkpoint five verified remediation rounds before e2e convergence
Freezes the working tree as a fixed baseline: static gates green (1551 lib
tests, clippy -D warnings, fmt, release 0.4.7), live-verified E1/E2 fixes,
notification/harness work pending e2e acceptance. Known-open: hover fixture
churn to back out, 3 e2e failures (hover oracle, AE6 sheet, sheet cancel),
NT1-NT4 unproven.
2026-07-11 22:06:13 -07:00

51 lines
1.4 KiB
Python

import importlib.util
import unittest
from pathlib import Path
MODULE_PATH = Path(__file__).with_name("check_rust_comments.py")
SPEC = importlib.util.spec_from_file_location("check_rust_comments", MODULE_PATH)
COMMENTS = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(COMMENTS)
class RustCommentScannerTests(unittest.TestCase):
def test_ignores_doc_comments_and_comment_markers_in_strings(self):
source = '''
/// Public documentation.
//! Module documentation.
let url = "https://example.test/path";
let marker = "/* not a comment */";
let raw = r###"// still text /* still text */"###;
'''
self.assertEqual(COMMENTS.forbidden_comments(source), [])
def test_reports_line_and_block_comments_only_in_rust_code(self):
source = '''
// standalone
let value = 1; // trailing
/* block */
let other = 2; /* trailing block */
'''
findings = COMMENTS.forbidden_comments(source)
self.assertEqual(
findings,
[
(2, "non-doc line comment"),
(3, "end-of-line comment"),
(4, "block comment"),
(5, "block comment"),
],
)
def test_nested_doc_blocks_do_not_expose_inner_markers(self):
source = "/** docs with /* nested */ text */\nlet value = 1;\n"
self.assertEqual(COMMENTS.forbidden_comments(source), [])
if __name__ == "__main__":
unittest.main()