Implement coverage option

To use pass -DCMAKE_BUILD_TYPE=Debug or Asan -DCOVERAGE=ON and build as
usual, then do ninja lcov-initialize && ninja check && ninja
lcov-collect. The result will be a directory, <Builddir>/Coverage
containing lcov tracefiles, including an aggregate file gnucash.info
which you can use for further processing. It will also report an overall summary.
Note that only C/C++ files are included.

There's one more target, lcov-generate-html, that you can run after
lcov-collect. It will generate a simple website in
<Builddir>/Coverage-HTML showing coverage by source directory (the
directories in <Builddir> have coverage for generated files). Each
directory path is a clickable link to a page that shows coverage for
each source file; the filenames link to a page for each showing which
lines have been exercised.
This commit is contained in:
John Ralls
2023-12-04 10:43:50 -08:00
parent a3f14759ab
commit 6834cb5025
28 changed files with 233 additions and 3 deletions

View File

@@ -43,6 +43,10 @@ if (WITH_SQL)
set_target_properties (gncmod-backend-dbi PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/gnucash")
endif()
if (COVERAGE)
add_coverage_target(gncmod-backend-dbi)
endif()
install(TARGETS gncmod-backend-dbi
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/gnucash

View File

@@ -80,5 +80,9 @@ if(WITH_SQL)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (COVERAGE)
add_coverage_target(gnc-backend-sql)
endif()
# No headers to install
endif()

View File

@@ -96,6 +96,10 @@ install(TARGETS gnc-backend-xml-utils
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# No headers to install
if (COVERAGE)
add_coverage_target(gnc-backend-xml-utils)
endif()
# ----
@@ -119,6 +123,10 @@ if (APPLE)
set_target_properties (gncmod-backend-xml PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
if (COVERAGE)
add_coverage_target(gncmod-backend-xml)
endif()
install(TARGETS gncmod-backend-xml
LIBRARY DESTINATION ${LIB_DIR}
ARCHIVE DESTINATION ${LIB_DIR}