Skip to content

Commit

Permalink
cmake, doc: Document test coverage using CMake-based build system
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 27, 2023
1 parent 19ead5e commit 98bed06
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,31 @@ Test coverage

This library aims to have full coverage of the reachable lines and branches.

To create a test coverage report, configure with `--enable-coverage` (use of GCC is necessary):
To create a test coverage report, configure for coverage analysis (use of GCC is necessary), build and run the tests:

$ ./configure --enable-coverage
* using Autotools-based build system:

Run the tests:
```
$ ./configure --enable-coverage
$ make check
```

$ make check
* using CMake-based build system:

```
$ cmake --preset coverage -S . -B build
$ cmake --build build
$ ctest --test-dir build
```

To create a report, `gcovr` is recommended, as it includes branch coverage reporting:

$ gcovr --exclude 'src/bench*' --print-summary
$ gcovr --exclude 'build/*' --exclude 'src/bench*' --print-summary

To create a HTML report with coloured and annotated source code:

$ mkdir -p coverage
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
$ gcovr --exclude 'build/*' --exclude 'src/bench*' --html --html-details -o coverage/coverage.html

Benchmark
------------
Expand Down

0 comments on commit 98bed06

Please sign in to comment.