Davide Pesavento | 87d4e20 | 2020-08-09 01:18:52 -0400 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | da1a4d3 | 2022-08-19 19:03:24 -0400 | [diff] [blame] | 2 | set -exo pipefail |
Davide Pesavento | 87d4e20 | 2020-08-09 01:18:52 -0400 | [diff] [blame] | 3 | |
| 4 | if [[ $JOB_NAME == *"code-coverage" ]]; then |
Davide Pesavento | f078fb5 | 2021-11-05 16:08:44 -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 | 0ba5eb6 | 2022-04-19 18:05:16 -0400 | [diff] [blame] | 7 | gcovr --object-directory build \ |
Davide Pesavento | f078fb5 | 2021-11-05 16:08:44 -0400 | [diff] [blame] | 8 | --filter PSync/ \ |
| 9 | --exclude-throw-branches \ |
| 10 | --exclude-unreachable-branches \ |
Davide Pesavento | 0ba5eb6 | 2022-04-19 18:05:16 -0400 | [diff] [blame] | 11 | --cobertura build/coverage.xml \ |
Davide Pesavento | f078fb5 | 2021-11-05 16:08:44 -0400 | [diff] [blame] | 12 | --html-details build/gcovr/ \ |
Davide Pesavento | 0ba5eb6 | 2022-04-19 18:05:16 -0400 | [diff] [blame] | 13 | --print-summary |
Davide Pesavento | f078fb5 | 2021-11-05 16:08:44 -0400 | [diff] [blame] | 14 | |
Davide Pesavento | 8dce194 | 2021-10-02 22:31:26 -0400 | [diff] [blame] | 15 | # Generate a detailed HTML report using lcov |
Davide Pesavento | 87d4e20 | 2020-08-09 01:18:52 -0400 | [diff] [blame] | 16 | lcov --quiet \ |
| 17 | --capture \ |
| 18 | --directory . \ |
Davide Pesavento | 8dce194 | 2021-10-02 22:31:26 -0400 | [diff] [blame] | 19 | --exclude "$PWD/tests/*" \ |
Davide Pesavento | 87d4e20 | 2020-08-09 01:18:52 -0400 | [diff] [blame] | 20 | --no-external \ |
| 21 | --rc lcov_branch_coverage=1 \ |
Davide Pesavento | 87d4e20 | 2020-08-09 01:18:52 -0400 | [diff] [blame] | 22 | --output-file build/coverage.info |
| 23 | |
| 24 | genhtml --branch-coverage \ |
| 25 | --demangle-cpp \ |
| 26 | --legend \ |
Davide Pesavento | 8dce194 | 2021-10-02 22:31:26 -0400 | [diff] [blame] | 27 | --output-directory build/lcov \ |
Davide Pesavento | 87d4e20 | 2020-08-09 01:18:52 -0400 | [diff] [blame] | 28 | --title "PSync unit tests" \ |
| 29 | build/coverage.info |
| 30 | fi |