Namespace the coverage target when embedded
Follows a87cbfb: a sibling dependency may ship a `coverage` target of its
own, so a non-top-level build gets `akstdlib_coverage` instead. The
top-level name is unchanged, and so is every documented command.
Verified: cmake --build build-coverage --target coverage still runs the
suite (14/14) and reports 99.0% of lines; the mutation target still
resolves.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -274,6 +274,14 @@ if(AKSL_COVERAGE AND Python3_FOUND)
|
|||||||
# 30s the test binaries get.
|
# 30s the test binaries get.
|
||||||
set_tests_properties(coverage_reset coverage_report PROPERTIES TIMEOUT 300)
|
set_tests_properties(coverage_reset coverage_report PROPERTIES TIMEOUT 300)
|
||||||
|
|
||||||
|
# Namespaced when embedded in another project, for the same reason the mutation
|
||||||
|
# target below is: a sibling dependency may well ship a `coverage` target too.
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
|
set(AKSL_COVERAGE_TARGET coverage)
|
||||||
|
else()
|
||||||
|
set(AKSL_COVERAGE_TARGET akstdlib_coverage)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Convenience entry point that also builds the test binaries first. It runs
|
# Convenience entry point that also builds the test binaries first. It runs
|
||||||
# the suite rather than the script directly, because the two fixture tests
|
# the suite rather than the script directly, because the two fixture tests
|
||||||
# above already reset the counters and produce the report -- and CTest pulls a
|
# above already reset the counters and produce the report -- and CTest pulls a
|
||||||
@@ -281,14 +289,14 @@ if(AKSL_COVERAGE AND Python3_FOUND)
|
|||||||
# run the tests without them. The second command re-reads the same counters to
|
# run the tests without them. The second command re-reads the same counters to
|
||||||
# print the report that CTest suppressed for the passing coverage_report test
|
# print the report that CTest suppressed for the passing coverage_report test
|
||||||
# (it only spawns gcov again, it does not re-run anything).
|
# (it only spawns gcov again, it does not re-run anything).
|
||||||
add_custom_target(coverage
|
add_custom_target(${AKSL_COVERAGE_TARGET}
|
||||||
COMMAND ctest --test-dir ${CMAKE_CURRENT_BINARY_DIR} --output-on-failure
|
COMMAND ctest --test-dir ${CMAKE_CURRENT_BINARY_DIR} --output-on-failure
|
||||||
COMMAND ${AKSL_COVERAGE_ARGS}
|
COMMAND ${AKSL_COVERAGE_ARGS}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
COMMENT "Running the test suite under gcov and reporting coverage"
|
COMMENT "Running the test suite under gcov and reporting coverage"
|
||||||
)
|
)
|
||||||
add_dependencies(coverage ${AKSL_TEST_TARGETS})
|
add_dependencies(${AKSL_COVERAGE_TARGET} ${AKSL_TEST_TARGETS})
|
||||||
elseif(AKSL_COVERAGE)
|
elseif(AKSL_COVERAGE)
|
||||||
message(WARNING "AKSL_COVERAGE=ON but Python3 was not found: "
|
message(WARNING "AKSL_COVERAGE=ON but Python3 was not found: "
|
||||||
"instrumenting the build, but the coverage report "
|
"instrumenting the build, but the coverage report "
|
||||||
|
|||||||
Reference in New Issue
Block a user