xo-flatstring: build: targets to install ccov output

This commit is contained in:
Roland Conybeare 2024-04-17 10:57:35 -04:00
commit c9c46c24a6
2 changed files with 39 additions and 3 deletions

View file

@ -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`

View file

@ -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, ...