@@ -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,48 @@ 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 MIR.
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 must be linked against the LLVM profiler runtime,
430+ so they are automatically skipped (via the ` needs-profiler-runtime ` directive)
431+ unless ** ` profiler = true ` ** is set in the ` [build] ` section of ` config.toml ` .
432+ This also means that they typically don't run in PR CI jobs,
433+ only in the full CI job suite used for merging.
434+
435+ The tests in [ ` tests/run-coverage-rustdoc ` ] also run instrumented doctests and
436+ include them in the coverage report. This avoids having to build rustdoc when
437+ only running the main ` run-coverage ` suite.
438+
439+ [ `tests/coverage-map` ] : https://github.com/rust-lang/rust/tree/master/tests/coverage-map
440+ [ `src/tools/coverage-dump` ] : https://github.com/rust-lang/rust/tree/master/src/tools/coverage-dump
441+ [ `tests/run-coverage` ] : https://github.com/rust-lang/rust/tree/master/tests/run-coverage
442+ [ `tests/run-coverage-rustdoc` ] : https://github.com/rust-lang/rust/tree/master/tests/run-coverage-rustdoc
443+
444+
397445## Building auxiliary crates
398446
399447It is common that some tests require additional auxiliary crates to be compiled.
0 commit comments