Commit fb023d70 authored by Evan Read's avatar Evan Read

Merge branch 'juergen.kosel.jk-master-patch-70281' into 'master'

Update test_coverage_visualization.md with C/C++ example

See merge request gitlab-org/gitlab!53407
parents 884e3656 80e04f3e
...@@ -219,3 +219,32 @@ run tests: ...@@ -219,3 +219,32 @@ run tests:
reports: reports:
cobertura: coverage.xml cobertura: coverage.xml
``` ```
### C/C++ example
The following [`gitlab-ci.yml`](../../../ci/yaml/README.md) example for C/C++ with
`gcc` or `g++` as the compiler uses [`gcovr`](https://gcovr.com/en/stable/) to generate the coverage
output file in Cobertura XML format.
This example assumes:
- That the `Makefile` is created by `cmake` in the `build` directory,
within another job in a previous stage.
(If you use `automake` to generate the `Makefile`,
then you need to call `make check` instead of `make test`.)
- `cmake` (or `automake`) has set the compiler option `--coverage`.
```yaml
run tests:
stage: test
script:
- cd build
- make test
- gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR}
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
expire_in: 2 days
reports:
cobertura: build/coverage.xml
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment