about summary refs log tree commit diff
path: root/tests/coverage
AgeCommit message (Collapse)AuthorLines
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
2024-03-20coverage: Remove incorrect assertions from counter allocationZalathar-2/+2
These assertions detect situations where a BCB node would have both a physical counter and one or more in-edge counters/expressions. For most BCBs that situation would indicate an implementation bug. However, it's perfectly fine in the case of a BCB having an edge that loops back to itself. Given the complexity and risk involved in fixing the assertions, and the fact that nothing relies on them actually being true, this patch just removes them instead.
2024-03-20coverage: Regression test for ICE triggered by self-loopsZalathar-0/+98
2024-03-14coverage: Enable branch coverage in the branch coverage testsZalathar-116/+272
2024-03-13coverage: Add branch coverage tests (with branch coverage disabled)Zalathar-0/+707
2024-03-13coverage: Remove all unstable values of `-Cinstrument-coverage`Zalathar-20/+10
2024-02-22[AUTO_GENERATED] Migrate compiletest to use `ui_test`-style `//@` directives许杰友 Jieyou Xu (Joe)-112/+112
2024-02-21coverage: Eagerly deduplicate covspans with the same spanZalathar-10/+8
2024-02-18Update coverage-run testsVadim Petrochenkov-5/+5
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-0/+20
2024-02-16coverage: Discard spans that fill the entire function bodyZalathar-29/+20
When we try to extract coverage-relevant spans from MIR, sometimes we see MIR statements/terminators whose spans cover the entire function body. Those spans tend to be unhelpful for coverage purposes, because they often represent compiler-inserted code, e.g. the implicit return value of `()`.
2024-02-16coverage: Regression test for a span extraction inconsistencyZalathar-0/+93
2024-02-09Enable by default.Camille GILLOT-178/+139
2024-02-05coverage: Make unexpansion of closure bodies more preciseZalathar-32/+48
This improves the coverage instrumentation of closures declared in macros, as seen in `closure_macro.rs` and `closure_macro_async.rs`.
2024-02-05coverage: Add a test for `#[coverage(..)]` on closuresZalathar-0/+119
2024-02-05coverage: Test for closure body that is a single bang-macroZalathar-0/+51
2024-02-02coverage: Use normal `edition:` headers in coverage testsZalathar-40/+40
Some of these tests were originally written as part of a custom `run-make` test, so at that time they weren't able to use the normal compiletest header directive parser. Now that they're properly integrated, there's no need for them to use `compile-flags` to specify the edition, since they can use `edition` instead.
2024-01-24Rollup merge of #120185 - Zalathar:auto-derived, r=wesleywiserLeón Orell Valerian Liehr-94/+4
coverage: Don't instrument `#[automatically_derived]` functions This PR makes the coverage instrumentor detect and skip functions that have [`#[automatically_derived]`](https://doc.rust-lang.org/reference/attributes/derive.html#the-automatically_derived-attribute) on their enclosing impl block. Most notably, this means that methods generated by built-in derives (e.g. `Clone`, `Debug`, `PartialEq`) are now ignored by coverage instrumentation, and won't appear as executed or not-executed in coverage reports. This is a noticeable change in user-visible behaviour, but overall I think it's a net improvement. For example, we've had a few user requests for this sort of change (e.g. #105055, https://github.com/rust-lang/rust/issues/84605#issuecomment-1902069040), and I believe it's the behaviour that most users will expect/prefer by default. It's possible to imagine situations where users would want to instrument these derived implementations, but I think it's OK to treat that as an opportunity to consider adding more fine-grained option flags to control the details of coverage instrumentation, while leaving this new behaviour as the default. (Also note that while `-Cinstrument-coverage` is a stable feature, the exact details of coverage instrumentation are allowed to change. So we *can* make this change; the main question is whether we *should*.) Fixes #105055.
2024-01-22coverage: Don't instrument `#[automatically_derived]` functionsZalathar-94/+4
2024-01-21Add `#[coverage(off)]` to closures introduced by `#[test]`/`#[bench]`Zalathar-18/+2
2024-01-21coverage: Add a test that uses `#[bench]`Zalathar-0/+33
2024-01-21Rollup merge of #120015 - Zalathar:format, r=dtolnayNadrieril-218/+282
coverage: Format all coverage tests with `rustfmt` As suggested by <https://github.com/rust-lang/rust/pull/119984#discussion_r1452856806>. Test files in `tests/` are normally ignored by `x fmt`, but sometimes those files end up being run through `rustfmt` anyway, either by `rust-analyzer` or by hand. When that happens, it's annoying to have to manually revert formatting changes that are unrelated to the actual changes being made. So it's helpful for the tests in the repository to already have standard formatting beforehand. However, there are several coverage tests that deliberately use non-standard formatting, so that line counts reveal more information about where code regions begin and end. In those cases, we can use `#[rustfmt::skip]` to prevent that code from being disturbed. ``@rustbot`` label +A-code-coverage
2024-01-18coverage: Format all remaining testsZalathar-54/+70
These tests can simply be reformatted as normal, because the resulting changes are unimportant.
2024-01-17Remove unnecessary `let`s and borrowing from `Waker::noop()` usage.Kevin Reid-16/+8
`Waker::noop()` now returns a `&'static Waker` reference, so it can be passed directly to `Context` creation with no temporary lifetime issue.
2024-01-16coverage: Tweak individual tests to be unaffected by `rustfmt`Zalathar-22/+34
Some of these tests use non-standard formatting that we can simulate by strategically adding `//` line comments. One contains `where` clauses that would be split across multiple lines, which we can keep on one line by moving the bounds to the generic type instead.
2024-01-16coverage: Add `#[rustfmt::skip]` to tests with non-standard formattingZalathar-142/+178
These tests deliberately use non-standard formatting, so that the line execution counts reported by `llvm-cov` reveal additional information about where code regions begin and end.
2024-01-08coverage: `llvm-cov` expects column numbers to be bytes, not code pointsZalathar-12/+52
2024-01-08coverage: Test for column numbers involving non-ASCII charactersZalathar-0/+89
2024-01-05Rollup merge of #119208 - Zalathar:hoist, r=WaffleLapkin,SwatinemMichael Goulet-27/+21
coverage: Hoist some complex code out of the main span refinement loop The span refinement loop in `spans.rs` takes the spans that have been extracted from MIR, and modifies them to produce more helpful output in coverage reports. It is also one of the most complicated pieces of code in the coverage instrumentor. It has an abundance of moving pieces that make it difficult to understand, and most attempts to modify it end up accidentally changing its behaviour in unacceptable ways. This PR nevertheless tries to make a dent in it by hoisting two pieces of special-case logic out of the main loop, and into separate preprocessing passes. Coverage tests show that the resulting mappings are *almost* identical, with all known differences being unimportant. This should hopefully unlock further simplifications to the refinement loop, since it now has fewer edge cases to worry about.
2024-01-05Allow coverage tests to enable `llvm-cov --use-color`Zalathar-0/+24
2024-01-05Allow tests to ignore individual test modesZalathar-0/+18
Normally, each test in `tests/coverage` is automatically run in both `coverage-map` mode and `coverage-run` mode. This new family of directives allows an individual test to specify that it should not be run in a particular mode.
2024-01-05coverage: Hoist the splitting of visible macro invocationsZalathar-24/+18
2024-01-05coverage: Overhaul how "visible macros" are determinedZalathar-3/+3
2024-01-04macro_rules: Less hacky heuristic for using `tt` metavariable spansVadim Petrochenkov-20/+7
2023-12-24Enable GVN by default.Camille GILLOT-12/+10
2023-12-20coverage: Add a test for `async` blocksZalathar-0/+104
We have coverage tests that use async functions, but none that use async blocks.
2023-12-18Rollup merge of #118852 - Zalathar:no-spans, r=cjgillotMatthias Krüger-0/+67
coverage: Skip instrumenting a function if no spans were extracted from MIR The immediate symptoms of #118643 were fixed by #118666, but some users reported that their builds now encounter another coverage-related ICE: ``` error: internal compiler error: compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs:98:17: A used function should have had coverage mapping data but did not: (...) ``` I was able to reproduce at least one cause of this error: if no relevant spans could be extracted from a function, but the function contains `CoverageKind::SpanMarker` statements, then codegen still thinks the function is instrumented and complains about the fact that it has no coverage spans. This PR prevents that from happening in two ways: - If we didn't extract any relevant spans from MIR, skip instrumenting the entire function and don't create a `FunctionCoverateInfo` for it. - If coverage codegen sees a `CoverageKind::SpanMarker` statement, skip it early and avoid creating `func_coverage`. --- Fixes #118850.
2023-12-16coverage: Regression test for `assert!(!false)`Zalathar-0/+39
2023-12-16coverage: Regression test for markers in a function with no spansZalathar-0/+67