@@ -67,6 +67,12 @@ The following test suites are available, with links for more information:
6767- ` run-make-fulldeps ` — ` run-make ` tests which require a linkable build of ` rustc ` ,
6868 or the rust demangler
6969- [ ` run-pass-valgrind ` ] ( #valgrind-tests ) — tests run with Valgrind
70+ - [ ` coverage-map ` ] ( #coverage-tests ) - tests for coverage maps produced by
71+ coverage instrumentation
72+ - [ ` run-coverage ` ] ( #coverage-tests ) - tests that run an instrumented program
73+ and check its coverage report
74+ - [ ` run-coverage-rustdoc ` ] ( #coverage-tests ) - coverage tests that also run
75+ instrumented doctests
7076- [ Rustdoc tests] ( ../rustdoc.md#tests ) :
7177 - ` rustdoc ` — tests for rustdoc, making sure that the generated files
7278 contain the expected documentation.
@@ -394,6 +400,55 @@ These may be removed in the future.
394400[ `tests/run-pass-valgrind` ] : https://github.com/rust-lang/rust/tree/master/tests/run-pass-valgrind
395401
396402
403+ ### Coverage tests
404+
405+ The tests in [ ` tests/coverage-map ` ] test the mappings between source code
406+ regions and coverage counters that are emitted by LLVM.
407+ They compile the test with ` --emit=llvm-ir ` ,
408+ then use a custom tool ([ ` src/tools/coverage-dump ` ] )
409+ to extract and pretty-print the coverage mappings embedded in the IR.
410+ These tests don't require the profiler runtime, so they run in PR CI jobs and
411+ are easy to run/bless locally.
412+
413+ These coverage map tests can be sensitive to changes in MIR lowering or MIR
414+ optimizations, producing mappings that are different but produce identical
415+ coverage reports.
416+
417+ As a rule of thumb, any PR that doesn't change coverage-specific
418+ code should ** feel free to re-bless** the ` coverage-map ` tests as necessary,
419+ without worrying about the actual changes, as long as the ` run-coverage ` tests
420+ still pass.
421+
422+ ---
423+
424+ The tests in [ ` tests/run-coverage ` ] perform an end-to-end test of coverage reporting.
425+ They compile a test program with coverage instrumentation, run that program to
426+ produce raw coverage data, and then use LLVM tools to process that data into a
427+ human-readable code coverage report.
428+
429+ Instrumented binaries need to be linked against the LLVM profiler runtime,
430+ so ` run-coverage ` tests are ** automatically skipped**
431+ unless the profiler runtime is enabled in ` config.toml ` :
432+
433+ ``` toml
434+ # config.toml
435+ [build ]
436+ profiler = true
437+ ```
438+
439+ This also means that they typically don't run in PR CI jobs,
440+ though they do run in the full set of CI jobs used for merging.
441+
442+ The tests in [ ` tests/run-coverage-rustdoc ` ] also run instrumented doctests and
443+ include them in the coverage report. This avoids having to build rustdoc when
444+ only running the main ` run-coverage ` suite.
445+
446+ [ `tests/coverage-map` ] : https://github.com/rust-lang/rust/tree/master/tests/coverage-map
447+ [ `src/tools/coverage-dump` ] : https://github.com/rust-lang/rust/tree/master/src/tools/coverage-dump
448+ [ `tests/run-coverage` ] : https://github.com/rust-lang/rust/tree/master/tests/run-coverage
449+ [ `tests/run-coverage-rustdoc` ] : https://github.com/rust-lang/rust/tree/master/tests/run-coverage-rustdoc
450+
451+
397452## Building auxiliary crates
398453
399454It is common that some tests require additional auxiliary crates to be compiled.
0 commit comments