To evaluate the current coverage of the library code, you need to install the tooling and configure the environment. This documentation is likely to be improved, but this information should be sufficient for basic use.
To generate a code coverage report, we use the python utility gcovr, which uses gcov from your build system.
In order for gcovr to work correctly, make sure that you can call gcov from the terminal or console of the OS.
If the utility is not available, add the folder in which it is located to the primary environments of your OS.
Next, you need to install python if you haven't already, as well as install the gcovr package with the command:
pip install gcovr
После установки, вам также необходимо убедиться, что gcovr стал доступен из терминала или консоли ОС.
Next, you need to configure the build system by adding the following required flags:
-DBDSP_BUILD_TESTS=ON -DINSTALL_GTEST=ON -DBDSP_BUILD_TYPE=Coverage
Please note that the second flag sets GTest, which speeds up the build and testing.
If you need to check the library coverage once, remove this flag.
If you use CLion like us, these flags are added to Settings>Build, Execution, Deployment>CMake>%Your Profile%>CMake options
In order to collect information about coverage, you first need to run GTest testing, during which the code execution of all library components will be analyzed.
Code execution data is saved in the gcno, gcda extension files in the project build folder, without them the report will be empty.
Next, you need to open the terminal and navigate to the root directory of the library.
For the convenience of storing the report, it is recommended to create a directory, for example - coverage.
The report is generated by the command (for the coverage folder):
gcovr --filter src --html-details coverage/coverage.html