Files
servo/etc/coverage_workspace_wrapper.py
Jonathan Schwender 38d977343c Add code-coverage option to mach run, test-wpt and test-devtools (#39916)
Add a `--coverage` flag to `./mach build` and a `./mach coverage-report`
command to use `cargo llvm-cov` to generate a coverage report from the
raw profiles.

The workflow is: 
```
./mach build --coverage [--profile <cargo_profile>]
# Or test-wpt or test-devtools
./mach run --coverage [--profile <cargo_profile>]
# Note, that coverage-report needs to know the cargo build profile.
./mach coverage-report [--profile <cargo_profile>] [optional parameters for cargo-llvm-cov]
```
According to the LLVM documentation on source based coverage, the
optimization profile should not influence the accuracy of the coverage
profile, so we can gather coverage data from optimized builds.

Note that `./mach test-devtools --coverage` will not produce any
coverage profiles yet, since the test runner kills the servo binary,
which prevents writing the profile data at shutdown.
The same problem also affects `test-wpt` with `servodriver`, which will
be fixed by https://github.com/servo/servo/pull/40455.

Testing: Manually tested. A CI workflow to test wpt coverage will be
added in a follow-up PR.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-11-07 14:38:24 +00:00

1.1 KiB
Executable File