Skip to content

Commit

Permalink
coverage: Register test::Coverage as the test suite for `tests/cove…
Browse files Browse the repository at this point in the history
…rage`

This restores the ability to run a coverage test by specifying its path, e.g.
`./x.py test tests/coverage/if.rs`. This runs the test in both modes.
  • Loading branch information
Zalathar committed Nov 7, 2023
1 parent 49127c6 commit 4e6f438
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ impl Step for Coverage {
const ONLY_HOSTS: bool = false;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.alias(Self::SUITE)
run.suite_path(Self::PATH)
}

fn make_run(run: RunConfig<'_>) {
Expand All @@ -1438,6 +1438,7 @@ impl Step for Coverage {
}
}

// Aliases for running the coverage tests in only one mode.
coverage_test_alias!(CoverageMap {
alias_and_mode: "coverage-map",
default: true,
Expand Down
17 changes: 10 additions & 7 deletions tests/coverage/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Many of these tests were copied from `tests/run-coverage` in order to
capture the current behavior of the instrumentor on non-trivial programs.
The actual mappings have not been closely inspected.
The tests in this directory are shared by two different test modes, and can be
run in multiple different ways:

- `./x.py test coverage-map` (compiles to LLVM IR and checks coverage mappings)
- `./x.py test run-coverage` (runs a test binary and checks its coverage report)
- `./x.py test coverage` (runs both `coverage-map` and `run-coverage`)

## Maintenance note

These tests can be sensitive to small changes in MIR spans or MIR control flow,
especially in HIR-to-MIR lowering or MIR optimizations.

If you haven't touched the coverage code directly, and the `run-coverage` test
suite still works, then it should usually be OK to just `--bless` these
coverage mapping tests as necessary, without worrying too much about the exact
changes.
If you haven't touched the coverage code directly, and the tests still pass in
`run-coverage` mode, then it should usually be OK to just re-bless the mappings
as necessary with `./x.py test coverage-map --bless`, without worrying too much
about the exact changes.

0 comments on commit 4e6f438

Please sign in to comment.