diff --git a/cmake/templates/CoverageTest.sh.in b/cmake/templates/CoverageTest.sh.in index 79e9d567a..ae6ef4545 100755 --- a/cmake/templates/CoverageTest.sh.in +++ b/cmake/templates/CoverageTest.sh.in @@ -1,30 +1,43 @@ #!/bin/sh set -e # Capture (-c) coverage data generated by the test. "${LCOV_EXECUTABLE}" --gcov-tool="${GCOV_EXECUTABLE}" ${LCOV_OPTIONS} \ -c -d "${CMAKE_BINARY_DIR}" \ -t ${SANITIZED_TARGET} \ -o "${TARGET}.info" # Reset to zero (-z) the counters (remove the *.gcda coverage files). "${LCOV_EXECUTABLE}" --gcov-tool="${GCOV_EXECUTABLE}" ${LCOV_OPTIONS} \ -z -d "${CMAKE_BINARY_DIR}" # Remove the coverage data for the paths matching any of the patterns. "${__COVERAGE_PYTHON}" "${CMAKE_SOURCE_DIR}/cmake/utils/filter-lcov.py" \ ${LCOV_FILTER_PATTERN} "${TARGET}.info" "${TARGET}_filtered.info" # Add (-a) the baseline and test coverage data files to combine them # into a single one. "${LCOV_EXECUTABLE}" --gcov-tool="${GCOV_EXECUTABLE}" ${LCOV_OPTIONS} \ -a "${CMAKE_BINARY_DIR}/baseline.info" \ -a "${TARGET}_filtered.info" \ -o "${TARGET}_combined.info" # Generate the HTML coverage report from the coverage data. "${GENHTML_EXECUTABLE}" ${LCOV_OPTIONS} \ --demangle-cpp \ -s "${TARGET}_combined.info" \ -o "${CMAKE_BINARY_DIR}/${TARGET}.coverage" + +# Generate a textual coverage report and summary from the coverage data. +# Depending on the version of lcov, the following commands can output to stdout, +# stderr or both, and not necessarily the same way for both options. This forces +# us to redirect both to be sure to catch all the output. There is the -o option +# to set the output file but obviously it doesn't work for these cases. +"${LCOV_EXECUTABLE}" ${LCOV_OPTIONS} \ + --list "${TARGET}_combined.info" \ + > "${CMAKE_BINARY_DIR}/${TARGET}.coverage/coverage.txt" 2>&1 + +"${LCOV_EXECUTABLE}" ${LCOV_OPTIONS} \ + --summary "${TARGET}_combined.info" \ + > "${CMAKE_BINARY_DIR}/${TARGET}.coverage/coverage-summary.txt" 2>&1