fix(checker): anchor the test attribute — #[cfg(test)] contains 'test'
Seventh silent success, found by CC-command on PR #41, and the THIRD instance in this campaign of one class: matching a substring where an exact token was meant. 'test' in s also matched '#[cfg(test)]', so every cfg-gated fixture was accepted as a test by --check-evidence — a gate written to reject exactly those. Two plain fixtures cleared it: Host::model and Sessions::apply_caught_up. The first instance was the bd dead-ID audit's unanchored exclusion list, where a real ticket improvise-gp12 would have been silently excluded because it starts with a crate name. The second was --check-evidence accepting any fn. This is the third. Now matched by exact attribute path (test, tokio::test, async_std::test, wasm_bindgen_test). Fault-injected: a #[cfg(test)] fn under a ### heading is reported as an orphan, a #[test] fn is not. Re-ran over the five merged units: 215 entries still pass, so none of them relied on the hole. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,23 @@ def rust_files(roots):
|
||||
yield os.path.join(dirpath, f)
|
||||
|
||||
|
||||
_TEST_ATTRS = ("test", "tokio::test", "async_std::test", "wasm_bindgen_test")
|
||||
|
||||
|
||||
def _is_test_attribute(line):
|
||||
"""True only for an attribute that actually marks a test.
|
||||
|
||||
Matched by exact path, never by substring: `#[cfg(test)]` contains "test"
|
||||
and marks a compilation condition, not a test.
|
||||
"""
|
||||
body = line.strip()
|
||||
if not body.startswith("#["):
|
||||
return False
|
||||
body = body[2:].rstrip()
|
||||
body = body[:-1] if body.endswith("]") else body
|
||||
return body.strip().strip(":") in _TEST_ATTRS
|
||||
|
||||
|
||||
EVIDENCE_DIR = os.path.join("context", "test-evidence")
|
||||
|
||||
|
||||
@@ -136,7 +153,11 @@ def check_evidence(roots):
|
||||
if proptest_depth <= 0:
|
||||
proptest_depth = None if "{" in raw else 0
|
||||
in_proptest = proptest_depth is not None
|
||||
if s.startswith("#[") and ("test" in s or "tokio::test" in s):
|
||||
# ANCHOR the attribute. `"test" in s` also matched `#[cfg(test)]`,
|
||||
# so every cfg-gated fixture cleared a gate written to reject
|
||||
# exactly those -- the third instance of the unanchored-substring
|
||||
# class in this campaign, after the bd audit's exclusion list.
|
||||
if s.startswith("#[") and _is_test_attribute(s):
|
||||
annotated = True
|
||||
continue
|
||||
if s.startswith("fn ") or s.startswith("pub fn ") or s.startswith("async fn "):
|
||||
|
||||
Reference in New Issue
Block a user