Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | f6be8e3 | 2020-04-30 16:06:03 -0400 | [diff] [blame] | 2 | set -ex |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 3 | |
| 4 | if [[ $JOB_NAME == *"code-coverage" ]]; then |
Davide Pesavento | cf14807 | 2021-11-06 19:38:01 -0400 | [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 | 583473a | 2022-04-20 13:23:06 -0400 | [diff] [blame] | 7 | gcovr --object-directory build \ |
Davide Pesavento | cf14807 | 2021-11-06 19:38:01 -0400 | [diff] [blame] | 8 | --filter src/ \ |
| 9 | --exclude-throw-branches \ |
| 10 | --exclude-unreachable-branches \ |
Davide Pesavento | 583473a | 2022-04-20 13:23:06 -0400 | [diff] [blame] | 11 | --cobertura build/coverage.xml \ |
Davide Pesavento | cf14807 | 2021-11-06 19:38:01 -0400 | [diff] [blame] | 12 | --html-details build/gcovr/ \ |
Davide Pesavento | 583473a | 2022-04-20 13:23:06 -0400 | [diff] [blame] | 13 | --print-summary |
Davide Pesavento | cf14807 | 2021-11-06 19:38:01 -0400 | [diff] [blame] | 14 | |
Davide Pesavento | ba8a4ed | 2021-10-13 21:28:43 -0400 | [diff] [blame] | 15 | # Generate a detailed HTML report using lcov |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 16 | lcov --quiet \ |
| 17 | --capture \ |
| 18 | --directory . \ |
Davide Pesavento | ba8a4ed | 2021-10-13 21:28:43 -0400 | [diff] [blame] | 19 | --exclude "$PWD/tests/*" \ |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 20 | --no-external \ |
| 21 | --rc lcov_branch_coverage=1 \ |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 22 | --output-file build/coverage.info |
| 23 | |
| 24 | genhtml --branch-coverage \ |
| 25 | --demangle-cpp \ |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 26 | --legend \ |
Davide Pesavento | ba8a4ed | 2021-10-13 21:28:43 -0400 | [diff] [blame] | 27 | --output-directory build/lcov \ |
Davide Pesavento | 6ebfd7c | 2017-08-26 17:52:54 -0400 | [diff] [blame] | 28 | --title "NLSR unit tests" \ |
| 29 | build/coverage.info |
| 30 | fi |