From c9c46c24a6b004ba602b935a1738391a20f14e09 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 17 Apr 2024 10:57:35 -0400 Subject: [PATCH] xo-flatstring: build: targets to install ccov output --- README.md | 11 ++++++++--- utest/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35b6f731..730c7a18 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ Limitations: - (asof April 2024) missing features: `insert`, `erase`, `push_back`, `append`, `replace`, `find`, `compare`, `starts_with`, `ends_with`, `contains`, `substr`. +## Documentation + +xo-flatstring documentation here: https://rconybea.github.io/web/xo-flatstring/html/index.html +unit test coverage here: https://rconybea.github.io/web/xo-flatstring/ccov/html/index.html + ## Getting started ### build + install @@ -39,18 +44,18 @@ When complete, point local browser to `xo-flatstring/.build/docs/sphinx/index.ht ``` $ cd xo-flatstring $ mkdir .build-ccov -$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -B .build-ccov +$ cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=coverage -B .build-ccov $ cmake --build .build-ccov ``` run coverage-enabled unit tests ``` -$ (cd .build-ccov && ctest) +$ cmake --build .build-ccov -- test ``` generate html+text coverage report ``` -$ .build-ccov/gen-ccov +$ cmake --build .build-ccov -- ccov ``` browse to `.build-ccov/ccov/html/index.html` diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 11e76f63..142a1a4b 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -11,6 +11,37 @@ xo_include_options2(${SELF_EXE}) add_test(NAME ${SELF_EXE} COMMAND ${SELF_EXE}) #target_code_coverage(${SELF_EXE} AUTO ALL) +# ---------------------------------------------------------------- +# in coverage build, target to build+install coverage report + +set(CCOV_OUTPUT_DIR ${PROJECT_BINARY_DIR}/ccov/html) +set(CCOV_INDEX_FILE ${CCOV_OUTPUT_DIR}/index.html) +set(CCOV_REPORT_EXE ${PROJECT_BINARY_DIR}/gen-ccov) +set(CCOV_INSTALL_DOCDIR ${CMAKE_INSTALL_DOCDIR}/ccov) + +# 'test' target should always be out-of-date +# +# DEPENDS: reminder - can't put 'test' here, requires 'all' target +# +add_custom_command( + OUTPUT ${CCOV_INDEX_FILE} + DEPENDS ${SELF_EXE} + COMMAND ${CCOV_REPORT_EXE} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMENT "Generating coverage report -> [${CCOV_OUTPUT_DIR}]") + +add_custom_target( + ccov + DEPENDS ${CCOV_INDEX_FILE} ${SELF_EXE}) + +# OPTIONAL: quietly skip this step if ccov report not generated +install( + DIRECTORY ${CCOV_OUTPUT_DIR} + FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ + DESTINATION ${CCOV_INSTALL_DOCDIR} + COMPONENT Documentation + OPTIONAL) + # ---------------------------------------------------------------- # deps: logutils, ...