Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | 679c42a | 2025-03-25 20:50:03 -0400 | [diff] [blame^] | 2 | set -eo pipefail |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 3 | |
Davide Pesavento | 679c42a | 2025-03-25 20:50:03 -0400 | [diff] [blame^] | 4 | [[ $JOB_NAME == *code-coverage ]] || exit 0 |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 5 | |
Davide Pesavento | 679c42a | 2025-03-25 20:50:03 -0400 | [diff] [blame^] | 6 | export FORCE_COLOR=1 |
| 7 | export UV_NO_MANAGED_PYTHON=1 |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 8 | |
Davide Pesavento | 679c42a | 2025-03-25 20:50:03 -0400 | [diff] [blame^] | 9 | set -x |
| 10 | |
| 11 | # Generate an XML report (Cobertura format) and a detailed HTML report using gcovr |
| 12 | # Note: trailing slashes are important in the paths below. Do not remove them! |
| 13 | uvx gcovr@5.2 \ |
| 14 | --object-directory build \ |
| 15 | --filter src/ \ |
| 16 | --exclude-throw-branches \ |
| 17 | --exclude-unreachable-branches \ |
| 18 | --cobertura build/coverage.xml \ |
| 19 | --html-details build/gcovr/ \ |
| 20 | --print-summary |
| 21 | |
| 22 | # Generate a detailed HTML report using lcov |
| 23 | lcov --quiet \ |
| 24 | --capture \ |
| 25 | --directory . \ |
| 26 | --exclude "$PWD/tests/*" \ |
| 27 | --no-external \ |
| 28 | --rc lcov_branch_coverage=1 \ |
| 29 | --output-file build/coverage.info |
| 30 | |
| 31 | genhtml --branch-coverage \ |
| 32 | --demangle-cpp \ |
| 33 | --legend \ |
| 34 | --output-directory build/lcov \ |
| 35 | --title "NDNS unit tests" \ |
| 36 | build/coverage.info |