fix(extract): derive unique names for GoogleTest macros to prevent same-file node collisions (#1266) - #1329
Open
harshitaajoshi wants to merge 1 commit into
Conversation
…me-file node collisions (DeusData#1266) Signed-off-by: Harshita Joshi <j.harshitaa06@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.