mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 19:45:41 -04:00

This fixes the 'negative' errors from lcov's geninfo. Before: source files: 600 lines.......: 23.2% (10654 of 45904 lines) functions...: 22.8% (848 of 3721 functions) branches....: 15.8% (7572 of 47821 branches) After: source files: 600 lines.......: 23.2% (10654 of 45904 lines) functions...: 22.8% (848 of 3721 functions) branches....: 15.8% (7572 of 47821 branches) Effectively no change in coverage, but it's likely more stable. I'll note that the error was triggering in ASTC decoding, which uses OpenMP for parallel processing.
78 lines
2.3 KiB
Bash
Executable File
78 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# lcov code coverage script.
|
|
# Based on: https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake
|
|
# (commit 59f8ab8dded56b490dec388ac6ad449318de8779)
|
|
#
|
|
# Parameters:
|
|
# - $1: Build configuration.
|
|
# - $2: Base name for lcov files.
|
|
# - $3: Output directory.
|
|
#
|
|
|
|
if [ "$#" != "3" -o ! -f CMakeCache.txt ]; then
|
|
echo "Syntax: $0 config basename output_directory"
|
|
echo "Run this script from the top-level CMake build directory."
|
|
exit 1
|
|
fi
|
|
|
|
CONFIG="$1"
|
|
coverage_base_info="$2.base.info"
|
|
coverage_test_info="$2.test.info"
|
|
coverage_info="$2.info"
|
|
coverage_cleaned="${coverage_info}.cleaned"
|
|
outputname="$3"
|
|
|
|
# lcov configuration overrides
|
|
LCOV_RC="--rc max_message_count=5 --rc branch_coverage=1"
|
|
|
|
# Cleanup lcov.
|
|
lcov ${LCOV_RC} --directory . --zerocounters
|
|
|
|
# Create baseline coverage data file.
|
|
# This ensures we get data for files that aren't loaded.
|
|
# References:
|
|
# - https://stackoverflow.com/questions/44203156/can-lcov-genhtml-show-files-that-were-never-executed
|
|
# - https://stackoverflow.com/a/45105825
|
|
lcov ${LCOV_RC} --ignore-errors inconsistent,mismatch \
|
|
-c -i -d . -o "${coverage_base_info}"
|
|
|
|
# Run tests.
|
|
ctest -C "${CONFIG}"
|
|
if [ "$?" != "0" ]; then
|
|
echo "*** WARNING: Some tests failed. Generating the lcov report anyway." >&2
|
|
fi
|
|
|
|
echo "*** A"
|
|
# Capture lcov output from the unit tests.
|
|
lcov ${LCOV_RC} --ignore-errors inconsistent,mismatch \
|
|
-c -d . -o "${coverage_test_info}"
|
|
|
|
echo "*** B"
|
|
# Combine baseline and unit test output.
|
|
lcov ${LCOV_RC} --ignore-errors inconsistent,corrupt,mismatch \
|
|
-a "${coverage_base_info}" \
|
|
-a "${coverage_test_info}" \
|
|
-o "${coverage_info}"
|
|
|
|
echo "*** C"
|
|
# Remove third-party libraries and generated sources.
|
|
lcov ${LCOV_RC} --ignore-errors unused \
|
|
-o "${coverage_cleaned}" -r "${coverage_info}" \
|
|
'*/tests/*' '/usr/*' '*/extlib/*' \
|
|
'*/moc_*.cpp' '*.moc' '*/ui_*.h' '*/qrc_*.cpp' \
|
|
'*/glibresources.c' \
|
|
'*/NetworkManager.c' \
|
|
'*/networkmanagerinterface.cpp' \
|
|
'*/networkmanagerinterface.h' \
|
|
'*/Notifications.c' \
|
|
'*/notificationsinterface.cpp' \
|
|
'*/notificationsinterface.h' \
|
|
'*/SpecializedThumbnailer1.c' \
|
|
'*/SpecializedThumbnailer1.h' \
|
|
'*/libi18n/gettext.h'
|
|
|
|
# Generate the HTML report.
|
|
genhtml ${LCOV_RC} -o "${outputname}" "${coverage_cleaned}"
|
|
rm -f "${coverage_base_info}" "${coverage_test_info}" "${coverage_info}" "${coverage_cleaned}"
|
|
exit 0
|