- 1 year ago
Gcov doesn't generate .gcno files on windows
On Windows, the default behavior of gcov
is not to generate .gcno
files, which are necessary for generating code coverage reports. However, there are alternative options to collect code coverage information on Windows. One such option is using the gcovr
tool, which provides code coverage support on Windows.
Here's how you can use gcovr
to generate code coverage reports on Windows:
Install Python: Make sure you have Python installed on your Windows machine. You can download the latest version of Python from the official Python website (https://www.python.org/) and follow the installation instructions.
Install
gcovr
: Open a command prompt and use the following command to installgcovr
using pip, the Python package manager:pip install gcovr
Build your project: Use your preferred build system (such as CMake or Make) to build your project with code coverage support enabled. Make sure to include the appropriate compiler flags to generate the necessary coverage information.
Run your tests: Execute your tests or application to exercise the code paths you want to measure coverage for.
Generate code coverage report: Once your tests have completed, navigate to the project's build directory in the command prompt. Use the following command to generate a code coverage report using
gcovr
:cssgcovr -r <root_directory> --html -o coverage.html
Replace
<root_directory>
with the root directory of your project, where the.gcda
files are generated. This command generates an HTML report namedcoverage.html
in the current directory.Open the coverage report: Open the generated
coverage.html
file in a web browser to view the code coverage report.
By using gcovr
, you can generate code coverage reports on Windows without relying on the generation of .gcno
files by gcov
. The gcovr
tool analyzes the existing .gcda
files to generate the coverage report.
Note: gcovr
provides several options for customizing the coverage report output. Refer to the gcovr
documentation for more information on available options and their usage.