11/14/2022 0 Comments Visual studio code coverage c++![]() ![]() If(CMAKE_BUILD_TYPE STREQUAL "coverage" OR CODE_COVERAGE) I work on Linux, so I haven’t found a real good tool for MSVC that really stood out unfortunately, but GCC and Clang both are common enough, and their requirements for programs can be checked for and appropriate flags added. So, when coverage tools are requested, the first determination to make is if a required compiler is found. The Clang-based tool can generate HTML output by itself using the llvm-cov tool, which is automatically part of the llvm toolset, where as to convert GCC’s coverage files into a nice readable/exportable HTML format requires two tools, lcov and genhtml, which are less commonly found. Now, while both GCC and Clang have code coverage capabilities, there is a difference between them. As a core buildĪnother option added, as was requested by some was the ability to just select coverage as the actual CMake build type, such as by -DCMAKE_BUILD_TYPE=coverage, where it builds automatically as a Release with it’s flags and the coverage hooked in, essentially the same as doing -DCMAKE_BUILD_TYPE=Release -DCODE_COVERAGE=ON. The first mode of inclusion, and the preferred way is to add an option, in this case named CODE_COVERAGE then, when selected to ON either via the command line with -DCODE_COVERAGE=ON or any CMake UI, will hook in the coverage support to whatever core build type is currently selected in CMake, whether Debug, Release, or any other. There are two main methods for creating a code-coverage build, the first is by specifying an option that hooks up the current build with the code coverage tools, and the second is a core build just for code coverage. ![]() The code coverage tools are pretty unique in that they can be linked into a build just by adding extra compiler flags. NOTE: The content here has been superseeded by a better implementation outlined here.Īfter the back of adding the basic clang tools, the ball began rolling to see what else could be integrated into the project infrastructure using CMake. JanuAdding C++ code coverage with CMake and GCC or ClangĬode coverage gives the ability to determine which sections of code are used, and how much, helping to prevent issues from sections of code that aren't run during tests and thus could potentially fail in production. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |