Skip to content

Add instructions on how to setup Code coverage to User Guide #20

Description

@mrparmesan01

Code coverage is really important to know which parts of your code has been tested and which part hasnt been tested.

The goal for this task is simply to just add these instructions to the webpage specifically in the User Guide section for ease.

Instructions for Creating a Code Coverage Report

Set Compiler Flags to Using Code Coverage

Note

I may implicitly add this to cmake-utils to implicitly add this to the CMake.

add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
add_link_options(-fprofile-instr-generate -fcoverage-mapping)

Edit environment variable

This for Windows, on Linux/Mac you would do the equivalent

$env:LLVM_PROFILE_FILE = "code_coverage.profraw"

Then run the executable.

Running the executable will generate the raw profile data for you. Then you can specify where that goes using the environment variable modification you did previously.

Convert the .prof raw data to .profdata

Using .profdata is used for processing the raw data into a report, merging that file into a more readable format. This is essentially how you'd might index it:

Tip

for llvm-toolchain, it would be /llvm-cov

<path>/llvm-profdata merge -sparse code_coverage.profraw -o code_coverage.profdata

Generating HTML Coverage Report

As soon you process the file, you should get something like code_coverage.profdata. Then you use the commands shown below.

To generate an HTML of the code coverage report that can be viewed in the browser.

<llvm-path>/llvm-cov show <exec-path>`
     -instr-profile=code_coverage.profdata `
     -show-line-counts-or-regions `
     -output-dir=coverage_report `
     -format=html `
     -ignore-filename-regex=".*conan.*

If this was to be executed for TheAtlasEngine editor, it would look like:

<llvm-path>/llvm-cov show .\build\Debug\editor\editor.exe `
     -instr-profile=code_coverage.profdata `
     -show-line-counts-or-regions `
     -output-dir=coverage_report `
     -format=html `
     -ignore-filename-regex=".*conan.*

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions