diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-29 16:36:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-29 16:36:31 +0200 |
| commit | f00db43e97dc9a4138686e5fca0fdb0be0775eed (patch) | |
| tree | a143c85fcfcc7d7af6f4882abc7586ee8c80dfe7 /tests/run-coverage/assert.coverage | |
| parent | 93a97c7a2a7d6ddcc40254331ce81f2fc1fe0790 (diff) | |
| parent | 7b4e75b98965f45dd35a31968d388c7deca997a2 (diff) | |
Rollup merge of #112300 - Zalathar:run-coverage, r=wesleywiser
Convert `run-make/coverage-reports` tests to use a custom compiletest mode I was frustrated by the fact that most of the coverage tests are glued together with makefiles and shell scripts, so I tried my hand at converting most of them over to a newly-implemented `run-coverage` mode/suite in compiletest. This ~~*mostly*~~ resolves #85009, ~~though I've left a small number of the existing tests as-is because they would require more work to fix/support~~. --- I had time to go back and add support for the more troublesome tests that I had initially skipped over, so this PR now manages to completely get rid of `run-make/coverage-reports`. --- The patches are arranged as follows: - Declare the new mode/suite in bootstrap - Small changes to compiletest that will be used by the new mode - Implement the new mode in compiletest - Migrate most of the tests over - Add more code to bootstrap and compiletest to support the remaining tests - Migrate the remaining tests (with some temporary hacks to avoid re-blessing them) - Remove the temporary hacks and re-bless the migrated tests - Remove the unused remnants of `run-make/coverage-reports`
Diffstat (limited to 'tests/run-coverage/assert.coverage')
| -rw-r--r-- | tests/run-coverage/assert.coverage | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/run-coverage/assert.coverage b/tests/run-coverage/assert.coverage new file mode 100644 index 00000000000..a7134a149e2 --- /dev/null +++ b/tests/run-coverage/assert.coverage @@ -0,0 +1,34 @@ + 1| |#![allow(unused_assignments)] + 2| |// failure-status: 101 + 3| | + 4| 4|fn might_fail_assert(one_plus_one: u32) { + 5| 4| println!("does 1 + 1 = {}?", one_plus_one); + 6| 4| assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); + ^1 + 7| 3|} + 8| | + 9| 1|fn main() -> Result<(),u8> { + 10| 1| let mut countdown = 10; + 11| 11| while countdown > 0 { + 12| 11| if countdown == 1 { + 13| 1| might_fail_assert(3); + 14| 10| } else if countdown < 5 { + 15| 3| might_fail_assert(2); + 16| 6| } + 17| 10| countdown -= 1; + 18| | } + 19| 0| Ok(()) + 20| 0|} + 21| | + 22| |// Notes: + 23| |// 1. Compare this program and its coverage results to those of the very similar test + 24| |// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`. + 25| |// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or + 26| |// related `assert_*!()` macro. + 27| |// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce + 28| |// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to + 29| |// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails). + 30| |// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test + 31| |// (and in many other coverage tests). The `Assert` terminator is typically generated by the + 32| |// Rust compiler to check for runtime failures, such as numeric overflows. + |
