Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | 552174c | 2020-04-16 01:54:08 -0400 | [diff] [blame] | 2 | set -ex |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 3 | |
| 4 | if [[ $JOB_NAME == *"code-coverage" ]]; then |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 5 | # Generate an XML report (Cobertura format) and a detailed HTML report using gcovr |
| 6 | # Note: trailing slashes are important in the paths below. Do not remove them! |
Davide Pesavento | 9d6d438 | 2022-04-19 17:26:03 -0400 | [diff] [blame] | 7 | gcovr --object-directory build \ |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 8 | --filter src/ \ |
| 9 | --exclude-throw-branches \ |
| 10 | --exclude-unreachable-branches \ |
Davide Pesavento | 9d6d438 | 2022-04-19 17:26:03 -0400 | [diff] [blame] | 11 | --cobertura build/coverage.xml \ |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 12 | --html-details build/gcovr/ \ |
Davide Pesavento | 9d6d438 | 2022-04-19 17:26:03 -0400 | [diff] [blame] | 13 | --print-summary |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 14 | |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 15 | # Generate a detailed HTML report using lcov |
Davide Pesavento | cf9ffe4 | 2018-01-21 22:21:53 -0500 | [diff] [blame] | 16 | lcov --quiet \ |
| 17 | --capture \ |
| 18 | --directory . \ |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 19 | --exclude "$PWD/tests/*" \ |
Davide Pesavento | cf9ffe4 | 2018-01-21 22:21:53 -0500 | [diff] [blame] | 20 | --no-external \ |
| 21 | --rc lcov_branch_coverage=1 \ |
Davide Pesavento | cf9ffe4 | 2018-01-21 22:21:53 -0500 | [diff] [blame] | 22 | --output-file build/coverage.info |
| 23 | |
| 24 | genhtml --branch-coverage \ |
| 25 | --demangle-cpp \ |
Davide Pesavento | cf9ffe4 | 2018-01-21 22:21:53 -0500 | [diff] [blame] | 26 | --legend \ |
Davide Pesavento | 725d3fc | 2021-11-19 23:37:03 -0500 | [diff] [blame] | 27 | --output-directory build/lcov \ |
Davide Pesavento | cf9ffe4 | 2018-01-21 22:21:53 -0500 | [diff] [blame] | 28 | --title "ndncert unit tests" \ |
| 29 | build/coverage.info |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 30 | fi |