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

lcov-2.x is much more strict than lcov-1.x, and it doesn't like some stuff with gtest, so we have to ignore various warnings. [gtk] Class headers: lcov gets confused if G_DECLARE_FINAL_TYPE() is in a preprocessor conditional. Instead, make conditional typedefs, and use those typedefs in G_DECLARE_FINAL_TYPE(). lcov: ERROR: (inconsistent) "gtk/MessageWidget.h":19: duplicate function 'RP_IS_MESSAGE_WIDGET' starts on line 19 but previous definition started on 17 while capturing from ./src/gtk/gtk3/CMakeFiles/rom-properties-gtk3.dir/__/MessageWidget.c.gcno. (use "lcov --ignore-errors inconsistent ..." to bypass this error) lcov.sh: Ignore inconsistent errors because gtest macros confuse lcov: lcov: ERROR: (inconsistent) mismatched end line for _ZN10LibRomData5Tests37SortFuncsTest_gtk4_ascendingSort_Test8TestBodyEv at src/gtk/tests/SortFuncsTest_gtk4.cpp:136: 136 -> 163 while capturing from ./src/gtk/tests/CMakeFiles/SortFuncsTest_gtk4.dir/SortFuncsTest_gtk4.cpp.gcno (use "lcov --ignore-errors inconsistent ..." to bypass this error) Also ignore "corrupt" errors, which seemingly happens randomly. Ignore "unused" removed file warnings, since SpecializedThumbnailer1.h might not be present in the output.
73 lines
2.1 KiB
Bash
Executable File
73 lines
2.1 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"
|
|
|
|
# Cleanup lcov.
|
|
set -v
|
|
lcov --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 --ignore-errors inconsistent \
|
|
-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
|
|
|
|
# Capture lcov output from the unit tests.
|
|
lcov --ignore-errors inconsistent \
|
|
-c -d . -o "${coverage_test_info}"
|
|
|
|
# Combine baseline and unit test output.
|
|
lcov --ignore-errors inconsistent,corrupt \
|
|
-a "${coverage_base_info}" \
|
|
-a "${coverage_test_info}" \
|
|
-o "${coverage_info}"
|
|
|
|
# Remove third-party libraries and generated sources.
|
|
lcov --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 -o "${outputname}" "${coverage_cleaned}"
|
|
rm -f "${coverage_base_info}" "${coverage_test_info}" "${coverage_info}" "${coverage_cleaned}"
|
|
exit 0
|