mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-11-03 12:50:50 -06:00
Fix failing coverage tests on Ubuntu 26.04LTS
geninfo barfs if none of the code in the directory was exercised, so check for *.gcda files. If none are found skip running lcov-collect. Baseline info files were created earlier so 0 coverage is still registered. Assisted-by: Claude Code Opus 5.5 Signed-off: John Ralls <jralls@ceridwen.us>
This commit is contained in:
1 parent
f765ffdc59
commit
1071f72a70
1 file changed
+20
-1
@@ -90,6 +90,22 @@ add_custom_target(lcov-generate-html
|
||||
COMMAND_EXPAND_LISTS)
|
||||
set_target_properties(lcov-generate-html PROPERTIES ADDITIONAL_CLEAN_FILES "${coverage_html_dir}")
|
||||
|
||||
# geninfo exits 1 when there are no .gcda files (lcov >= 2.3, regardless of
|
||||
# --ignore-errors empty), which happens for targets the tests never run. The
|
||||
# _base.info from lcov-initialize already covers those, so skip the capture.
|
||||
# Usage: collect-target.sh target_dir result_info lcov-command...
|
||||
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/collect-target.sh
|
||||
CONTENT
|
||||
"#!/bin/sh
|
||||
rm -f \"$2\"
|
||||
if find \"$1\" -name '*.gcda' -print -quit | grep -q .
|
||||
then
|
||||
shift 2
|
||||
exec \"$@\"
|
||||
fi
|
||||
"
|
||||
FILE_PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE WORLD_EXECUTE)
|
||||
|
||||
function (add_coverage_target tgt)
|
||||
get_target_property(build_dir ${tgt} BINARY_DIR)
|
||||
set(target_dir "${build_dir}/CMakeFiles/${tgt}.dir")
|
||||
@@ -102,8 +118,11 @@ function (add_coverage_target tgt)
|
||||
add_dependencies(lcov-initialize lcov-initialize-${tgt})
|
||||
add_dependencies(lcov-initialize-${tgt} ${tgt})
|
||||
|
||||
set(result_info "${coverage_dir}/${tgt}_result.info")
|
||||
add_custom_target(lcov-collect-${tgt}
|
||||
COMMAND lcov ${geninfo_flags} ${generate_flags} -c --directory ${target_dir} -o "${coverage_dir}/${tgt}_result.info"
|
||||
COMMAND sh ${CMAKE_BINARY_DIR}/collect-target.sh ${target_dir} ${result_info}
|
||||
lcov ${geninfo_flags} ${generate_flags} -c --directory ${target_dir} -o ${result_info}
|
||||
DEPENDS ${CMAKE_BINARY_DIR}/collect-target.sh
|
||||
VERBATIM
|
||||
COMMAND_EXPAND_LISTS)
|
||||
add_dependencies(lcov-collect lcov-collect-${tgt})
|
||||
|
||||
Reference in new issue
Block a user