Skip to content

Commit 2710dcc

Browse files
committed
Add C coverage docs
1 parent 6f6aa73 commit 2710dcc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/development.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,39 @@ and IO errors are difficult to simulate in C.) Code coverage statistics are
737737
automatically tracked using [CodeCov](https://codecov.io/gh/tskit-dev/tskit/).
738738

739739

740+
### Viewing coverage reports
741+
742+
To generate and view coverage reports for the C tests locally:
743+
744+
Compile with coverage enabled:
745+
```bash
746+
$ cd c
747+
$ meson build -D b_coverage=true
748+
$ ninja -C build
749+
```
750+
751+
Run the tests:
752+
```bash
753+
$ ninja -C build test
754+
```
755+
756+
Generate coverage data:
757+
```bash
758+
$ cd build
759+
$ find ../tskit/*.c -type f -printf "%f\n" | xargs -i gcov -pb libtskit.a.p/tskit_{}.gcno ../tskit/{}
760+
```
761+
762+
The generated `.gcov` files can then be viewed directly with `cat filename.c.gcov`.
763+
Lines prefixed with `#####` were never executed, lines with numbers show execution counts, and lines with `-` are non-executable code.
764+
765+
`lcov` can be used to create browsable HTML coverage reports:
766+
```bash
767+
$ sudo apt-get install lcov # if needed
768+
$ lcov --capture --directory build-gcc --output-file coverage.info
769+
$ genhtml coverage.info --output-directory coverage_html
770+
$ firefox coverage_html/index.html
771+
```
772+
740773
### Coding conventions
741774

742775
The code is written using the [C99](https://en.wikipedia.org/wiki/C99) standard. All

0 commit comments

Comments
 (0)