about summary refs log tree commit diff
path: root/tests/coverage
AgeCommit message (Collapse)AuthorLines
2024-11-25comment out the old tests instead of adjusting themRalf Jung-103/+120
2024-11-24Coverage test for allowing coverage in a `#![no_core]` crateZalathar-0/+34
2024-11-08coverage: Restrict empty-span expansion to only cover `{` and `}`Zalathar-154/+152
2024-11-02coverage: Regression test for inlining into an uninstrumented crateZalathar-0/+32
2024-10-18Dont ICE when computing coverage of synthetic async closure bodyMichael Goulet-0/+95
2024-10-11coverage: Include the highest counter ID seen in `.cov-map` dumpsZalathar-0/+296
When making changes that have a large impact on coverage counter creation, this makes it easier to see whether the number of physical counters has changed. (The highest counter ID seen in coverage maps is not necessarily the same as the number of physical counters actually used by the instrumented code, but it's the best approximation we can get from looking only at the coverage maps, and it should be reasonably accurate in most cases.)
2024-10-11compiletest: Remove the magic hacks for finding output with `lto=thin`Zalathar-15/+0
This hack was intended to handle the case where `-Clto=thin` causes the compiler to emit multiple output files (when producing LLVM-IR or assembly). The hack only affects 4 tests, of which 3 are just meta-tests for the hack itself. The one remaining test that motivated the hack currently doesn't even need it! (`tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs`)
2024-10-08Simplify the directives for ignoring coverage-test modesZalathar-5/+5
2024-10-08coverage. Adapt to mcdc mapping formats introduced by llvm 19zhuyunxing-213/+107
2024-10-08coverage. Disable supporting mcdc on llvm-18zhuyunxing-10/+10
2024-10-05fix GVN trying to transmute pointers to integersRalf Jung-8/+8
2024-09-18Update the minimum external LLVM to 18Josh Stone-52/+42
2024-09-10coverage: Extract `executor::block_on` from several async coverage testsZalathar-277/+142
By moving `block_on` to an auxiliary crate, we avoid having to keep a separate copy of it in every async test. (This also incorporates some small tweaks to the headers in `await_ready.rs`.)
2024-09-06coverage: Treat await similar to a macroJonathan Conder-37/+30
Currently `await` is only counted towards coverage if the containing function is suspended and resumed at least once. This is because it expands to code which contains a branch on the discriminant of `Poll`. By treating it like a branching macro (e.g. `assert!`), these implementation details will be hidden from the coverage results.
2024-09-06coverage: Add test to codify existing behaviorJonathan Conder-0/+101
Currently `await` is only counted towards coverage if the containing function is suspended and resumed at least once. A future commit will fix this and update the test to reflect the new behavior.
2024-08-01Finish blessing `coverage/mcdc` tests after LLVM 19 upgradeZalathar-0/+5
2024-07-30Bless coverage/mcdc for line number changesJosh Stone-42/+42
2024-07-30Disable MC/DC tests on LLVM 19Krasimir Georgiev-0/+5
Disable the tests and generate an error if MC/DC is used on LLVM 19. The support will be ported separately, as it is substantially different on LLVM 19, and there are no plans to support both versions.
2024-07-13Bless coverage.Camille GILLOT-7/+9
2024-07-13Create mapped places upon seeing them in the body.Camille GILLOT-85/+114
2024-07-09coverage. Fix panic when generating mcdc code for inlined functionszhuyunxing-0/+79
2024-07-09coverage. MCDC tests also report branches coveragezhuyunxing-6/+78
2024-07-09coverage. Group mcdc tests in one directoryzhuyunxing-18/+18
2024-07-08coverage: Extract hole spans from HIR instead of MIRZalathar-136/+109
This makes it possible to treat more kinds of nested item/code as holes, instead of being restricted to closures.
2024-07-08coverage: Test for handling of nested item spansZalathar-0/+179
2024-06-28Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJungMatthias Krüger-10/+10
core: avoid `extern type`s in formatting infrastructure ```@RalfJung``` [said](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Use.20of.20.60extern.20type.60.20in.20formatting.20machinery/near/446552837): >How attached are y'all to using `extern type` in the formatting machinery? Seems like this was introduced a [long time ago](https://github.com/rust-lang/rust/commit/34ef8f5441d5335c4177abd622383ed34a6e9315). However, it's also [not really compatible with Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/issues/256), and only works currently because we effectively treat references-to-extern-type almost like raw pointers in Stacked Borrows -- which of course is unsound, it's not how LLVM works. I was planning to make Miri emit a warning when this happens to avoid cases like [this](https://github.com/rust-lang/rust/issues/126814#issuecomment-2183816373) where people use extern type specifically to silence Miri without realizing what happens. but with the formatting machinery using extern type, this warning would just show up everywhere... > > The "proper" way to do this in Stacked Borrows is to use raw pointers (or `NonNull`). This PR does just that. r? ```@RalfJung```
2024-06-27Rollup merge of #126721 - Zalathar:nested-cov-attr, r=oli-obkJacob Pratt-152/+255
coverage: Make `#[coverage(..)]` apply recursively to nested functions This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to. Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value. --- Fixes #126625.
2024-06-26coverage: Allow `#[coverage(..)]` on `impl` and `mod`Zalathar-0/+206
These attributes apply to all enclosed functions/methods/closures, unless explicitly overridden by another coverage attribute.
2024-06-26coverage: Apply `#[coverage(..)]` recursively to nested functionsZalathar-152/+49
2024-06-26update coverage testjoboet-10/+10
2024-06-22Update coverage maps in testsScott McMurray-8/+8
2024-06-20I'd never even heard of a coverage mapScott McMurray-8/+8
2024-06-20Auto merge of #116088 - nbdd0121:unwind, r=Amanieu,RalfJungbors-6/+4
Stabilise `c_unwind` Fix #74990 Fix #115285 (that's also where FCP is happening) Marking as draft PR for now due to `compiler_builtins` issues r? `@Amanieu`
2024-06-19Remove c_unwind from tests and fix testsGary Guo-6/+4
2024-06-19Rollup merge of #125766 - RenjiSann:fresh-mcdc-branch-on-bool, r=nnethercoteLeón Orell Valerian Liehr-0/+478
MCDC Coverage: instrument last boolean RHS operands from condition coverage Fresh PR from #124652 -- This PR ensures that the top-level boolean expressions that are not part of the control flow are correctly instrumented thanks to condition coverage. See discussion on https://github.com/rust-lang/rust/issues/124120. Depends on `@Zalathar` 's condition coverage implementation #125756.
2024-06-19tests(coverage): Bless mcdc_non_control_flow testsDorian Péron-38/+147
2024-06-18Rollup merge of #126621 - Zalathar:test-coverage-attr, r=petrochenkovGuillaume Gomez-0/+468
More thorough status-quo tests for `#[coverage(..)]` In light of the stabilization push at https://github.com/rust-lang/rust/issues/84605#issuecomment-2166514660, I have written some tests to more thoroughly capture the current behaviour of the `#[coverage(..)]` attribute. These tests aim to capture the *current* behaviour, which is not necessarily the desired behaviour. For example, some of the error message are not great, some things that perhaps ought to cause an error do not, and recursive coverage attributes have not been implemented yet. `@rustbot` label +A-code-coverage
2024-06-18Add more thorough coverage tests for `#[coverage(..)]` in nested functionsZalathar-0/+468
These tests reflect the current implementation behaviour, which is not necessarily the desired behaviour.
2024-06-17coverage: Add debugging flag `-Zcoverage-options=no-mir-spans`Zalathar-0/+191
When set, this flag skips the code that normally extracts coverage spans from MIR statements and terminators. That sometimes makes it easier to debug branch coverage and MC/DC coverage, because the coverage output is less noisy. For internal debugging only. If other code changes would make it hard to keep supporting this flag, remove it.
2024-06-12coverage: Replace the old span refiner with a single functionZalathar-4/+4
As more and more of the span refiner's functionality has been pulled out into separate early passes, it has finally reached the point where we can remove the rest of the old `SpansRefiner` code, and replace it with a single modestly-sized function.
2024-06-12coverage: Add `tests/coverage/loop-break.rs`Zalathar-0/+41
This is a modified copy of `tests/mir-opt/coverage/instrument_coverage.rs`.
2024-06-12coverage: Add `tests/coverage/assert-ne.rs`Zalathar-0/+58
This test extracts a fragment of `issue-84561.rs` that has historically proven troublesome when trying to modify how spans are extracted from MIR.
2024-06-05tests(coverage): Add mcdc_non_control_flow testsDorian Péron-0/+369
2024-06-04coverage: Use hole spans to carve up coverage spans into separate bucketsZalathar-10/+6
This performs the same task as the hole-carving code in the main span refiner, but in a separate earlier pass.
2024-05-30coverage: Instrument the RHS value of lazy logical operatorsZalathar-45/+85
When a lazy logical operator (`&&` or `||`) occurs outside of an `if` condition, it normally doesn't have any associated control-flow branch, so we don't have an existing way to track whether it was true or false. This patch adds special code to handle this case, by inserting extra MIR blocks in a diamond shape after evaluating the RHS. This gives us a place to insert the appropriate marker statements, which can then be given their own counters.
2024-05-30coverage: Add a test for `-Zcoverage-options=condition`Dorian Péron-0/+274
2024-05-29Rollup merge of #125700 - Zalathar:limit-overflow, r=nnethercoteMatthias Krüger-0/+270
coverage: Avoid overflow when the MC/DC condition limit is exceeded Fix for the test failure seen in https://github.com/rust-lang/rust/pull/124571#issuecomment-2099620869. If we perform this subtraction first, it can sometimes overflow to -1 before the addition can bring its value back to 0. That behaviour seems to be benign, but it nevertheless causes test failures in compiler configurations that check for overflow. ``@rustbot`` label +A-code-coverage
2024-05-29coverage: Add tests for the MC/DC condition limitZalathar-0/+270
2024-05-29Manually run `x fmt` on all source files in `tests/coverage/`Zalathar-44/+34
Currently we can't automatically enforce formatting on tests (see #125637), but we can at least keep things relatively tidy by occasionally running the formatter manually. This was done by temporarily commenting out the `"/tests/"` exclusion in `rustfmt.toml`, and then running `x fmt tests/coverage` and `x test coverage --bless`.
2024-05-29Tweak various coverage test files for slightly nicer formattingZalathar-58/+54
For coverage tests, splitting code across multiple lines often makes the resulting coverage report easier to interpret, so we force rustfmt to retain line breaks by adding dummy line comments with `//`.