Support generation of code coverage data

Hi Ivan,

I searched for this kind of topic and didn’t find anything but let me know if this is a duplicate.

I have my Transition library being tested on Travis using my ArduinoFrameworkFake library which has been working well since you gave me directions on how to import the library.

I’d now like to gather some information regarding coverage so that I can identify areas where I am not testing my code sufficiently. I tried using the build_flags section in platformio.ini to pass --coverage but was met with a lot of linker errors that I tried (unsuccessfully) to resolve.
Here’s a few of the combinations of options I tried using
-g -O0 --coverage -fPIC -shared -Wl,-fprofile-generate -Wl,-shared -Wl,-fPIC
-fprofile-arcs -ftest-coverage -fprofile-generate -Wl,-lgcov --coverage

I am successfully generating coverage using: Transition/.travis.yml at master · r89m/Transition · GitHub
which is giving me the output I’d like (r89m/Transition | Job 19.1 (PLATFORMIO_CI_SRC=examples/LEDTransition/LEDTransition.ino) | Coveralls - Test Coverage History & Statistics) but I’d love to be able to do something along the lines of pio test --coverage or similar and generate the necessary gcno and gcda files.

Any help would be appreciated.



Please file a feature request here Issues · platformio/platformio-core · GitHub


1 Like