about summary refs log tree commit diff
path: root/tests/coverage
AgeCommit message (Collapse)AuthorLines
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 `//`.
2024-05-14coverage: Simplify counter expressions using simple algebraZalathar-1305/+804
Some of these cases currently don't occur in practice, but are included for completeness, and to avoid having to add them later as branch coverage and MC/DC coverage start building more complex expressions.
2024-05-07Auto merge of #124223 - Zalathar:conditional-let, r=compiler-errorsbors-10/+34
coverage: Branch coverage support for let-else and if-let This PR adds branch coverage instrumentation for let-else and if-let, including let-chains. This lifts two of the limitations listed at #124118.
2024-05-03Auto merge of #123602 - cjgillot:gvn-borrowed, r=oli-obkbors-14/+14
Account for immutably borrowed locals in MIR copy-prop and GVN For the most part, we consider that immutably borrowed `Freeze` locals still fulfill SSA conditions. As the borrow is immutable, any use of the local will have the value given by the single assignment, and there can be no surprise. This allows copy-prop to merge a non-borrowed local with a borrowed local. We chose to keep copy-classes heads unborrowed, as those may be easier to optimize in later passes. This also allows to GVN the value behind an immutable borrow. If a SSA local is borrowed, dereferencing that borrow is equivalent to copying the local's value: re-executing the assignment between the borrow and the dereference would be UB. r? `@ghost` for perf
2024-04-30coverage: Add branch coverage support for if-let and let-chainsZalathar-7/+25
2024-04-30coverage: Add branch coverage support for let-elseZalathar-3/+9
2024-04-29Auto merge of #124255 - RenjiSann:renji/mcdc-nested-expressions, r=Zalatharbors-0/+506
MCDC coverage: support nested decision coverage #123409 provided the initial MCDC coverage implementation. As referenced in #124144, it does not currently support "nested" decisions, like the following example : ```rust fn nested_if_in_condition(a: bool, b: bool, c: bool) { if a && if b || c { true } else { false } { say("yes"); } else { say("no"); } } ``` Note that there is an if-expression (`if b || c ...`) embedded inside a boolean expression in the decision of an outer if-expression. This PR proposes a workaround for this cases, by introducing a Decision context stack, and by handing several `temporary condition bitmaps` instead of just one. When instrumenting boolean expressions, if the current node is a leaf condition (i.e. not a `||`/`&&` logical operator nor a `!` not operator), we insert a new decision context, such that if there are more boolean expressions inside the condition, they are handled as separate expressions. On the codegen LLVM side, we allocate as many `temp_cond_bitmap`s as necessary to handle the maximum encountered decision depth.
2024-04-29tests(mcdc-coverage): Add tests for nested decision structures in ↵Dorian Péron-0/+506
mcdc_nested_if.rs
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-16/+16
And suggest adding the `#[coroutine]` to the closure
2024-04-22coverage: Branch coverage tests for match armsZalathar-0/+401
2024-04-22coverage: Branch coverage test for if-let and let-chainsZalathar-0/+161
2024-04-22coverage: Branch coverage test for let-elseZalathar-0/+90
2024-04-20Rollup merge of #124053 - Zalathar:lazy-boolean, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-15/+385
coverage: Branch coverage tests for lazy boolean operators The current branch coverage implementation already supports the `&&` and `||` operators (even outside of an `if` condition), as a natural consequence of how they are desugared/lowered, but we didn't have any specific tests for them. This PR adds some appropriate tests. I've also moved the existing branch coverage tests into a `coverage/branch` subdirectory, so that they don't become unwieldy as I add more branch coverage tests. ``@rustbot`` label +A-code-coverage
2024-04-20Dereference immutable borrows in GVN.Camille GILLOT-14/+14
2024-04-20coverage. Add basic tests for MC/DCzhuyunxing-0/+583
2024-04-17coverage: Branch coverage tests for lazy boolean operatorsZalathar-0/+370
2024-04-17coverage: Move branch coverage tests into a subdirectoryZalathar-15/+15
2024-03-27Eliminate `UbCheck` for non-standard librariesDianQK-6/+6
2024-03-26coverage: Re-enable `UnreachablePropagation` for coverage buildsZalathar-3/+3