Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | fee7ee3 | 2020-04-15 02:45:07 -0400 | [diff] [blame] | 2 | set -ex |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 3 | |
| 4 | if [[ $JOB_NAME == *"code-coverage" ]]; then |
Davide Pesavento | 90a632b | 2021-10-04 01:05:24 -0400 | [diff] [blame^] | 5 | # Generate an XML report (Cobertura format) using gcovr |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 6 | gcovr --object-directory=build \ |
| 7 | --output=build/coverage.xml \ |
| 8 | --exclude="$PWD/tests" \ |
| 9 | --root=. \ |
| 10 | --xml |
| 11 | |
Davide Pesavento | 90a632b | 2021-10-04 01:05:24 -0400 | [diff] [blame^] | 12 | # Generate a detailed HTML report using lcov |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 13 | lcov --quiet \ |
| 14 | --capture \ |
| 15 | --directory . \ |
Davide Pesavento | 90a632b | 2021-10-04 01:05:24 -0400 | [diff] [blame^] | 16 | --exclude "$PWD/tests/*" \ |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 17 | --no-external \ |
| 18 | --rc lcov_branch_coverage=1 \ |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 19 | --output-file build/coverage.info |
| 20 | |
| 21 | genhtml --branch-coverage \ |
| 22 | --demangle-cpp \ |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 23 | --legend \ |
Davide Pesavento | 90a632b | 2021-10-04 01:05:24 -0400 | [diff] [blame^] | 24 | --output-directory build/lcov \ |
Davide Pesavento | 4a315b3 | 2018-11-24 14:32:19 -0500 | [diff] [blame] | 25 | --title "NDNS unit tests" \ |
| 26 | build/coverage.info |
| 27 | fi |