harness: documentation reads through grep count (grep prefixes stripped before matching)

This commit is contained in:
dev committed 2026-10-05 21:40:34 +03:00
1 parent 0972ed2a5e
commit a2d72628e0
3 files changed
+22 -2

No files matched your search

+17
View File
@@ -315,6 +315,23 @@ class StatusTest(unittest.TestCase):
self.assertEqual(native.evaluation_status({"accepted": False, "infrastructure": True}), "infrastructure_failure")
class GrepReadTest(unittest.TestCase):
def test_grep_output_counts_as_read(self):
from ajieval import context
with tempfile.TemporaryDirectory() as d:
os.makedirs(os.path.join(d, "language"))
with open(os.path.join(d, "language", "syntax.md"), "w") as f:
f.write("alpha rule one\nbeta rule two\n")
events = [('{"command": "grep -rn rule /docs/language"}', "/docs/language/syntax.md:1:alpha rule one\n/docs/language/syntax.md-2-beta rule two"),
('{"pattern": "x", "path": "/docs"}', "language/syntax.md:alpha rule one")]
seen = {context._norm(l) for _, o in events for l in o.splitlines() if context._norm(l)}
m = context.doc_metrics(events, [("", d)], {}, seen, len)
self.assertEqual(m["coverage_by_section"]["language/syntax.md"], 1.0)
# Ordinary text with a colon is left alone.
self.assertEqual(context._norm("Note: keep this"), "Note: keep this")
self.assertEqual(context._norm(" 12→text"), "text")
class CyclesTest(unittest.TestCase):
def test_repair_cycles_from_commands(self):
from ajieval import native