gkdbus: Fix underflow and unreachable code bug
[platform/upstream/glib.git] / .gitlab-ci / coverage-docker.sh
1 #!/bin/bash
2
3 set -ex
4
5 # Fixup Windows paths
6 python3 ./.gitlab-ci/fixup-cov-paths.py _coverage/*.lcov
7
8 for path in _coverage/*.lcov; do
9     # Remove coverage from generated code in the build directory
10     lcov --config-file .lcovrc -r "${path}" '*/_build/*' -o "$(pwd)/${path}"
11     # Remove any coverage from system files
12     lcov --config-file .lcovrc -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}"
13     # Remove coverage from the fuzz tests, since they are run on a separate CI system
14     lcov --config-file .lcovrc -r "${path}" "*/fuzzing/*" -o "$(pwd)/${path}"
15     # Remove coverage from copylibs and subprojects
16     for lib in xdgmime libcharset gnulib; do
17         lcov --config-file .lcovrc -r "${path}" "*/${lib}/*" -o "$(pwd)/${path}"
18     done
19
20     # Convert to cobertura format for gitlab integration
21     cobertura_base="${path/.lcov}-cobertura"
22     cobertura_xml="${cobertura_base}.xml"
23     lcov_cobertura "${path}" --output "${cobertura_xml}"
24     mkdir -p "${cobertura_base}"
25     cobertura-split-by-package.py "${cobertura_xml}" "${cobertura_base}"
26     rm -f "${cobertura_xml}"
27 done
28
29 genhtml \
30     --ignore-errors=source \
31     --config-file .lcovrc \
32     _coverage/*.lcov \
33     -o _coverage/coverage
34
35 cd _coverage
36 rm -f ./*.lcov
37
38 cat >index.html <<EOL
39 <html>
40 <body>
41 <ul>
42 <li><a href="coverage/index.html">Coverage</a></li>
43 </ul>
44 </body>
45 </html>
46 EOL
47
48 # Print a handy link to the coverage report
49 echo "Coverage report at: https://${CI_PROJECT_NAMESPACE}.pages.gitlab.gnome.org/-/${CI_PROJECT_NAME}/-/jobs/${CI_BUILD_ID}/artifacts/_coverage/coverage/index.html"