Skip to content

Commit 5a06a5d

Browse files
committed
cmake, doc: Document test coverage using CMake-based build system
1 parent ba60234 commit 5a06a5d

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,31 @@ Test coverage
122122

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

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

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

129-
Run the tests:
129+
```
130+
$ ./configure --enable-coverage
131+
$ make check
132+
```
130133

131-
$ make check
134+
* using CMake-based build system:
135+
136+
```
137+
$ cmake --preset coverage -S . -B build
138+
$ cmake --build build
139+
$ ctest --test-dir build
140+
```
132141

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

135-
$ gcovr --exclude 'src/bench*' --print-summary
144+
$ gcovr --exclude 'build/*' --exclude 'src/bench*' --print-summary
136145

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

139148
$ mkdir -p coverage
140-
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
149+
$ gcovr --exclude 'build/*' --exclude 'src/bench*' --html --html-details -o coverage/coverage.html
141150

142151
Benchmark
143152
------------

0 commit comments

Comments
 (0)