Skip to content

fix(test): strip comments before matching in the #44 and #117 sensors - #126

Merged
thesprockee merged 2 commits into
mainfrom
issue-123
Oct 6, 2026
Merged

thesprockee merged 2 commits into
mainfrom
issue-123

Conversation

@thesprockee

Copy link
Copy Markdown
Member

Summary

Mutation test (manual, not committed)

  • Commented out EchoVR::Broadcaster* owner = GameServer::RecordBroadcasterOwner(*m_context); in src/runtime/server/gameserver.cpp, replacing it with owner = nullptr; as a decoy → before the fix, the gameserver: 033b303 dropped cb.broadcasterOwner assignment, UnregisterBroadcasterCallbacks never unregisters anything #117 check still passed (confirmed by running the old regex without strip_comments against the mutated file); after the fix, test_broadcaster_callbacks_record_their_owner_before_listening correctly FAILED.
  • Same mutation shape against self->ShutdownUnregisterOnGameThread(); in the shutdown-thread lambda → test_shutdown_thread_never_touches_the_callback_registry correctly FAILED.
  • Restored both call sites; all 7 tests in the file pass again, confirmed by rerun.

Test plan

Fixes #123

🤖 Generated with Claude Code

thesprockee and others added 2 commits October 5, 2026 22:24
tools/tests/test_runtime_lifecycle_invariants.py's regex-based source checks
matched raw source text, so a commented-out call site with a decoy
statement nearby still satisfied the check — mutation-tested on both
test_shutdown_thread_never_touches_the_callback_registry (#44) and
test_broadcaster_callbacks_record_their_owner_before_listening (#117).
Add strip_comments(), the same //-and-block-comment-aware approach the
justfile's N99 sensors already use, and run it over every extracted
function body before the regexes see it.

Fixes #123

Co-Authored-By: nevr-runtime <agents@sprock.io>
…raced_function

Opus review of PR #126 found two remaining issues in the strip_comments fix:

1. False negative: closing a block comment appended nothing to the result,
   so `return/**/Unregister();` collapsed to `returnUnregister();` — gluing
   two real tokens together and breaking \bUnregister word-boundary
   matching for a call a comment merely interrupts, not one that is
   commented out. The compiler treats a block comment as whitespace;
   strip_comments now does too, appending a single space when the `*/`
   closes.

2. Scope gap: the #44/#117 sensors were wrapped in strip_comments() by
   hand, but every other regex/substring sensor in this file (e.g.
   test_every_boot_detour_result_is_consumed's `if (installed) return;`
   check) still matched raw, unstripped source — a commented-out real line
   with a decoy nearby still satisfied assertIn. Moved strip_comments()
   into extract_braced_function() itself so every sensor in the file gets
   the same comment-transparency the compiler has, and removed the now-
   redundant per-call wraps around the #44/#117 variables.

Verified both fixes with a mutation suite (scratch copies under
/var/tmp/work-nevr-runtime/issue123-mutation/): 6 real-regression mutations
across the #44/#117 sensors still correctly fail pre- and post-fix: the
return/**/Unregister(); false negative now correctly fails post-fix (missed
pre-fix); and a new mutation against initialize.cpp's
`if (installed) return;` (commented out with a decoy) now also correctly
fails post-fix (missed pre-fix) — proving the scope-gap fix reaches a
sensor the per-call wraps never touched. strip_comments edge cases (line
comments, multi-line block comments, strings/char literals containing // or
/*, a / b / c division) re-verified correct.

just verify: green (CMAKE_BUILD_PARALLEL_LEVEL=4 just verify ->
"verify: OK (mingw-release)"), including the file's own 87 ground-truth
tests under test-auth-unit.

Co-Authored-By: nevr-runtime <agents@sprock.io>
@thesprockee
thesprockee merged commit ea4f5f4 into main Oct 6, 2026
1 check passed
@thesprockee
thesprockee deleted the issue-123 branch October 6, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools/tests/test_runtime_lifecycle_invariants.py: source-level sensors don't strip comments, so a commented-out call site still passes

1 participant