kosma / minmea

a lightweight GPS NMEA 0183 parser library in pure C
Do What The F*ck You Want To Public License
791 stars 253 forks source link

👨‍🏭 enable test coverage #39

Closed noahp closed 3 years ago

noahp commented 6 years ago

Add optional coverage output and if lcov is available, html report output.

Coverage is enabled if the env variable MINMEA_COVERAGE is set to 1.

Also add optional AddressSanitizer and UndefinedBehaviorSanitizer, only enabled if the env variable MINMEA_ASAN is set to 1.

Example:

MINMEA_COVERAGE=1 MINMEA_ASAN=1 make -j6
...
+++ Running lcov...
lcov --quiet --rc lcov_branch_coverage=1 --capture --directory ./ --output-file coverage.info
lcov --quiet --rc lcov_branch_coverage=1 --remove coverage.info "*test*" -o coverage_filtered.info
genhtml --branch-coverage coverage_filtered.info --output-directory coverage
Reading data file coverage_filtered.info
Found 2 entries.
Found common filename prefix "/home/noah/dev/github"
Writing .css and .png files.
Generating output.
Processing file minmea/minmea.h
Processing file minmea/minmea.c
Writing directory view page.
Overall coverage rate:
  lines......: 91.1% (318 of 349 lines)
  functions..: 100.0% (19 of 19 functions)
  branches...: 75.5% (241 of 319 branches)
See file://minmea/coverage/index.html for lcov results
+++ All good.
kosma commented 6 years ago

I like it, thanks! Just one more thing: can you describe this functionality in README.md? Othewise, it's gonna be lost knowledge.

kosma commented 6 years ago

PS. Travis-CI integration would be great as well, if you're willing to do it; if not - I can handle it myself.

noahp commented 6 years ago

Ah, looks like the sanitizers require more recent versions of gcc / clang than travis has by default, and coverage compiler flags and coverage report generation is different for gcc vs clang :upside_down_face: ...

Going to have to try a few rounds before I get this working in travis, stay tuned!

kosma commented 6 years ago

Ah, the wonders of configuring CI environments - especially ones you don't own... take your time - it takes a certain amount of stubbornness :)

noahp commented 6 years ago

I've added a docker build instead of using built in travis stuff, see what you think!

The build fails right now because it's attempting to upload to a nonexistent coveralls repo (https://travis-ci.org/kosma/minmea/builds/450285255#L1721). If the coverage upload is interesting to you, you'd need to enable the coveralls repo (tested here: https://coveralls.io/github/noahp/minmea) or we can just disable the coveralls upload too :smile: .

noahp commented 3 years ago

Old PR, abandoning!