fix(extract): derive unique names for GoogleTest macros to prevent same-file node collisions (#1266) - #1329
Conversation
…me-file node collisions (DeusData#1266) Signed-off-by: Harshita Joshi <j.harshitaa06@gmail.com>
|
Merged — thank you, this closes #1266 properly. The failure mode you fixed is a nasty one: What I liked about the implementation:
One entirely optional follow-up, not a blocker and not something I want you to change now: a genuine C++ function literally named Thanks for the thorough work. |
|
Thank you for the detailed review. The stability point about incremental diffing is something I will keep in mind for future contributions. I have noted the optional follow-up on tightening the parameter shape check and may pick that up separately. |
What does this PR do?
Fixes #1266
Multiple GoogleTest
TEST(...)cases defined in the same file collapse into a single graph node becausecbm_resolve_func_namereturns the bare macro nameTESTwith no argument-derived identity. Every test case in the file maps to the same qualified name (e.g.proj.file.TEST), so the graph upsert keeps only the last one and the call edges of all previous test cases are dropped.This PR adds a GoogleTest macro detection step in
extract_func_defthat composes a unique name from the two macro arguments:TEST(WidgetSuite, DoublesSmallSize)becomesTEST_WidgetSuite_DoublesSmallSize. This gives each test case its own qualified name, preventing node collisions. The fix coversTEST,TEST_F,TEST_P,TYPED_TEST, andTYPED_TEST_P. It also setsis_test = truefor these nodes so test exclusion queries work correctly.Changes:
internal/cbm/extract_defs.c: Addis_cpp_test_macro()andresolve_cpp_test_macro_name()helpers; call them inextract_func_defbefore QN computation; setis_testflagtests/test_extraction.c: Two regression tests using the exact fixture from the issue (TEST()three-case collision andTEST_F()two-case collision)Checklist
git commit -s) -- required, CI rejects unsigned commits (DCO, see CONTRIBUTING.md)make -f Makefile.cbm test)ASan test-runner hangs on startup on macOS Tahoe (Apple Clang 17), a pre-existing environment issue unrelated to this change.
make -f Makefile.cbm lint-ci)Note: the local test checkbox is unchecked because the ASan test-runner hangs on startup for all suites locally (pre-existing environment issue unrelated to this change). The production build compiles cleanly with
-Werrorand clang-format passes on all changed files. CI will run the full test suite.