Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | 72517b5 | 2022-08-13 18:50:55 -0400 | [diff] [blame] | 2 | set -exo pipefail |
Davide Pesavento | e0edc4c | 2016-09-13 18:29:52 +0000 | [diff] [blame] | 3 | |
Davide Pesavento | 231ddd7 | 2016-09-02 22:20:00 +0000 | [diff] [blame] | 4 | if [[ $JOB_NAME == *"code-coverage" ]]; then |
Davide Pesavento | 2c61bad | 2021-08-30 22:40:35 -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 | 6153eaf | 2022-04-19 19:45:03 -0400 | [diff] [blame] | 7 | gcovr --object-directory build \ |
Davide Pesavento | 2c61bad | 2021-08-30 22:40:35 -0400 | [diff] [blame] | 8 | --exclude tests/ \ |
| 9 | --exclude websocketpp/ \ |
| 10 | --exclude-throw-branches \ |
| 11 | --exclude-unreachable-branches \ |
Davide Pesavento | 6153eaf | 2022-04-19 19:45:03 -0400 | [diff] [blame] | 12 | --cobertura build/coverage.xml \ |
Davide Pesavento | 2c61bad | 2021-08-30 22:40:35 -0400 | [diff] [blame] | 13 | --html-details build/gcovr/ \ |
Davide Pesavento | 6153eaf | 2022-04-19 19:45:03 -0400 | [diff] [blame] | 14 | --print-summary |
Davide Pesavento | 8d61c03 | 2017-04-29 20:06:33 -0400 | [diff] [blame] | 15 | |
Davide Pesavento | 2c61bad | 2021-08-30 22:40:35 -0400 | [diff] [blame] | 16 | # Generate a detailed HTML report using lcov |
Davide Pesavento | 8d61c03 | 2017-04-29 20:06:33 -0400 | [diff] [blame] | 17 | lcov --quiet \ |
| 18 | --capture \ |
| 19 | --directory . \ |
Davide Pesavento | 2c61bad | 2021-08-30 22:40:35 -0400 | [diff] [blame] | 20 | --exclude "$PWD/tests/*" \ |
| 21 | --exclude "$PWD/websocketpp/*" \ |
Davide Pesavento | 8d61c03 | 2017-04-29 20:06:33 -0400 | [diff] [blame] | 22 | --no-external \ |
| 23 | --rc lcov_branch_coverage=1 \ |
Davide Pesavento | 8d61c03 | 2017-04-29 20:06:33 -0400 | [diff] [blame] | 24 | --output-file build/coverage.info |
| 25 | |
| 26 | genhtml --branch-coverage \ |
| 27 | --demangle-cpp \ |
Davide Pesavento | 8d61c03 | 2017-04-29 20:06:33 -0400 | [diff] [blame] | 28 | --legend \ |
Davide Pesavento | 2c61bad | 2021-08-30 22:40:35 -0400 | [diff] [blame] | 29 | --output-directory build/lcov \ |
Davide Pesavento | 8d61c03 | 2017-04-29 20:06:33 -0400 | [diff] [blame] | 30 | --title "NFD unit tests" \ |
| 31 | build/coverage.info |
Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 32 | fi |