Record TEST_GROUP source locations for cmake-tools integration#49
Merged
Conversation
The upstream PR cpputest/cpputest#1848 added DEF_SOURCE_LINE support to CTest discovery so VS Code's CMake Tools extension can navigate to test sources. It noted a limitation: group-mode entries pointed to the first TEST() in the group rather than the TEST_GROUP() declaration itself. Introduce GroupLocation, a self-registering class (same static linked-list pattern as OrderedShell) that captures __FILE__ and __LINE__ at the TEST_GROUP() macro site. Add a -lgl flag to list group declaration locations in group.file.line format. Update the cmake discovery script to call -lgl and use the real group locations for DEF_SOURCE_LINE, with a graceful fallback to the previous heuristic for old binaries.
Bare get_head() can't resolve from a @file block without class/namespace context. Use the fully-qualified name so Doxygen can link it correctly.
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.
Description
Upstream PR cpputest/cpputest#1848 added
DEF_SOURCE_LINEsupport to CTest discovery so VS Code's CMake Tools extension can navigate directly to test sources. It noted a limitation:This meant the "go to test" link for a group-level CTest entry jumped to the first
TEST()in the group, not theTEST_GROUP()declaration.This PR resolves that limitation.
Changes
New
GroupLocationclass (include/mutiny/test/GroupLocation.hpp,src/test/GroupLocation.cpp)A self-registering node that captures the source location of each
TEST_GROUP()declaration. Follows the same static linked-list pattern asOrderedShell. No heap allocation; no standard library dependency (works withMUTINY_USE_STD_CPP_LIB=OFF). The existing link-time duplicate-group guard (extern int) is replaced by theGroupLocationobject, preserving the same linker error for duplicate group names.Updated
TEST_GROUP()macro (include/mutiny/test.hpp)Now captures
__FILE__and__LINE__via theGroupLocationconstructor.TEST_GROUP_C_WRAPPERdelegates toTEST_GROUPand picks this up automatically.New
-lglflag — list group locationsThreads through
CommandLineArguments→CommandLineRunner→Registry::list_test_group_locations(). Output format:group.file.line\nper group.Updated cmake discovery script (
cmake/_mutiny_discovery.cmake)Calls
-lglafter-lland uses the real group declaration locations forDEF_SOURCE_LINE. Falls back gracefully to the previous lowest-test-line heuristic when-lglexits non-zero (old binaries). The same fallback pattern is already used for-lo.Related Issues
Addresses the limitation noted in cpputest/cpputest#1848.
Type of Change
Checklist
docs/for any user-facing changes.mu::tinynamespace,INCLUDED_MUTINY_guards,mutiny_C-prefix)..hand.c.cpp) is required for parity.CONTRIBUTING.mdfile to ensure compliance with architectural guidelines.