blob: eb100d3c5e405bfaef9c3325f973865ce10470f4 [file] [log] [blame]
Davide Pesavento4a315b32018-11-24 14:32:19 -05001#!/usr/bin/env bash
Davide Pesavento423553e2022-08-19 20:46:06 -04002set -exo pipefail
Davide Pesavento4a315b32018-11-24 14:32:19 -05003
4if [[ $JOB_NAME == *"code-coverage" ]]; then
Davide Pesavento7243f852021-11-06 19:13:23 -04005 # 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 Pesavento38fd3982022-04-18 22:22:02 -04007 gcovr --object-directory build \
Davide Pesavento7243f852021-11-06 19:13:23 -04008 --filter src/ \
9 --exclude-throw-branches \
10 --exclude-unreachable-branches \
Davide Pesavento38fd3982022-04-18 22:22:02 -040011 --cobertura build/coverage.xml \
Davide Pesavento7243f852021-11-06 19:13:23 -040012 --html-details build/gcovr/ \
Davide Pesavento38fd3982022-04-18 22:22:02 -040013 --print-summary
Davide Pesavento4a315b32018-11-24 14:32:19 -050014
Davide Pesavento90a632b2021-10-04 01:05:24 -040015 # Generate a detailed HTML report using lcov
Davide Pesavento4a315b32018-11-24 14:32:19 -050016 lcov --quiet \
17 --capture \
18 --directory . \
Davide Pesavento90a632b2021-10-04 01:05:24 -040019 --exclude "$PWD/tests/*" \
Davide Pesavento4a315b32018-11-24 14:32:19 -050020 --no-external \
21 --rc lcov_branch_coverage=1 \
Davide Pesavento4a315b32018-11-24 14:32:19 -050022 --output-file build/coverage.info
23
24 genhtml --branch-coverage \
25 --demangle-cpp \
Davide Pesavento4a315b32018-11-24 14:32:19 -050026 --legend \
Davide Pesavento90a632b2021-10-04 01:05:24 -040027 --output-directory build/lcov \
Davide Pesavento4a315b32018-11-24 14:32:19 -050028 --title "NDNS unit tests" \
29 build/coverage.info
30fi