From 7f8a6de72c1ddf25775da648dc42198847ca0a23 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 26 Oct 2023 21:34:49 +1100 Subject: [PATCH 01/11] coverage: Use `-Copt-level=2` by default in run-coverage tests This is a step towards being able to unify the two coverage test directories. There are two tests that require adjustment: - `overflow.rs` requires an explicit `-Coverflow-checks=yes` - `sort_groups.rs` is sensitive to provably unused instantiations --- src/tools/compiletest/src/runtest.rs | 4 +-- .../coverage-map/status-quo/overflow.cov-map | 8 ++--- tests/coverage-map/status-quo/overflow.rs | 1 + .../status-quo/sort_groups.cov-map | 29 ++++++++++++++----- tests/coverage-map/status-quo/sort_groups.rs | 2 +- tests/run-coverage/overflow.coverage | 1 + tests/run-coverage/overflow.rs | 1 + tests/run-coverage/sort_groups.coverage | 2 +- tests/run-coverage/sort_groups.rs | 2 +- 9 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index e74d66a859926..4c6f46ef0dcee 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2481,9 +2481,9 @@ impl<'test> TestCx<'test> { RunCoverage => { rustc.arg("-Cinstrument-coverage"); // Coverage reports are sometimes sensitive to optimizations, - // and the current snapshots assume no optimization unless + // and the current snapshots assume `opt-level=2` unless // overridden by `compile-flags`. - rustc.arg("-Copt-level=0"); + rustc.arg("-Copt-level=2"); } RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake | CodegenUnits | JsDocTest | Assembly => { diff --git a/tests/coverage-map/status-quo/overflow.cov-map b/tests/coverage-map/status-quo/overflow.cov-map index bfffd9b2ab515..39a5c05f879ad 100644 --- a/tests/coverage-map/status-quo/overflow.cov-map +++ b/tests/coverage-map/status-quo/overflow.cov-map @@ -1,5 +1,5 @@ Function name: overflow::main -Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 0f, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] +Raw bytes (65): 0x[01, 01, 08, 01, 1b, 05, 1f, 09, 0d, 03, 11, 16, 05, 03, 11, 05, 1f, 09, 0d, 09, 01, 10, 01, 01, 1b, 03, 02, 0b, 00, 18, 16, 01, 0c, 00, 1a, 05, 00, 1b, 03, 0a, 12, 03, 13, 00, 20, 09, 00, 21, 03, 0a, 0d, 03, 0a, 00, 0b, 1b, 01, 09, 00, 17, 11, 02, 05, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 8 @@ -12,7 +12,7 @@ Number of expressions: 8 - expression 6 operands: lhs = Counter(1), rhs = Expression(7, Add) - expression 7 operands: lhs = Counter(2), rhs = Counter(3) Number of file 0 mappings: 9 -- Code(Counter(0)) at (prev + 15, 1) to (start + 1, 27) +- Code(Counter(0)) at (prev + 16, 1) to (start + 1, 27) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 24) = (c0 + (c1 + (c2 + c3))) - Code(Expression(5, Sub)) at (prev + 1, 12) to (start + 0, 26) @@ -27,14 +27,14 @@ Number of file 0 mappings: 9 - Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2) Function name: overflow::might_overflow -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 04, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 05, 01, 01, 12, 05, 01, 13, 02, 06, 02, 02, 06, 00, 07, 07, 01, 09, 05, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 4, 1) to (start + 1, 18) +- Code(Counter(0)) at (prev + 5, 1) to (start + 1, 18) - Code(Counter(1)) at (prev + 1, 19) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) = (c0 - c1) diff --git a/tests/coverage-map/status-quo/overflow.rs b/tests/coverage-map/status-quo/overflow.rs index bbb65c1b35df6..1c40771b27478 100644 --- a/tests/coverage-map/status-quo/overflow.rs +++ b/tests/coverage-map/status-quo/overflow.rs @@ -1,4 +1,5 @@ #![allow(unused_assignments)] +// compile-flags: -Coverflow-checks=yes // failure-status: 101 fn might_overflow(to_add: u32) -> u32 { diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/status-quo/sort_groups.cov-map index db027f3dc3249..3cbda6fbe1ab8 100644 --- a/tests/coverage-map/status-quo/sort_groups.cov-map +++ b/tests/coverage-map/status-quo/sort_groups.cov-map @@ -28,6 +28,21 @@ Number of file 0 mappings: 4 - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) = (c1 + (c0 - c1)) +Function name: sort_groups::generic_fn:: +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 17, 1) to (start + 1, 12) +- Code(Counter(1)) at (prev + 1, 13) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) + = (c1 + (c0 - c1)) + Function name: sort_groups::generic_fn:: Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 11, 01, 01, 0c, 05, 01, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 01, 00, 02] Number of files: 1 @@ -44,19 +59,19 @@ Number of file 0 mappings: 4 = (c1 + (c0 - c1)) Function name: sort_groups::main -Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 23, 05, 04, 24, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 6, 1) to (start + 4, 13) -- Code(Zero) at (prev + 4, 14) to (start + 2, 6) +- Code(Counter(0)) at (prev + 6, 1) to (start + 4, 35) +- Code(Counter(1)) at (prev + 4, 36) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) - = (c0 - Zero) + = (c0 - c1) - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2) - = (Zero + (c0 - Zero)) + = (c1 + (c0 - c1)) Function name: sort_groups::other_fn Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11] diff --git a/tests/coverage-map/status-quo/sort_groups.rs b/tests/coverage-map/status-quo/sort_groups.rs index f89f9f3ec61fa..5adbbc6a87d1f 100644 --- a/tests/coverage-map/status-quo/sort_groups.rs +++ b/tests/coverage-map/status-quo/sort_groups.rs @@ -7,7 +7,7 @@ fn main() { let cond = std::env::args().len() > 1; generic_fn::<()>(cond); generic_fn::<&'static str>(!cond); - if false { + if std::hint::black_box(false) { generic_fn::(cond); } generic_fn::(cond); diff --git a/tests/run-coverage/overflow.coverage b/tests/run-coverage/overflow.coverage index cee076e88cd43..4f8dffc0c4814 100644 --- a/tests/run-coverage/overflow.coverage +++ b/tests/run-coverage/overflow.coverage @@ -1,4 +1,5 @@ LL| |#![allow(unused_assignments)] + LL| |// compile-flags: -Coverflow-checks=yes LL| |// failure-status: 101 LL| | LL| 4|fn might_overflow(to_add: u32) -> u32 { diff --git a/tests/run-coverage/overflow.rs b/tests/run-coverage/overflow.rs index bbb65c1b35df6..1c40771b27478 100644 --- a/tests/run-coverage/overflow.rs +++ b/tests/run-coverage/overflow.rs @@ -1,4 +1,5 @@ #![allow(unused_assignments)] +// compile-flags: -Coverflow-checks=yes // failure-status: 101 fn might_overflow(to_add: u32) -> u32 { diff --git a/tests/run-coverage/sort_groups.coverage b/tests/run-coverage/sort_groups.coverage index 8733bf48a9c8d..c70d7b3b28253 100644 --- a/tests/run-coverage/sort_groups.coverage +++ b/tests/run-coverage/sort_groups.coverage @@ -7,7 +7,7 @@ LL| 1| let cond = std::env::args().len() > 1; LL| 1| generic_fn::<()>(cond); LL| 1| generic_fn::<&'static str>(!cond); - LL| 1| if false { + LL| 1| if std::hint::black_box(false) { LL| 0| generic_fn::(cond); LL| 1| } LL| 1| generic_fn::(cond); diff --git a/tests/run-coverage/sort_groups.rs b/tests/run-coverage/sort_groups.rs index f89f9f3ec61fa..5adbbc6a87d1f 100644 --- a/tests/run-coverage/sort_groups.rs +++ b/tests/run-coverage/sort_groups.rs @@ -7,7 +7,7 @@ fn main() { let cond = std::env::args().len() > 1; generic_fn::<()>(cond); generic_fn::<&'static str>(!cond); - if false { + if std::hint::black_box(false) { generic_fn::(cond); } generic_fn::(cond); From 8eef39f0825f03629373e430063f331149da6d37 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 28 Oct 2023 21:20:32 +1100 Subject: [PATCH 02/11] coverage: Remove `tests/coverage-map/if.rs` There is another test named `if.rs` in `tests/coverage-map/status-quo/`, so this test stands in the way of flattening that directory into its parent. Fortunately both tests are more-or-less equivalent, so removing this one is fine. --- tests/coverage-map/if.cov-map | 15 --------------- tests/coverage-map/if.rs | 9 --------- 2 files changed, 24 deletions(-) delete mode 100644 tests/coverage-map/if.cov-map delete mode 100644 tests/coverage-map/if.rs diff --git a/tests/coverage-map/if.cov-map b/tests/coverage-map/if.cov-map deleted file mode 100644 index 3cedb5ffbecb1..0000000000000 --- a/tests/coverage-map/if.cov-map +++ /dev/null @@ -1,15 +0,0 @@ -Function name: if::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 03, 01, 02, 0c, 05, 02, 0d, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 01, 02] -Number of files: 1 -- file 0 => global file 1 -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) -Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 3, 1) to (start + 2, 12) -- Code(Counter(1)) at (prev + 2, 13) to (start + 2, 6) -- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) - = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 1, 2) - = (c1 + (c0 - c1)) - diff --git a/tests/coverage-map/if.rs b/tests/coverage-map/if.rs deleted file mode 100644 index ed3f69bdc98d2..0000000000000 --- a/tests/coverage-map/if.rs +++ /dev/null @@ -1,9 +0,0 @@ -// compile-flags: --edition=2021 - -fn main() { - let cond = std::env::args().len() == 1; - if cond { - println!("true"); - } - println!("done"); -} From f5df56b26b5a9c46299e74591602940c0e48b08c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 28 Oct 2023 21:23:23 +1100 Subject: [PATCH 03/11] coverage: Flatten `coverage-map/status-quo/` into its parent directory --- tests/coverage-map/README.md | 2 +- tests/coverage-map/{status-quo => }/abort.cov-map | 0 tests/coverage-map/{status-quo => }/abort.rs | 0 tests/coverage-map/{status-quo => }/assert.cov-map | 0 tests/coverage-map/{status-quo => }/assert.rs | 0 tests/coverage-map/{status-quo => }/async.cov-map | 0 tests/coverage-map/{status-quo => }/async.rs | 0 tests/coverage-map/{status-quo => }/async2.cov-map | 0 tests/coverage-map/{status-quo => }/async2.rs | 0 tests/coverage-map/{status-quo => }/bad_counter_ids.cov-map | 0 tests/coverage-map/{status-quo => }/bad_counter_ids.rs | 0 tests/coverage-map/{status-quo => }/closure.cov-map | 0 tests/coverage-map/{status-quo => }/closure.rs | 0 tests/coverage-map/{status-quo => }/closure_bug.cov-map | 0 tests/coverage-map/{status-quo => }/closure_bug.rs | 0 tests/coverage-map/{status-quo => }/closure_macro.cov-map | 0 tests/coverage-map/{status-quo => }/closure_macro.rs | 0 tests/coverage-map/{status-quo => }/closure_macro_async.cov-map | 0 tests/coverage-map/{status-quo => }/closure_macro_async.rs | 0 tests/coverage-map/{status-quo => }/conditions.cov-map | 0 tests/coverage-map/{status-quo => }/conditions.rs | 0 tests/coverage-map/{status-quo => }/continue.cov-map | 0 tests/coverage-map/{status-quo => }/continue.rs | 0 tests/coverage-map/{status-quo => }/coroutine.cov-map | 0 tests/coverage-map/{status-quo => }/coroutine.rs | 0 tests/coverage-map/{status-quo => }/dead_code.cov-map | 0 tests/coverage-map/{status-quo => }/dead_code.rs | 0 tests/coverage-map/{status-quo => }/drop_trait.cov-map | 0 tests/coverage-map/{status-quo => }/drop_trait.rs | 0 tests/coverage-map/{status-quo => }/generics.cov-map | 0 tests/coverage-map/{status-quo => }/generics.rs | 0 tests/coverage-map/{status-quo => }/if.cov-map | 0 tests/coverage-map/{status-quo => }/if.rs | 0 tests/coverage-map/{status-quo => }/if_else.cov-map | 0 tests/coverage-map/{status-quo => }/if_else.rs | 0 tests/coverage-map/{status-quo => }/inline-dead.cov-map | 0 tests/coverage-map/{status-quo => }/inline-dead.rs | 0 tests/coverage-map/{status-quo => }/inline.cov-map | 0 tests/coverage-map/{status-quo => }/inline.rs | 0 tests/coverage-map/{status-quo => }/inner_items.cov-map | 0 tests/coverage-map/{status-quo => }/inner_items.rs | 0 tests/coverage-map/{status-quo => }/issue-83601.cov-map | 0 tests/coverage-map/{status-quo => }/issue-83601.rs | 0 tests/coverage-map/{status-quo => }/issue-84561.cov-map | 0 tests/coverage-map/{status-quo => }/issue-84561.rs | 0 tests/coverage-map/{status-quo => }/issue-93054.cov-map | 0 tests/coverage-map/{status-quo => }/issue-93054.rs | 0 tests/coverage-map/{status-quo => }/lazy_boolean.cov-map | 0 tests/coverage-map/{status-quo => }/lazy_boolean.rs | 0 tests/coverage-map/{status-quo => }/loop_break_value.cov-map | 0 tests/coverage-map/{status-quo => }/loop_break_value.rs | 0 tests/coverage-map/{status-quo => }/loops_branches.cov-map | 0 tests/coverage-map/{status-quo => }/loops_branches.rs | 0 tests/coverage-map/{status-quo => }/match_or_pattern.cov-map | 0 tests/coverage-map/{status-quo => }/match_or_pattern.rs | 0 tests/coverage-map/{status-quo => }/nested_loops.cov-map | 0 tests/coverage-map/{status-quo => }/nested_loops.rs | 0 tests/coverage-map/{status-quo => }/no_cov_crate.cov-map | 0 tests/coverage-map/{status-quo => }/no_cov_crate.rs | 0 tests/coverage-map/{status-quo => }/overflow.cov-map | 0 tests/coverage-map/{status-quo => }/overflow.rs | 0 tests/coverage-map/{status-quo => }/panic_unwind.cov-map | 0 tests/coverage-map/{status-quo => }/panic_unwind.rs | 0 tests/coverage-map/{status-quo => }/partial_eq.cov-map | 0 tests/coverage-map/{status-quo => }/partial_eq.rs | 0 tests/coverage-map/{status-quo => }/simple_loop.cov-map | 0 tests/coverage-map/{status-quo => }/simple_loop.rs | 0 tests/coverage-map/{status-quo => }/simple_match.cov-map | 0 tests/coverage-map/{status-quo => }/simple_match.rs | 0 tests/coverage-map/{status-quo => }/sort_groups.cov-map | 0 tests/coverage-map/{status-quo => }/sort_groups.rs | 0 tests/coverage-map/{status-quo => }/test_harness.cov-map | 0 tests/coverage-map/{status-quo => }/test_harness.rs | 0 tests/coverage-map/{status-quo => }/tight_inf_loop.cov-map | 0 tests/coverage-map/{status-quo => }/tight_inf_loop.rs | 0 tests/coverage-map/{status-quo => }/try_error_result.cov-map | 0 tests/coverage-map/{status-quo => }/try_error_result.rs | 0 tests/coverage-map/{status-quo => }/unused.cov-map | 0 tests/coverage-map/{status-quo => }/unused.rs | 0 tests/coverage-map/{status-quo => }/while.cov-map | 0 tests/coverage-map/{status-quo => }/while.rs | 0 tests/coverage-map/{status-quo => }/while_early_ret.cov-map | 0 tests/coverage-map/{status-quo => }/while_early_ret.rs | 0 tests/coverage-map/{status-quo => }/yield.cov-map | 0 tests/coverage-map/{status-quo => }/yield.rs | 0 85 files changed, 1 insertion(+), 1 deletion(-) rename tests/coverage-map/{status-quo => }/abort.cov-map (100%) rename tests/coverage-map/{status-quo => }/abort.rs (100%) rename tests/coverage-map/{status-quo => }/assert.cov-map (100%) rename tests/coverage-map/{status-quo => }/assert.rs (100%) rename tests/coverage-map/{status-quo => }/async.cov-map (100%) rename tests/coverage-map/{status-quo => }/async.rs (100%) rename tests/coverage-map/{status-quo => }/async2.cov-map (100%) rename tests/coverage-map/{status-quo => }/async2.rs (100%) rename tests/coverage-map/{status-quo => }/bad_counter_ids.cov-map (100%) rename tests/coverage-map/{status-quo => }/bad_counter_ids.rs (100%) rename tests/coverage-map/{status-quo => }/closure.cov-map (100%) rename tests/coverage-map/{status-quo => }/closure.rs (100%) rename tests/coverage-map/{status-quo => }/closure_bug.cov-map (100%) rename tests/coverage-map/{status-quo => }/closure_bug.rs (100%) rename tests/coverage-map/{status-quo => }/closure_macro.cov-map (100%) rename tests/coverage-map/{status-quo => }/closure_macro.rs (100%) rename tests/coverage-map/{status-quo => }/closure_macro_async.cov-map (100%) rename tests/coverage-map/{status-quo => }/closure_macro_async.rs (100%) rename tests/coverage-map/{status-quo => }/conditions.cov-map (100%) rename tests/coverage-map/{status-quo => }/conditions.rs (100%) rename tests/coverage-map/{status-quo => }/continue.cov-map (100%) rename tests/coverage-map/{status-quo => }/continue.rs (100%) rename tests/coverage-map/{status-quo => }/coroutine.cov-map (100%) rename tests/coverage-map/{status-quo => }/coroutine.rs (100%) rename tests/coverage-map/{status-quo => }/dead_code.cov-map (100%) rename tests/coverage-map/{status-quo => }/dead_code.rs (100%) rename tests/coverage-map/{status-quo => }/drop_trait.cov-map (100%) rename tests/coverage-map/{status-quo => }/drop_trait.rs (100%) rename tests/coverage-map/{status-quo => }/generics.cov-map (100%) rename tests/coverage-map/{status-quo => }/generics.rs (100%) rename tests/coverage-map/{status-quo => }/if.cov-map (100%) rename tests/coverage-map/{status-quo => }/if.rs (100%) rename tests/coverage-map/{status-quo => }/if_else.cov-map (100%) rename tests/coverage-map/{status-quo => }/if_else.rs (100%) rename tests/coverage-map/{status-quo => }/inline-dead.cov-map (100%) rename tests/coverage-map/{status-quo => }/inline-dead.rs (100%) rename tests/coverage-map/{status-quo => }/inline.cov-map (100%) rename tests/coverage-map/{status-quo => }/inline.rs (100%) rename tests/coverage-map/{status-quo => }/inner_items.cov-map (100%) rename tests/coverage-map/{status-quo => }/inner_items.rs (100%) rename tests/coverage-map/{status-quo => }/issue-83601.cov-map (100%) rename tests/coverage-map/{status-quo => }/issue-83601.rs (100%) rename tests/coverage-map/{status-quo => }/issue-84561.cov-map (100%) rename tests/coverage-map/{status-quo => }/issue-84561.rs (100%) rename tests/coverage-map/{status-quo => }/issue-93054.cov-map (100%) rename tests/coverage-map/{status-quo => }/issue-93054.rs (100%) rename tests/coverage-map/{status-quo => }/lazy_boolean.cov-map (100%) rename tests/coverage-map/{status-quo => }/lazy_boolean.rs (100%) rename tests/coverage-map/{status-quo => }/loop_break_value.cov-map (100%) rename tests/coverage-map/{status-quo => }/loop_break_value.rs (100%) rename tests/coverage-map/{status-quo => }/loops_branches.cov-map (100%) rename tests/coverage-map/{status-quo => }/loops_branches.rs (100%) rename tests/coverage-map/{status-quo => }/match_or_pattern.cov-map (100%) rename tests/coverage-map/{status-quo => }/match_or_pattern.rs (100%) rename tests/coverage-map/{status-quo => }/nested_loops.cov-map (100%) rename tests/coverage-map/{status-quo => }/nested_loops.rs (100%) rename tests/coverage-map/{status-quo => }/no_cov_crate.cov-map (100%) rename tests/coverage-map/{status-quo => }/no_cov_crate.rs (100%) rename tests/coverage-map/{status-quo => }/overflow.cov-map (100%) rename tests/coverage-map/{status-quo => }/overflow.rs (100%) rename tests/coverage-map/{status-quo => }/panic_unwind.cov-map (100%) rename tests/coverage-map/{status-quo => }/panic_unwind.rs (100%) rename tests/coverage-map/{status-quo => }/partial_eq.cov-map (100%) rename tests/coverage-map/{status-quo => }/partial_eq.rs (100%) rename tests/coverage-map/{status-quo => }/simple_loop.cov-map (100%) rename tests/coverage-map/{status-quo => }/simple_loop.rs (100%) rename tests/coverage-map/{status-quo => }/simple_match.cov-map (100%) rename tests/coverage-map/{status-quo => }/simple_match.rs (100%) rename tests/coverage-map/{status-quo => }/sort_groups.cov-map (100%) rename tests/coverage-map/{status-quo => }/sort_groups.rs (100%) rename tests/coverage-map/{status-quo => }/test_harness.cov-map (100%) rename tests/coverage-map/{status-quo => }/test_harness.rs (100%) rename tests/coverage-map/{status-quo => }/tight_inf_loop.cov-map (100%) rename tests/coverage-map/{status-quo => }/tight_inf_loop.rs (100%) rename tests/coverage-map/{status-quo => }/try_error_result.cov-map (100%) rename tests/coverage-map/{status-quo => }/try_error_result.rs (100%) rename tests/coverage-map/{status-quo => }/unused.cov-map (100%) rename tests/coverage-map/{status-quo => }/unused.rs (100%) rename tests/coverage-map/{status-quo => }/while.cov-map (100%) rename tests/coverage-map/{status-quo => }/while.rs (100%) rename tests/coverage-map/{status-quo => }/while_early_ret.cov-map (100%) rename tests/coverage-map/{status-quo => }/while_early_ret.rs (100%) rename tests/coverage-map/{status-quo => }/yield.cov-map (100%) rename tests/coverage-map/{status-quo => }/yield.rs (100%) diff --git a/tests/coverage-map/README.md b/tests/coverage-map/README.md index 60d1352cd64f1..146fbff5b204d 100644 --- a/tests/coverage-map/README.md +++ b/tests/coverage-map/README.md @@ -1,4 +1,4 @@ -The tests in `./status-quo` were copied from `tests/run-coverage` in order to +Many of these tests were copied from `tests/run-coverage` in order to capture the current behavior of the instrumentor on non-trivial programs. The actual mappings have not been closely inspected. diff --git a/tests/coverage-map/status-quo/abort.cov-map b/tests/coverage-map/abort.cov-map similarity index 100% rename from tests/coverage-map/status-quo/abort.cov-map rename to tests/coverage-map/abort.cov-map diff --git a/tests/coverage-map/status-quo/abort.rs b/tests/coverage-map/abort.rs similarity index 100% rename from tests/coverage-map/status-quo/abort.rs rename to tests/coverage-map/abort.rs diff --git a/tests/coverage-map/status-quo/assert.cov-map b/tests/coverage-map/assert.cov-map similarity index 100% rename from tests/coverage-map/status-quo/assert.cov-map rename to tests/coverage-map/assert.cov-map diff --git a/tests/coverage-map/status-quo/assert.rs b/tests/coverage-map/assert.rs similarity index 100% rename from tests/coverage-map/status-quo/assert.rs rename to tests/coverage-map/assert.rs diff --git a/tests/coverage-map/status-quo/async.cov-map b/tests/coverage-map/async.cov-map similarity index 100% rename from tests/coverage-map/status-quo/async.cov-map rename to tests/coverage-map/async.cov-map diff --git a/tests/coverage-map/status-quo/async.rs b/tests/coverage-map/async.rs similarity index 100% rename from tests/coverage-map/status-quo/async.rs rename to tests/coverage-map/async.rs diff --git a/tests/coverage-map/status-quo/async2.cov-map b/tests/coverage-map/async2.cov-map similarity index 100% rename from tests/coverage-map/status-quo/async2.cov-map rename to tests/coverage-map/async2.cov-map diff --git a/tests/coverage-map/status-quo/async2.rs b/tests/coverage-map/async2.rs similarity index 100% rename from tests/coverage-map/status-quo/async2.rs rename to tests/coverage-map/async2.rs diff --git a/tests/coverage-map/status-quo/bad_counter_ids.cov-map b/tests/coverage-map/bad_counter_ids.cov-map similarity index 100% rename from tests/coverage-map/status-quo/bad_counter_ids.cov-map rename to tests/coverage-map/bad_counter_ids.cov-map diff --git a/tests/coverage-map/status-quo/bad_counter_ids.rs b/tests/coverage-map/bad_counter_ids.rs similarity index 100% rename from tests/coverage-map/status-quo/bad_counter_ids.rs rename to tests/coverage-map/bad_counter_ids.rs diff --git a/tests/coverage-map/status-quo/closure.cov-map b/tests/coverage-map/closure.cov-map similarity index 100% rename from tests/coverage-map/status-quo/closure.cov-map rename to tests/coverage-map/closure.cov-map diff --git a/tests/coverage-map/status-quo/closure.rs b/tests/coverage-map/closure.rs similarity index 100% rename from tests/coverage-map/status-quo/closure.rs rename to tests/coverage-map/closure.rs diff --git a/tests/coverage-map/status-quo/closure_bug.cov-map b/tests/coverage-map/closure_bug.cov-map similarity index 100% rename from tests/coverage-map/status-quo/closure_bug.cov-map rename to tests/coverage-map/closure_bug.cov-map diff --git a/tests/coverage-map/status-quo/closure_bug.rs b/tests/coverage-map/closure_bug.rs similarity index 100% rename from tests/coverage-map/status-quo/closure_bug.rs rename to tests/coverage-map/closure_bug.rs diff --git a/tests/coverage-map/status-quo/closure_macro.cov-map b/tests/coverage-map/closure_macro.cov-map similarity index 100% rename from tests/coverage-map/status-quo/closure_macro.cov-map rename to tests/coverage-map/closure_macro.cov-map diff --git a/tests/coverage-map/status-quo/closure_macro.rs b/tests/coverage-map/closure_macro.rs similarity index 100% rename from tests/coverage-map/status-quo/closure_macro.rs rename to tests/coverage-map/closure_macro.rs diff --git a/tests/coverage-map/status-quo/closure_macro_async.cov-map b/tests/coverage-map/closure_macro_async.cov-map similarity index 100% rename from tests/coverage-map/status-quo/closure_macro_async.cov-map rename to tests/coverage-map/closure_macro_async.cov-map diff --git a/tests/coverage-map/status-quo/closure_macro_async.rs b/tests/coverage-map/closure_macro_async.rs similarity index 100% rename from tests/coverage-map/status-quo/closure_macro_async.rs rename to tests/coverage-map/closure_macro_async.rs diff --git a/tests/coverage-map/status-quo/conditions.cov-map b/tests/coverage-map/conditions.cov-map similarity index 100% rename from tests/coverage-map/status-quo/conditions.cov-map rename to tests/coverage-map/conditions.cov-map diff --git a/tests/coverage-map/status-quo/conditions.rs b/tests/coverage-map/conditions.rs similarity index 100% rename from tests/coverage-map/status-quo/conditions.rs rename to tests/coverage-map/conditions.rs diff --git a/tests/coverage-map/status-quo/continue.cov-map b/tests/coverage-map/continue.cov-map similarity index 100% rename from tests/coverage-map/status-quo/continue.cov-map rename to tests/coverage-map/continue.cov-map diff --git a/tests/coverage-map/status-quo/continue.rs b/tests/coverage-map/continue.rs similarity index 100% rename from tests/coverage-map/status-quo/continue.rs rename to tests/coverage-map/continue.rs diff --git a/tests/coverage-map/status-quo/coroutine.cov-map b/tests/coverage-map/coroutine.cov-map similarity index 100% rename from tests/coverage-map/status-quo/coroutine.cov-map rename to tests/coverage-map/coroutine.cov-map diff --git a/tests/coverage-map/status-quo/coroutine.rs b/tests/coverage-map/coroutine.rs similarity index 100% rename from tests/coverage-map/status-quo/coroutine.rs rename to tests/coverage-map/coroutine.rs diff --git a/tests/coverage-map/status-quo/dead_code.cov-map b/tests/coverage-map/dead_code.cov-map similarity index 100% rename from tests/coverage-map/status-quo/dead_code.cov-map rename to tests/coverage-map/dead_code.cov-map diff --git a/tests/coverage-map/status-quo/dead_code.rs b/tests/coverage-map/dead_code.rs similarity index 100% rename from tests/coverage-map/status-quo/dead_code.rs rename to tests/coverage-map/dead_code.rs diff --git a/tests/coverage-map/status-quo/drop_trait.cov-map b/tests/coverage-map/drop_trait.cov-map similarity index 100% rename from tests/coverage-map/status-quo/drop_trait.cov-map rename to tests/coverage-map/drop_trait.cov-map diff --git a/tests/coverage-map/status-quo/drop_trait.rs b/tests/coverage-map/drop_trait.rs similarity index 100% rename from tests/coverage-map/status-quo/drop_trait.rs rename to tests/coverage-map/drop_trait.rs diff --git a/tests/coverage-map/status-quo/generics.cov-map b/tests/coverage-map/generics.cov-map similarity index 100% rename from tests/coverage-map/status-quo/generics.cov-map rename to tests/coverage-map/generics.cov-map diff --git a/tests/coverage-map/status-quo/generics.rs b/tests/coverage-map/generics.rs similarity index 100% rename from tests/coverage-map/status-quo/generics.rs rename to tests/coverage-map/generics.rs diff --git a/tests/coverage-map/status-quo/if.cov-map b/tests/coverage-map/if.cov-map similarity index 100% rename from tests/coverage-map/status-quo/if.cov-map rename to tests/coverage-map/if.cov-map diff --git a/tests/coverage-map/status-quo/if.rs b/tests/coverage-map/if.rs similarity index 100% rename from tests/coverage-map/status-quo/if.rs rename to tests/coverage-map/if.rs diff --git a/tests/coverage-map/status-quo/if_else.cov-map b/tests/coverage-map/if_else.cov-map similarity index 100% rename from tests/coverage-map/status-quo/if_else.cov-map rename to tests/coverage-map/if_else.cov-map diff --git a/tests/coverage-map/status-quo/if_else.rs b/tests/coverage-map/if_else.rs similarity index 100% rename from tests/coverage-map/status-quo/if_else.rs rename to tests/coverage-map/if_else.rs diff --git a/tests/coverage-map/status-quo/inline-dead.cov-map b/tests/coverage-map/inline-dead.cov-map similarity index 100% rename from tests/coverage-map/status-quo/inline-dead.cov-map rename to tests/coverage-map/inline-dead.cov-map diff --git a/tests/coverage-map/status-quo/inline-dead.rs b/tests/coverage-map/inline-dead.rs similarity index 100% rename from tests/coverage-map/status-quo/inline-dead.rs rename to tests/coverage-map/inline-dead.rs diff --git a/tests/coverage-map/status-quo/inline.cov-map b/tests/coverage-map/inline.cov-map similarity index 100% rename from tests/coverage-map/status-quo/inline.cov-map rename to tests/coverage-map/inline.cov-map diff --git a/tests/coverage-map/status-quo/inline.rs b/tests/coverage-map/inline.rs similarity index 100% rename from tests/coverage-map/status-quo/inline.rs rename to tests/coverage-map/inline.rs diff --git a/tests/coverage-map/status-quo/inner_items.cov-map b/tests/coverage-map/inner_items.cov-map similarity index 100% rename from tests/coverage-map/status-quo/inner_items.cov-map rename to tests/coverage-map/inner_items.cov-map diff --git a/tests/coverage-map/status-quo/inner_items.rs b/tests/coverage-map/inner_items.rs similarity index 100% rename from tests/coverage-map/status-quo/inner_items.rs rename to tests/coverage-map/inner_items.rs diff --git a/tests/coverage-map/status-quo/issue-83601.cov-map b/tests/coverage-map/issue-83601.cov-map similarity index 100% rename from tests/coverage-map/status-quo/issue-83601.cov-map rename to tests/coverage-map/issue-83601.cov-map diff --git a/tests/coverage-map/status-quo/issue-83601.rs b/tests/coverage-map/issue-83601.rs similarity index 100% rename from tests/coverage-map/status-quo/issue-83601.rs rename to tests/coverage-map/issue-83601.rs diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/issue-84561.cov-map similarity index 100% rename from tests/coverage-map/status-quo/issue-84561.cov-map rename to tests/coverage-map/issue-84561.cov-map diff --git a/tests/coverage-map/status-quo/issue-84561.rs b/tests/coverage-map/issue-84561.rs similarity index 100% rename from tests/coverage-map/status-quo/issue-84561.rs rename to tests/coverage-map/issue-84561.rs diff --git a/tests/coverage-map/status-quo/issue-93054.cov-map b/tests/coverage-map/issue-93054.cov-map similarity index 100% rename from tests/coverage-map/status-quo/issue-93054.cov-map rename to tests/coverage-map/issue-93054.cov-map diff --git a/tests/coverage-map/status-quo/issue-93054.rs b/tests/coverage-map/issue-93054.rs similarity index 100% rename from tests/coverage-map/status-quo/issue-93054.rs rename to tests/coverage-map/issue-93054.rs diff --git a/tests/coverage-map/status-quo/lazy_boolean.cov-map b/tests/coverage-map/lazy_boolean.cov-map similarity index 100% rename from tests/coverage-map/status-quo/lazy_boolean.cov-map rename to tests/coverage-map/lazy_boolean.cov-map diff --git a/tests/coverage-map/status-quo/lazy_boolean.rs b/tests/coverage-map/lazy_boolean.rs similarity index 100% rename from tests/coverage-map/status-quo/lazy_boolean.rs rename to tests/coverage-map/lazy_boolean.rs diff --git a/tests/coverage-map/status-quo/loop_break_value.cov-map b/tests/coverage-map/loop_break_value.cov-map similarity index 100% rename from tests/coverage-map/status-quo/loop_break_value.cov-map rename to tests/coverage-map/loop_break_value.cov-map diff --git a/tests/coverage-map/status-quo/loop_break_value.rs b/tests/coverage-map/loop_break_value.rs similarity index 100% rename from tests/coverage-map/status-quo/loop_break_value.rs rename to tests/coverage-map/loop_break_value.rs diff --git a/tests/coverage-map/status-quo/loops_branches.cov-map b/tests/coverage-map/loops_branches.cov-map similarity index 100% rename from tests/coverage-map/status-quo/loops_branches.cov-map rename to tests/coverage-map/loops_branches.cov-map diff --git a/tests/coverage-map/status-quo/loops_branches.rs b/tests/coverage-map/loops_branches.rs similarity index 100% rename from tests/coverage-map/status-quo/loops_branches.rs rename to tests/coverage-map/loops_branches.rs diff --git a/tests/coverage-map/status-quo/match_or_pattern.cov-map b/tests/coverage-map/match_or_pattern.cov-map similarity index 100% rename from tests/coverage-map/status-quo/match_or_pattern.cov-map rename to tests/coverage-map/match_or_pattern.cov-map diff --git a/tests/coverage-map/status-quo/match_or_pattern.rs b/tests/coverage-map/match_or_pattern.rs similarity index 100% rename from tests/coverage-map/status-quo/match_or_pattern.rs rename to tests/coverage-map/match_or_pattern.rs diff --git a/tests/coverage-map/status-quo/nested_loops.cov-map b/tests/coverage-map/nested_loops.cov-map similarity index 100% rename from tests/coverage-map/status-quo/nested_loops.cov-map rename to tests/coverage-map/nested_loops.cov-map diff --git a/tests/coverage-map/status-quo/nested_loops.rs b/tests/coverage-map/nested_loops.rs similarity index 100% rename from tests/coverage-map/status-quo/nested_loops.rs rename to tests/coverage-map/nested_loops.rs diff --git a/tests/coverage-map/status-quo/no_cov_crate.cov-map b/tests/coverage-map/no_cov_crate.cov-map similarity index 100% rename from tests/coverage-map/status-quo/no_cov_crate.cov-map rename to tests/coverage-map/no_cov_crate.cov-map diff --git a/tests/coverage-map/status-quo/no_cov_crate.rs b/tests/coverage-map/no_cov_crate.rs similarity index 100% rename from tests/coverage-map/status-quo/no_cov_crate.rs rename to tests/coverage-map/no_cov_crate.rs diff --git a/tests/coverage-map/status-quo/overflow.cov-map b/tests/coverage-map/overflow.cov-map similarity index 100% rename from tests/coverage-map/status-quo/overflow.cov-map rename to tests/coverage-map/overflow.cov-map diff --git a/tests/coverage-map/status-quo/overflow.rs b/tests/coverage-map/overflow.rs similarity index 100% rename from tests/coverage-map/status-quo/overflow.rs rename to tests/coverage-map/overflow.rs diff --git a/tests/coverage-map/status-quo/panic_unwind.cov-map b/tests/coverage-map/panic_unwind.cov-map similarity index 100% rename from tests/coverage-map/status-quo/panic_unwind.cov-map rename to tests/coverage-map/panic_unwind.cov-map diff --git a/tests/coverage-map/status-quo/panic_unwind.rs b/tests/coverage-map/panic_unwind.rs similarity index 100% rename from tests/coverage-map/status-quo/panic_unwind.rs rename to tests/coverage-map/panic_unwind.rs diff --git a/tests/coverage-map/status-quo/partial_eq.cov-map b/tests/coverage-map/partial_eq.cov-map similarity index 100% rename from tests/coverage-map/status-quo/partial_eq.cov-map rename to tests/coverage-map/partial_eq.cov-map diff --git a/tests/coverage-map/status-quo/partial_eq.rs b/tests/coverage-map/partial_eq.rs similarity index 100% rename from tests/coverage-map/status-quo/partial_eq.rs rename to tests/coverage-map/partial_eq.rs diff --git a/tests/coverage-map/status-quo/simple_loop.cov-map b/tests/coverage-map/simple_loop.cov-map similarity index 100% rename from tests/coverage-map/status-quo/simple_loop.cov-map rename to tests/coverage-map/simple_loop.cov-map diff --git a/tests/coverage-map/status-quo/simple_loop.rs b/tests/coverage-map/simple_loop.rs similarity index 100% rename from tests/coverage-map/status-quo/simple_loop.rs rename to tests/coverage-map/simple_loop.rs diff --git a/tests/coverage-map/status-quo/simple_match.cov-map b/tests/coverage-map/simple_match.cov-map similarity index 100% rename from tests/coverage-map/status-quo/simple_match.cov-map rename to tests/coverage-map/simple_match.cov-map diff --git a/tests/coverage-map/status-quo/simple_match.rs b/tests/coverage-map/simple_match.rs similarity index 100% rename from tests/coverage-map/status-quo/simple_match.rs rename to tests/coverage-map/simple_match.rs diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/sort_groups.cov-map similarity index 100% rename from tests/coverage-map/status-quo/sort_groups.cov-map rename to tests/coverage-map/sort_groups.cov-map diff --git a/tests/coverage-map/status-quo/sort_groups.rs b/tests/coverage-map/sort_groups.rs similarity index 100% rename from tests/coverage-map/status-quo/sort_groups.rs rename to tests/coverage-map/sort_groups.rs diff --git a/tests/coverage-map/status-quo/test_harness.cov-map b/tests/coverage-map/test_harness.cov-map similarity index 100% rename from tests/coverage-map/status-quo/test_harness.cov-map rename to tests/coverage-map/test_harness.cov-map diff --git a/tests/coverage-map/status-quo/test_harness.rs b/tests/coverage-map/test_harness.rs similarity index 100% rename from tests/coverage-map/status-quo/test_harness.rs rename to tests/coverage-map/test_harness.rs diff --git a/tests/coverage-map/status-quo/tight_inf_loop.cov-map b/tests/coverage-map/tight_inf_loop.cov-map similarity index 100% rename from tests/coverage-map/status-quo/tight_inf_loop.cov-map rename to tests/coverage-map/tight_inf_loop.cov-map diff --git a/tests/coverage-map/status-quo/tight_inf_loop.rs b/tests/coverage-map/tight_inf_loop.rs similarity index 100% rename from tests/coverage-map/status-quo/tight_inf_loop.rs rename to tests/coverage-map/tight_inf_loop.rs diff --git a/tests/coverage-map/status-quo/try_error_result.cov-map b/tests/coverage-map/try_error_result.cov-map similarity index 100% rename from tests/coverage-map/status-quo/try_error_result.cov-map rename to tests/coverage-map/try_error_result.cov-map diff --git a/tests/coverage-map/status-quo/try_error_result.rs b/tests/coverage-map/try_error_result.rs similarity index 100% rename from tests/coverage-map/status-quo/try_error_result.rs rename to tests/coverage-map/try_error_result.rs diff --git a/tests/coverage-map/status-quo/unused.cov-map b/tests/coverage-map/unused.cov-map similarity index 100% rename from tests/coverage-map/status-quo/unused.cov-map rename to tests/coverage-map/unused.cov-map diff --git a/tests/coverage-map/status-quo/unused.rs b/tests/coverage-map/unused.rs similarity index 100% rename from tests/coverage-map/status-quo/unused.rs rename to tests/coverage-map/unused.rs diff --git a/tests/coverage-map/status-quo/while.cov-map b/tests/coverage-map/while.cov-map similarity index 100% rename from tests/coverage-map/status-quo/while.cov-map rename to tests/coverage-map/while.cov-map diff --git a/tests/coverage-map/status-quo/while.rs b/tests/coverage-map/while.rs similarity index 100% rename from tests/coverage-map/status-quo/while.rs rename to tests/coverage-map/while.rs diff --git a/tests/coverage-map/status-quo/while_early_ret.cov-map b/tests/coverage-map/while_early_ret.cov-map similarity index 100% rename from tests/coverage-map/status-quo/while_early_ret.cov-map rename to tests/coverage-map/while_early_ret.cov-map diff --git a/tests/coverage-map/status-quo/while_early_ret.rs b/tests/coverage-map/while_early_ret.rs similarity index 100% rename from tests/coverage-map/status-quo/while_early_ret.rs rename to tests/coverage-map/while_early_ret.rs diff --git a/tests/coverage-map/status-quo/yield.cov-map b/tests/coverage-map/yield.cov-map similarity index 100% rename from tests/coverage-map/status-quo/yield.cov-map rename to tests/coverage-map/yield.cov-map diff --git a/tests/coverage-map/status-quo/yield.rs b/tests/coverage-map/yield.rs similarity index 100% rename from tests/coverage-map/status-quo/yield.rs rename to tests/coverage-map/yield.rs From 4b76b97bc8c7a9bf4e9d9e43f02c03b2dce23a57 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 28 Oct 2023 21:27:23 +1100 Subject: [PATCH 04/11] coverage: Copy all remaining coverage-map tests into run-coverage --- tests/run-coverage/long_and_wide.coverage | 151 ++++++++++++++++++++++ tests/run-coverage/long_and_wide.rs | 150 +++++++++++++++++++++ tests/run-coverage/trivial.coverage | 4 + tests/run-coverage/trivial.rs | 3 + 4 files changed, 308 insertions(+) create mode 100644 tests/run-coverage/long_and_wide.coverage create mode 100644 tests/run-coverage/long_and_wide.rs create mode 100644 tests/run-coverage/trivial.coverage create mode 100644 tests/run-coverage/trivial.rs diff --git a/tests/run-coverage/long_and_wide.coverage b/tests/run-coverage/long_and_wide.coverage new file mode 100644 index 0000000000000..d7d29ca40cddd --- /dev/null +++ b/tests/run-coverage/long_and_wide.coverage @@ -0,0 +1,151 @@ + LL| |// compile-flags: --edition=2021 + LL| |// ignore-tidy-linelength + LL| | + LL| |// This file deliberately contains line and column numbers larger than 127, + LL| |// to verify that `coverage-dump`'s ULEB128 parser can handle them. + LL| | + LL| 1|fn main() { + LL| 1| wide_function(); + LL| 1| long_function(); + LL| 1| far_function(); + LL| 1|} + LL| | + LL| |#[rustfmt::skip] + LL| 1|fn wide_function() { /* */ (); } + LL| | + LL| 1|fn long_function() { + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1| // + LL| 1|} + LL| | + LL| 1|fn far_function() {} + diff --git a/tests/run-coverage/long_and_wide.rs b/tests/run-coverage/long_and_wide.rs new file mode 100644 index 0000000000000..a7cbcd4802791 --- /dev/null +++ b/tests/run-coverage/long_and_wide.rs @@ -0,0 +1,150 @@ +// compile-flags: --edition=2021 +// ignore-tidy-linelength + +// This file deliberately contains line and column numbers larger than 127, +// to verify that `coverage-dump`'s ULEB128 parser can handle them. + +fn main() { + wide_function(); + long_function(); + far_function(); +} + +#[rustfmt::skip] +fn wide_function() { /* */ (); } + +fn long_function() { + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // +} + +fn far_function() {} diff --git a/tests/run-coverage/trivial.coverage b/tests/run-coverage/trivial.coverage new file mode 100644 index 0000000000000..4f417979ef97d --- /dev/null +++ b/tests/run-coverage/trivial.coverage @@ -0,0 +1,4 @@ + LL| |// compile-flags: --edition=2021 + LL| | + LL| 1|fn main() {} + diff --git a/tests/run-coverage/trivial.rs b/tests/run-coverage/trivial.rs new file mode 100644 index 0000000000000..d0a9b44fb3605 --- /dev/null +++ b/tests/run-coverage/trivial.rs @@ -0,0 +1,3 @@ +// compile-flags: --edition=2021 + +fn main() {} From 211d4cee8eb0ef2e3dcf5426c143cecce76570cb Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 28 Oct 2023 21:29:37 +1100 Subject: [PATCH 05/11] coverage: Copy all remaining run-coverage tests into coverage-map These multi-file tests were not copied over in #114843 because they weren't working, but it turns out that they just need the correct crate-type. --- src/tools/compiletest/src/runtest.rs | 2 +- .../auxiliary/inline_always_with_dead_code.rs | 22 ++++ .../auxiliary/unused_mod_helper.rs | 4 + tests/coverage-map/auxiliary/used_crate.rs | 103 ++++++++++++++++++ .../auxiliary/used_inline_crate.rs | 85 +++++++++++++++ tests/coverage-map/issue-85461.cov-map | 8 ++ tests/coverage-map/issue-85461.rs | 11 ++ tests/coverage-map/unused_mod.cov-map | 16 +++ tests/coverage-map/unused_mod.rs | 6 + tests/coverage-map/uses_crate.cov-map | 40 +++++++ tests/coverage-map/uses_crate.rs | 19 ++++ tests/coverage-map/uses_inline_crate.cov-map | 55 ++++++++++ tests/coverage-map/uses_inline_crate.rs | 22 ++++ 13 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 tests/coverage-map/auxiliary/inline_always_with_dead_code.rs create mode 100644 tests/coverage-map/auxiliary/unused_mod_helper.rs create mode 100644 tests/coverage-map/auxiliary/used_crate.rs create mode 100644 tests/coverage-map/auxiliary/used_inline_crate.rs create mode 100644 tests/coverage-map/issue-85461.cov-map create mode 100644 tests/coverage-map/issue-85461.rs create mode 100644 tests/coverage-map/unused_mod.cov-map create mode 100644 tests/coverage-map/unused_mod.rs create mode 100644 tests/coverage-map/uses_crate.cov-map create mode 100644 tests/coverage-map/uses_crate.rs create mode 100644 tests/coverage-map/uses_inline_crate.cov-map create mode 100644 tests/coverage-map/uses_inline_crate.rs diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4c6f46ef0dcee..c9bc858b8e918 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2193,7 +2193,7 @@ impl<'test> TestCx<'test> { || self.is_vxworks_pure_static() || self.config.target.contains("bpf") || !self.config.target_cfg().dynamic_linking - || self.config.mode == RunCoverage + || matches!(self.config.mode, CoverageMap | RunCoverage) { // We primarily compile all auxiliary libraries as dynamic libraries // to avoid code size bloat and large binaries as much as possible diff --git a/tests/coverage-map/auxiliary/inline_always_with_dead_code.rs b/tests/coverage-map/auxiliary/inline_always_with_dead_code.rs new file mode 100644 index 0000000000000..9dc50dae25ae2 --- /dev/null +++ b/tests/coverage-map/auxiliary/inline_always_with_dead_code.rs @@ -0,0 +1,22 @@ +// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0 + +#![allow(dead_code)] + +mod foo { + #[inline(always)] + pub fn called() {} + + fn uncalled() {} +} + +pub mod bar { + pub fn call_me() { + super::foo::called(); + } +} + +pub mod baz { + pub fn call_me() { + super::foo::called(); + } +} diff --git a/tests/coverage-map/auxiliary/unused_mod_helper.rs b/tests/coverage-map/auxiliary/unused_mod_helper.rs new file mode 100644 index 0000000000000..88c5dac65cb50 --- /dev/null +++ b/tests/coverage-map/auxiliary/unused_mod_helper.rs @@ -0,0 +1,4 @@ +#[allow(dead_code)] +pub fn never_called_function() { + println!("I am never called"); +} diff --git a/tests/coverage-map/auxiliary/used_crate.rs b/tests/coverage-map/auxiliary/used_crate.rs new file mode 100644 index 0000000000000..c086ef21e1a9f --- /dev/null +++ b/tests/coverage-map/auxiliary/used_crate.rs @@ -0,0 +1,103 @@ +#![allow(unused_assignments, unused_variables)] +// Verify that coverage works with optimizations: +// compile-flags: -C opt-level=3 + +use std::fmt::Debug; + +pub fn used_function() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + let mut countdown = 0; + if is_true { + countdown = 10; + } + use_this_lib_crate(); +} + +pub fn used_only_from_bin_crate_generic_function(arg: T) { + println!("used_only_from_bin_crate_generic_function with {:?}", arg); +} +// Expect for above function: `Unexecuted instantiation` (see below) +pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); +} + +pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); +} + +pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); +} + +pub fn unused_generic_function(arg: T) { + println!("unused_generic_function with {:?}", arg); +} + +pub fn unused_function() { + let is_true = std::env::args().len() == 1; + let mut countdown = 2; + if !is_true { + countdown = 20; + } +} + +#[allow(dead_code)] +fn unused_private_function() { + let is_true = std::env::args().len() == 1; + let mut countdown = 2; + if !is_true { + countdown = 20; + } +} + +fn use_this_lib_crate() { + used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); + used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + "used from library used_crate.rs", + ); + let some_vec = vec![5, 6, 7, 8]; + used_only_from_this_lib_crate_generic_function(some_vec); + used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); +} + +// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results, +// for example: +// +// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> +// +// These notices appear when `llvm-cov` shows instantiations. This may be a +// default option, but it can be suppressed with: +// +// ```shell +// $ `llvm-cov show --show-instantiations=0 ...` +// ``` +// +// The notice is triggered because the function is unused by the library itself, +// and when the library is compiled, a synthetic function is generated, so +// unused function coverage can be reported. Coverage can be skipped for unused +// generic functions with: +// +// ```shell +// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...` +// ``` +// +// Even though this function is used by `uses_crate.rs` (and +// counted), with substitutions for `T`, those instantiations are only generated +// when the generic function is actually used (from the binary, not from this +// library crate). So the test result shows coverage for all instantiated +// versions and their generic type substitutions, plus the `Unexecuted +// instantiation` message for the non-substituted version. This is valid, but +// unfortunately a little confusing. +// +// The library crate has its own coverage map, and the only way to show unused +// coverage of a generic function is to include the generic function in the +// coverage map, marked as an "unused function". If the library were used by +// another binary that never used this generic function, then it would be valid +// to show the unused generic, with unknown substitution (`_`). +// +// The alternative is to exclude all generics from being included in the "unused +// functions" list, which would then omit coverage results for +// `unused_generic_function()`, below. diff --git a/tests/coverage-map/auxiliary/used_inline_crate.rs b/tests/coverage-map/auxiliary/used_inline_crate.rs new file mode 100644 index 0000000000000..e8929de6b360a --- /dev/null +++ b/tests/coverage-map/auxiliary/used_inline_crate.rs @@ -0,0 +1,85 @@ +#![allow(unused_assignments, unused_variables)] +// Verify that coverage works with optimizations: +// compile-flags: -C opt-level=3 + +use std::fmt::Debug; + +pub fn used_function() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + let mut countdown = 0; + if is_true { + countdown = 10; + } + use_this_lib_crate(); +} + +#[inline(always)] +pub fn used_inline_function() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. + let is_true = std::env::args().len() == 1; + let mut countdown = 0; + if is_true { + countdown = 10; + } + use_this_lib_crate(); +} + +#[inline(always)] +pub fn used_only_from_bin_crate_generic_function(arg: T) { + println!("used_only_from_bin_crate_generic_function with {:?}", arg); +} +// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`) + +#[inline(always)] +pub fn used_only_from_this_lib_crate_generic_function(arg: T) { + println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); +} + +#[inline(always)] +pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { + println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); +} + +#[inline(always)] +pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { + println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); +} + +#[inline(always)] +pub fn unused_generic_function(arg: T) { + println!("unused_generic_function with {:?}", arg); +} + +#[inline(always)] +pub fn unused_function() { + let is_true = std::env::args().len() == 1; + let mut countdown = 2; + if !is_true { + countdown = 20; + } +} + +#[inline(always)] +#[allow(dead_code)] +fn unused_private_function() { + let is_true = std::env::args().len() == 1; + let mut countdown = 2; + if !is_true { + countdown = 20; + } +} + +fn use_this_lib_crate() { + used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); + used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + "used from library used_crate.rs", + ); + let some_vec = vec![5, 6, 7, 8]; + used_only_from_this_lib_crate_generic_function(some_vec); + used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); +} diff --git a/tests/coverage-map/issue-85461.cov-map b/tests/coverage-map/issue-85461.cov-map new file mode 100644 index 0000000000000..d1c449b9a355e --- /dev/null +++ b/tests/coverage-map/issue-85461.cov-map @@ -0,0 +1,8 @@ +Function name: issue_85461::main +Raw bytes (9): 0x[01, 01, 00, 01, 01, 08, 01, 03, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 8, 1) to (start + 3, 2) + diff --git a/tests/coverage-map/issue-85461.rs b/tests/coverage-map/issue-85461.rs new file mode 100644 index 0000000000000..9d4c90a827eeb --- /dev/null +++ b/tests/coverage-map/issue-85461.rs @@ -0,0 +1,11 @@ +// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] + +// aux-build:inline_always_with_dead_code.rs +extern crate inline_always_with_dead_code; + +use inline_always_with_dead_code::{bar, baz}; + +fn main() { + bar::call_me(); + baz::call_me(); +} diff --git a/tests/coverage-map/unused_mod.cov-map b/tests/coverage-map/unused_mod.cov-map new file mode 100644 index 0000000000000..241cb2610ffc0 --- /dev/null +++ b/tests/coverage-map/unused_mod.cov-map @@ -0,0 +1,16 @@ +Function name: unused_mod::main +Raw bytes (9): 0x[01, 02, 00, 01, 01, 04, 01, 02, 02] +Number of files: 1 +- file 0 => global file 2 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 4, 1) to (start + 2, 2) + +Function name: unused_mod::unused_module::never_called_function (unused) +Raw bytes (9): 0x[01, 01, 00, 01, 00, 02, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Zero) at (prev + 2, 1) to (start + 2, 2) + diff --git a/tests/coverage-map/unused_mod.rs b/tests/coverage-map/unused_mod.rs new file mode 100644 index 0000000000000..6e62839c99856 --- /dev/null +++ b/tests/coverage-map/unused_mod.rs @@ -0,0 +1,6 @@ +#[path = "auxiliary/unused_mod_helper.rs"] +mod unused_module; + +fn main() { + println!("hello world!"); +} diff --git a/tests/coverage-map/uses_crate.cov-map b/tests/coverage-map/uses_crate.cov-map new file mode 100644 index 0000000000000..9c06eab700507 --- /dev/null +++ b/tests/coverage-map/uses_crate.cov-map @@ -0,0 +1,40 @@ +Function name: used_crate::used_from_bin_crate_and_lib_crate_generic_function::> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1b, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 27, 1) to (start + 2, 2) + +Function name: used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 19, 1) to (start + 2, 2) + +Function name: used_crate::used_only_from_bin_crate_generic_function::<&str> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 13, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 19, 1) to (start + 2, 2) + +Function name: used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1f, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 31, 1) to (start + 2, 2) + +Function name: uses_crate::main +Raw bytes (9): 0x[01, 02, 00, 01, 01, 0c, 01, 07, 02] +Number of files: 1 +- file 0 => global file 2 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 12, 1) to (start + 7, 2) + diff --git a/tests/coverage-map/uses_crate.rs b/tests/coverage-map/uses_crate.rs new file mode 100644 index 0000000000000..ab203ad781d66 --- /dev/null +++ b/tests/coverage-map/uses_crate.rs @@ -0,0 +1,19 @@ +// This test was failing on Linux for a while due to #110393 somehow making +// the unused functions not instrumented, but it seems to be fine now. + +// Validates coverage now works with optimizations +// compile-flags: -C opt-level=3 + +#![allow(unused_assignments, unused_variables)] + +// aux-build:used_crate.rs +extern crate used_crate; + +fn main() { + used_crate::used_function(); + let some_vec = vec![1, 2, 3, 4]; + used_crate::used_only_from_bin_crate_generic_function(&some_vec); + used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); + used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); + used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); +} diff --git a/tests/coverage-map/uses_inline_crate.cov-map b/tests/coverage-map/uses_inline_crate.cov-map new file mode 100644 index 0000000000000..6b621825c8861 --- /dev/null +++ b/tests/coverage-map/uses_inline_crate.cov-map @@ -0,0 +1,55 @@ +Function name: used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 2c, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 44, 1) to (start + 2, 2) + +Function name: used_inline_crate::used_inline_function +Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 14, 01, 06, 0f, 05, 06, 10, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 01, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 2 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 20, 1) to (start + 6, 15) +- Code(Counter(1)) at (prev + 6, 16) to (start + 2, 6) +- Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) + = (c0 - c1) +- Code(Expression(1, Add)) at (prev + 1, 5) to (start + 1, 2) + = (c1 + (c0 - c1)) + +Function name: used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 33, 1) to (start + 2, 2) + +Function name: used_inline_crate::used_only_from_bin_crate_generic_function::<&str> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 21, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 33, 1) to (start + 2, 2) + +Function name: used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str> +Raw bytes (9): 0x[01, 01, 00, 01, 01, 31, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 49, 1) to (start + 2, 2) + +Function name: uses_inline_crate::main +Raw bytes (9): 0x[01, 02, 00, 01, 01, 0c, 01, 0a, 02] +Number of files: 1 +- file 0 => global file 2 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 12, 1) to (start + 10, 2) + diff --git a/tests/coverage-map/uses_inline_crate.rs b/tests/coverage-map/uses_inline_crate.rs new file mode 100644 index 0000000000000..d7b4c3c057f46 --- /dev/null +++ b/tests/coverage-map/uses_inline_crate.rs @@ -0,0 +1,22 @@ +// This test was failing on Linux for a while due to #110393 somehow making +// the unused functions not instrumented, but it seems to be fine now. + +// Validates coverage now works with optimizations +// compile-flags: -C opt-level=3 + +#![allow(unused_assignments, unused_variables)] + +// aux-build:used_inline_crate.rs +extern crate used_inline_crate; + +fn main() { + used_inline_crate::used_function(); + used_inline_crate::used_inline_function(); + let some_vec = vec![1, 2, 3, 4]; + used_inline_crate::used_only_from_bin_crate_generic_function(&some_vec); + used_inline_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); + used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); + used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + "interesting?", + ); +} From e585a992300093c13e477f2eb7e66842d9275131 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 2 Nov 2023 13:07:57 +1100 Subject: [PATCH 06/11] coverage: Give each coverage test mode a separate output directory When multiple test modes share the same test directory, this will allow them to avoid interfering with each others' files and timestamps. --- src/tools/compiletest/src/common.rs | 12 +++++++++++- src/tools/compiletest/src/runtest.rs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 0e1bf0c6c2dce..a908218fff14e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -78,7 +78,7 @@ impl Default for Mode { } impl Mode { - pub fn disambiguator(self) -> &'static str { + pub fn aux_dir_disambiguator(self) -> &'static str { // Pretty-printing tests could run concurrently, and if they do, // they need to keep their output segregated. match self { @@ -86,6 +86,15 @@ impl Mode { _ => "", } } + + pub fn output_dir_disambiguator(self) -> &'static str { + // Coverage tests use the same test files for multiple test modes, + // so each mode should have a separate output directory. + match self { + CoverageMap | RunCoverage => self.to_str(), + _ => "", + } + } } string_enum! { @@ -699,6 +708,7 @@ pub fn output_testname_unique( let mode = config.compare_mode.as_ref().map_or("", |m| m.to_str()); let debugger = config.debugger.as_ref().map_or("", |m| m.to_str()); PathBuf::from(&testpaths.file.file_stem().unwrap()) + .with_extra_extension(config.mode.output_dir_disambiguator()) .with_extra_extension(revision.unwrap_or("")) .with_extra_extension(mode) .with_extra_extension(debugger) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index c9bc858b8e918..748ee2fe052ee 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2720,7 +2720,7 @@ impl<'test> TestCx<'test> { fn aux_output_dir_name(&self) -> PathBuf { self.output_base_dir() .join("auxiliary") - .with_extra_extension(self.config.mode.disambiguator()) + .with_extra_extension(self.config.mode.aux_dir_disambiguator()) } /// Generates a unique name for the test, such as `testname.revision.mode`. From 3509aed632dd7badac18b071bcd7e1ca53f9d1c6 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 1 Nov 2023 20:02:09 +1100 Subject: [PATCH 07/11] coverage: Add `./x.py test coverage`, an alias for `coverage-map` and `run-coverage` --- src/bootstrap/src/core/build_steps/test.rs | 50 ++++++++++++++++++++++ src/bootstrap/src/core/builder.rs | 1 + 2 files changed, 51 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e2b515a30867b..c964d220cc3da 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1349,6 +1349,56 @@ host_test!(RunMakeFullDeps { default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" }); +/// Custom test step that is responsible for running the coverage tests +/// in multiple different modes. +/// +/// Each individual mode also has its own alias that will run the tests in +/// just that mode. +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct Coverage { + pub compiler: Compiler, + pub target: TargetSelection, +} + +impl Coverage { + const SUITE: &'static str = "coverage"; +} + +impl Step for Coverage { + type Output = (); + const DEFAULT: bool = false; + const ONLY_HOSTS: bool = false; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias(Self::SUITE) + } + + fn make_run(run: RunConfig<'_>) { + let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); + + run.builder.ensure(Coverage { compiler, target: run.target }); + } + + fn run(self, builder: &Builder<'_>) { + builder.ensure(Compiletest { + compiler: self.compiler, + target: self.target, + mode: "coverage-map", + suite: "coverage-map", + path: "tests/coverage-map", + compare_mode: None, + }); + builder.ensure(Compiletest { + compiler: self.compiler, + target: self.target, + mode: "run-coverage", + suite: "run-coverage", + path: "tests/run-coverage", + compare_mode: None, + }); + } +} + default_test!(CoverageMap { path: "tests/coverage-map", mode: "coverage-map", diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 44cdbe38de365..38eb46332738a 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -727,6 +727,7 @@ impl<'a> Builder<'a> { test::Tidy, test::Ui, test::RunPassValgrind, + test::Coverage, test::CoverageMap, test::RunCoverage, test::MirOpt, From aea7c27eae5e34b11c64ec6d11c75627ef24f8b1 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 1 Nov 2023 21:23:46 +1100 Subject: [PATCH 08/11] coverage: Set up a macro for declaring unified coverage test suites --- src/bootstrap/src/core/build_steps/test.rs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index c964d220cc3da..758a801f8a76c 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1305,6 +1305,47 @@ macro_rules! test_definitions { }; } +/// Declares an alias for running the [`Coverage`] tests in only one mode. +/// Adapted from [`test_definitions`]. +macro_rules! coverage_test_alias { + ($name:ident { + alias_and_mode: $alias_and_mode:expr, + default: $default:expr, + only_hosts: $only_hosts:expr $(,)? + }) => { + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] + pub struct $name { + pub compiler: Compiler, + pub target: TargetSelection, + } + + impl $name { + const MODE: &'static str = $alias_and_mode; + } + + impl Step for $name { + type Output = (); + const DEFAULT: bool = $default; + const ONLY_HOSTS: bool = $only_hosts; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias($alias_and_mode) + } + + fn make_run(run: RunConfig<'_>) { + let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); + + run.builder.ensure($name { compiler, target: run.target }); + } + + fn run(self, builder: &Builder<'_>) { + Coverage { compiler: self.compiler, target: self.target } + .run_unified_suite(builder, Self::MODE) + } + } + }; +} + default_test!(Ui { path: "tests/ui", mode: "ui", suite: "ui" }); default_test!(RunPassValgrind { @@ -1361,7 +1402,19 @@ pub struct Coverage { } impl Coverage { + const PATH: &'static str = "tests/coverage"; const SUITE: &'static str = "coverage"; + + fn run_unified_suite(&self, builder: &Builder<'_>, mode: &'static str) { + builder.ensure(Compiletest { + compiler: self.compiler, + target: self.target, + mode, + suite: Self::SUITE, + path: Self::PATH, + compare_mode: None, + }) + } } impl Step for Coverage { From e9d04c5e2444526ffde83662f2d57fa35c772891 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 1 Nov 2023 21:26:53 +1100 Subject: [PATCH 09/11] coverage: Migrate `tests/run-coverage` into `tests/coverage` --- src/bootstrap/src/core/build_steps/test.rs | 16 +++++++--------- tests/{run-coverage => coverage}/abort.coverage | 0 tests/{run-coverage => coverage}/abort.rs | 0 tests/{run-coverage => coverage}/assert.coverage | 0 tests/{run-coverage => coverage}/assert.rs | 0 tests/{run-coverage => coverage}/async.coverage | 0 tests/{run-coverage => coverage}/async.rs | 0 tests/{run-coverage => coverage}/async2.coverage | 0 tests/{run-coverage => coverage}/async2.rs | 0 .../auxiliary/inline_always_with_dead_code.rs | 0 .../auxiliary/unused_mod_helper.rs | 0 .../auxiliary/used_crate.rs | 0 .../auxiliary/used_inline_crate.rs | 0 .../bad_counter_ids.coverage | 0 .../bad_counter_ids.rs | 0 .../{run-coverage => coverage}/closure.coverage | 0 tests/{run-coverage => coverage}/closure.rs | 0 .../closure_bug.coverage | 0 tests/{run-coverage => coverage}/closure_bug.rs | 0 .../closure_macro.coverage | 0 .../{run-coverage => coverage}/closure_macro.rs | 0 .../closure_macro_async.coverage | 0 .../closure_macro_async.rs | 0 .../conditions.coverage | 0 tests/{run-coverage => coverage}/conditions.rs | 0 .../{run-coverage => coverage}/continue.coverage | 0 tests/{run-coverage => coverage}/continue.rs | 0 .../coroutine.coverage | 0 tests/{run-coverage => coverage}/coroutine.rs | 0 .../dead_code.coverage | 0 tests/{run-coverage => coverage}/dead_code.rs | 0 .../drop_trait.coverage | 0 tests/{run-coverage => coverage}/drop_trait.rs | 0 .../fn_sig_into_try.coverage | 0 .../fn_sig_into_try.rs | 0 .../{run-coverage => coverage}/generics.coverage | 0 tests/{run-coverage => coverage}/generics.rs | 0 tests/{run-coverage => coverage}/if.coverage | 0 tests/{run-coverage => coverage}/if.rs | 0 .../{run-coverage => coverage}/if_else.coverage | 0 tests/{run-coverage => coverage}/if_else.rs | 0 .../inline-dead.coverage | 0 tests/{run-coverage => coverage}/inline-dead.rs | 0 tests/{run-coverage => coverage}/inline.coverage | 0 tests/{run-coverage => coverage}/inline.rs | 0 .../inner_items.coverage | 0 tests/{run-coverage => coverage}/inner_items.rs | 0 .../issue-83601.coverage | 0 tests/{run-coverage => coverage}/issue-83601.rs | 0 .../issue-84561.coverage | 0 tests/{run-coverage => coverage}/issue-84561.rs | 0 .../issue-85461.coverage | 0 tests/{run-coverage => coverage}/issue-85461.rs | 0 .../issue-93054.coverage | 0 tests/{run-coverage => coverage}/issue-93054.rs | 0 .../lazy_boolean.coverage | 0 tests/{run-coverage => coverage}/lazy_boolean.rs | 0 .../long_and_wide.coverage | 0 .../{run-coverage => coverage}/long_and_wide.rs | 0 .../loop_break_value.coverage | 0 .../loop_break_value.rs | 0 .../loops_branches.coverage | 0 .../{run-coverage => coverage}/loops_branches.rs | 0 .../match_or_pattern.coverage | 0 .../match_or_pattern.rs | 0 .../nested_loops.coverage | 0 tests/{run-coverage => coverage}/nested_loops.rs | 0 .../no_cov_crate.coverage | 0 tests/{run-coverage => coverage}/no_cov_crate.rs | 0 .../{run-coverage => coverage}/overflow.coverage | 0 tests/{run-coverage => coverage}/overflow.rs | 0 .../panic_unwind.coverage | 0 tests/{run-coverage => coverage}/panic_unwind.rs | 0 .../partial_eq.coverage | 0 tests/{run-coverage => coverage}/partial_eq.rs | 0 .../simple_loop.coverage | 0 tests/{run-coverage => coverage}/simple_loop.rs | 0 .../simple_match.coverage | 0 tests/{run-coverage => coverage}/simple_match.rs | 0 .../sort_groups.coverage | 0 tests/{run-coverage => coverage}/sort_groups.rs | 0 .../test_harness.coverage | 0 tests/{run-coverage => coverage}/test_harness.rs | 0 .../tight_inf_loop.coverage | 0 .../{run-coverage => coverage}/tight_inf_loop.rs | 0 .../{run-coverage => coverage}/trivial.coverage | 0 tests/{run-coverage => coverage}/trivial.rs | 0 .../try_error_result.coverage | 0 .../try_error_result.rs | 0 .../unreachable.coverage | 0 tests/{run-coverage => coverage}/unreachable.rs | 0 tests/{run-coverage => coverage}/unused.coverage | 0 tests/{run-coverage => coverage}/unused.rs | 0 .../unused_mod.coverage | 0 tests/{run-coverage => coverage}/unused_mod.rs | 0 .../uses_crate.coverage | 0 tests/{run-coverage => coverage}/uses_crate.rs | 0 .../uses_inline_crate.coverage | 0 .../uses_inline_crate.rs | 0 tests/{run-coverage => coverage}/while.coverage | 0 tests/{run-coverage => coverage}/while.rs | 0 .../while_early_ret.coverage | 0 .../while_early_ret.rs | 0 tests/{run-coverage => coverage}/yield.coverage | 0 tests/{run-coverage => coverage}/yield.rs | 0 105 files changed, 7 insertions(+), 9 deletions(-) rename tests/{run-coverage => coverage}/abort.coverage (100%) rename tests/{run-coverage => coverage}/abort.rs (100%) rename tests/{run-coverage => coverage}/assert.coverage (100%) rename tests/{run-coverage => coverage}/assert.rs (100%) rename tests/{run-coverage => coverage}/async.coverage (100%) rename tests/{run-coverage => coverage}/async.rs (100%) rename tests/{run-coverage => coverage}/async2.coverage (100%) rename tests/{run-coverage => coverage}/async2.rs (100%) rename tests/{run-coverage => coverage}/auxiliary/inline_always_with_dead_code.rs (100%) rename tests/{run-coverage => coverage}/auxiliary/unused_mod_helper.rs (100%) rename tests/{run-coverage => coverage}/auxiliary/used_crate.rs (100%) rename tests/{run-coverage => coverage}/auxiliary/used_inline_crate.rs (100%) rename tests/{run-coverage => coverage}/bad_counter_ids.coverage (100%) rename tests/{run-coverage => coverage}/bad_counter_ids.rs (100%) rename tests/{run-coverage => coverage}/closure.coverage (100%) rename tests/{run-coverage => coverage}/closure.rs (100%) rename tests/{run-coverage => coverage}/closure_bug.coverage (100%) rename tests/{run-coverage => coverage}/closure_bug.rs (100%) rename tests/{run-coverage => coverage}/closure_macro.coverage (100%) rename tests/{run-coverage => coverage}/closure_macro.rs (100%) rename tests/{run-coverage => coverage}/closure_macro_async.coverage (100%) rename tests/{run-coverage => coverage}/closure_macro_async.rs (100%) rename tests/{run-coverage => coverage}/conditions.coverage (100%) rename tests/{run-coverage => coverage}/conditions.rs (100%) rename tests/{run-coverage => coverage}/continue.coverage (100%) rename tests/{run-coverage => coverage}/continue.rs (100%) rename tests/{run-coverage => coverage}/coroutine.coverage (100%) rename tests/{run-coverage => coverage}/coroutine.rs (100%) rename tests/{run-coverage => coverage}/dead_code.coverage (100%) rename tests/{run-coverage => coverage}/dead_code.rs (100%) rename tests/{run-coverage => coverage}/drop_trait.coverage (100%) rename tests/{run-coverage => coverage}/drop_trait.rs (100%) rename tests/{run-coverage => coverage}/fn_sig_into_try.coverage (100%) rename tests/{run-coverage => coverage}/fn_sig_into_try.rs (100%) rename tests/{run-coverage => coverage}/generics.coverage (100%) rename tests/{run-coverage => coverage}/generics.rs (100%) rename tests/{run-coverage => coverage}/if.coverage (100%) rename tests/{run-coverage => coverage}/if.rs (100%) rename tests/{run-coverage => coverage}/if_else.coverage (100%) rename tests/{run-coverage => coverage}/if_else.rs (100%) rename tests/{run-coverage => coverage}/inline-dead.coverage (100%) rename tests/{run-coverage => coverage}/inline-dead.rs (100%) rename tests/{run-coverage => coverage}/inline.coverage (100%) rename tests/{run-coverage => coverage}/inline.rs (100%) rename tests/{run-coverage => coverage}/inner_items.coverage (100%) rename tests/{run-coverage => coverage}/inner_items.rs (100%) rename tests/{run-coverage => coverage}/issue-83601.coverage (100%) rename tests/{run-coverage => coverage}/issue-83601.rs (100%) rename tests/{run-coverage => coverage}/issue-84561.coverage (100%) rename tests/{run-coverage => coverage}/issue-84561.rs (100%) rename tests/{run-coverage => coverage}/issue-85461.coverage (100%) rename tests/{run-coverage => coverage}/issue-85461.rs (100%) rename tests/{run-coverage => coverage}/issue-93054.coverage (100%) rename tests/{run-coverage => coverage}/issue-93054.rs (100%) rename tests/{run-coverage => coverage}/lazy_boolean.coverage (100%) rename tests/{run-coverage => coverage}/lazy_boolean.rs (100%) rename tests/{run-coverage => coverage}/long_and_wide.coverage (100%) rename tests/{run-coverage => coverage}/long_and_wide.rs (100%) rename tests/{run-coverage => coverage}/loop_break_value.coverage (100%) rename tests/{run-coverage => coverage}/loop_break_value.rs (100%) rename tests/{run-coverage => coverage}/loops_branches.coverage (100%) rename tests/{run-coverage => coverage}/loops_branches.rs (100%) rename tests/{run-coverage => coverage}/match_or_pattern.coverage (100%) rename tests/{run-coverage => coverage}/match_or_pattern.rs (100%) rename tests/{run-coverage => coverage}/nested_loops.coverage (100%) rename tests/{run-coverage => coverage}/nested_loops.rs (100%) rename tests/{run-coverage => coverage}/no_cov_crate.coverage (100%) rename tests/{run-coverage => coverage}/no_cov_crate.rs (100%) rename tests/{run-coverage => coverage}/overflow.coverage (100%) rename tests/{run-coverage => coverage}/overflow.rs (100%) rename tests/{run-coverage => coverage}/panic_unwind.coverage (100%) rename tests/{run-coverage => coverage}/panic_unwind.rs (100%) rename tests/{run-coverage => coverage}/partial_eq.coverage (100%) rename tests/{run-coverage => coverage}/partial_eq.rs (100%) rename tests/{run-coverage => coverage}/simple_loop.coverage (100%) rename tests/{run-coverage => coverage}/simple_loop.rs (100%) rename tests/{run-coverage => coverage}/simple_match.coverage (100%) rename tests/{run-coverage => coverage}/simple_match.rs (100%) rename tests/{run-coverage => coverage}/sort_groups.coverage (100%) rename tests/{run-coverage => coverage}/sort_groups.rs (100%) rename tests/{run-coverage => coverage}/test_harness.coverage (100%) rename tests/{run-coverage => coverage}/test_harness.rs (100%) rename tests/{run-coverage => coverage}/tight_inf_loop.coverage (100%) rename tests/{run-coverage => coverage}/tight_inf_loop.rs (100%) rename tests/{run-coverage => coverage}/trivial.coverage (100%) rename tests/{run-coverage => coverage}/trivial.rs (100%) rename tests/{run-coverage => coverage}/try_error_result.coverage (100%) rename tests/{run-coverage => coverage}/try_error_result.rs (100%) rename tests/{run-coverage => coverage}/unreachable.coverage (100%) rename tests/{run-coverage => coverage}/unreachable.rs (100%) rename tests/{run-coverage => coverage}/unused.coverage (100%) rename tests/{run-coverage => coverage}/unused.rs (100%) rename tests/{run-coverage => coverage}/unused_mod.coverage (100%) rename tests/{run-coverage => coverage}/unused_mod.rs (100%) rename tests/{run-coverage => coverage}/uses_crate.coverage (100%) rename tests/{run-coverage => coverage}/uses_crate.rs (100%) rename tests/{run-coverage => coverage}/uses_inline_crate.coverage (100%) rename tests/{run-coverage => coverage}/uses_inline_crate.rs (100%) rename tests/{run-coverage => coverage}/while.coverage (100%) rename tests/{run-coverage => coverage}/while.rs (100%) rename tests/{run-coverage => coverage}/while_early_ret.coverage (100%) rename tests/{run-coverage => coverage}/while_early_ret.rs (100%) rename tests/{run-coverage => coverage}/yield.coverage (100%) rename tests/{run-coverage => coverage}/yield.rs (100%) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 758a801f8a76c..11c9e1c7bc25b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1441,14 +1441,7 @@ impl Step for Coverage { path: "tests/coverage-map", compare_mode: None, }); - builder.ensure(Compiletest { - compiler: self.compiler, - target: self.target, - mode: "run-coverage", - suite: "run-coverage", - path: "tests/run-coverage", - compare_mode: None, - }); + self.run_unified_suite(builder, RunCoverage::MODE); } } @@ -1458,7 +1451,12 @@ default_test!(CoverageMap { suite: "coverage-map" }); -host_test!(RunCoverage { path: "tests/run-coverage", mode: "run-coverage", suite: "run-coverage" }); +coverage_test_alias!(RunCoverage { + alias_and_mode: "run-coverage", + default: true, + only_hosts: true, +}); + host_test!(RunCoverageRustdoc { path: "tests/run-coverage-rustdoc", mode: "run-coverage", diff --git a/tests/run-coverage/abort.coverage b/tests/coverage/abort.coverage similarity index 100% rename from tests/run-coverage/abort.coverage rename to tests/coverage/abort.coverage diff --git a/tests/run-coverage/abort.rs b/tests/coverage/abort.rs similarity index 100% rename from tests/run-coverage/abort.rs rename to tests/coverage/abort.rs diff --git a/tests/run-coverage/assert.coverage b/tests/coverage/assert.coverage similarity index 100% rename from tests/run-coverage/assert.coverage rename to tests/coverage/assert.coverage diff --git a/tests/run-coverage/assert.rs b/tests/coverage/assert.rs similarity index 100% rename from tests/run-coverage/assert.rs rename to tests/coverage/assert.rs diff --git a/tests/run-coverage/async.coverage b/tests/coverage/async.coverage similarity index 100% rename from tests/run-coverage/async.coverage rename to tests/coverage/async.coverage diff --git a/tests/run-coverage/async.rs b/tests/coverage/async.rs similarity index 100% rename from tests/run-coverage/async.rs rename to tests/coverage/async.rs diff --git a/tests/run-coverage/async2.coverage b/tests/coverage/async2.coverage similarity index 100% rename from tests/run-coverage/async2.coverage rename to tests/coverage/async2.coverage diff --git a/tests/run-coverage/async2.rs b/tests/coverage/async2.rs similarity index 100% rename from tests/run-coverage/async2.rs rename to tests/coverage/async2.rs diff --git a/tests/run-coverage/auxiliary/inline_always_with_dead_code.rs b/tests/coverage/auxiliary/inline_always_with_dead_code.rs similarity index 100% rename from tests/run-coverage/auxiliary/inline_always_with_dead_code.rs rename to tests/coverage/auxiliary/inline_always_with_dead_code.rs diff --git a/tests/run-coverage/auxiliary/unused_mod_helper.rs b/tests/coverage/auxiliary/unused_mod_helper.rs similarity index 100% rename from tests/run-coverage/auxiliary/unused_mod_helper.rs rename to tests/coverage/auxiliary/unused_mod_helper.rs diff --git a/tests/run-coverage/auxiliary/used_crate.rs b/tests/coverage/auxiliary/used_crate.rs similarity index 100% rename from tests/run-coverage/auxiliary/used_crate.rs rename to tests/coverage/auxiliary/used_crate.rs diff --git a/tests/run-coverage/auxiliary/used_inline_crate.rs b/tests/coverage/auxiliary/used_inline_crate.rs similarity index 100% rename from tests/run-coverage/auxiliary/used_inline_crate.rs rename to tests/coverage/auxiliary/used_inline_crate.rs diff --git a/tests/run-coverage/bad_counter_ids.coverage b/tests/coverage/bad_counter_ids.coverage similarity index 100% rename from tests/run-coverage/bad_counter_ids.coverage rename to tests/coverage/bad_counter_ids.coverage diff --git a/tests/run-coverage/bad_counter_ids.rs b/tests/coverage/bad_counter_ids.rs similarity index 100% rename from tests/run-coverage/bad_counter_ids.rs rename to tests/coverage/bad_counter_ids.rs diff --git a/tests/run-coverage/closure.coverage b/tests/coverage/closure.coverage similarity index 100% rename from tests/run-coverage/closure.coverage rename to tests/coverage/closure.coverage diff --git a/tests/run-coverage/closure.rs b/tests/coverage/closure.rs similarity index 100% rename from tests/run-coverage/closure.rs rename to tests/coverage/closure.rs diff --git a/tests/run-coverage/closure_bug.coverage b/tests/coverage/closure_bug.coverage similarity index 100% rename from tests/run-coverage/closure_bug.coverage rename to tests/coverage/closure_bug.coverage diff --git a/tests/run-coverage/closure_bug.rs b/tests/coverage/closure_bug.rs similarity index 100% rename from tests/run-coverage/closure_bug.rs rename to tests/coverage/closure_bug.rs diff --git a/tests/run-coverage/closure_macro.coverage b/tests/coverage/closure_macro.coverage similarity index 100% rename from tests/run-coverage/closure_macro.coverage rename to tests/coverage/closure_macro.coverage diff --git a/tests/run-coverage/closure_macro.rs b/tests/coverage/closure_macro.rs similarity index 100% rename from tests/run-coverage/closure_macro.rs rename to tests/coverage/closure_macro.rs diff --git a/tests/run-coverage/closure_macro_async.coverage b/tests/coverage/closure_macro_async.coverage similarity index 100% rename from tests/run-coverage/closure_macro_async.coverage rename to tests/coverage/closure_macro_async.coverage diff --git a/tests/run-coverage/closure_macro_async.rs b/tests/coverage/closure_macro_async.rs similarity index 100% rename from tests/run-coverage/closure_macro_async.rs rename to tests/coverage/closure_macro_async.rs diff --git a/tests/run-coverage/conditions.coverage b/tests/coverage/conditions.coverage similarity index 100% rename from tests/run-coverage/conditions.coverage rename to tests/coverage/conditions.coverage diff --git a/tests/run-coverage/conditions.rs b/tests/coverage/conditions.rs similarity index 100% rename from tests/run-coverage/conditions.rs rename to tests/coverage/conditions.rs diff --git a/tests/run-coverage/continue.coverage b/tests/coverage/continue.coverage similarity index 100% rename from tests/run-coverage/continue.coverage rename to tests/coverage/continue.coverage diff --git a/tests/run-coverage/continue.rs b/tests/coverage/continue.rs similarity index 100% rename from tests/run-coverage/continue.rs rename to tests/coverage/continue.rs diff --git a/tests/run-coverage/coroutine.coverage b/tests/coverage/coroutine.coverage similarity index 100% rename from tests/run-coverage/coroutine.coverage rename to tests/coverage/coroutine.coverage diff --git a/tests/run-coverage/coroutine.rs b/tests/coverage/coroutine.rs similarity index 100% rename from tests/run-coverage/coroutine.rs rename to tests/coverage/coroutine.rs diff --git a/tests/run-coverage/dead_code.coverage b/tests/coverage/dead_code.coverage similarity index 100% rename from tests/run-coverage/dead_code.coverage rename to tests/coverage/dead_code.coverage diff --git a/tests/run-coverage/dead_code.rs b/tests/coverage/dead_code.rs similarity index 100% rename from tests/run-coverage/dead_code.rs rename to tests/coverage/dead_code.rs diff --git a/tests/run-coverage/drop_trait.coverage b/tests/coverage/drop_trait.coverage similarity index 100% rename from tests/run-coverage/drop_trait.coverage rename to tests/coverage/drop_trait.coverage diff --git a/tests/run-coverage/drop_trait.rs b/tests/coverage/drop_trait.rs similarity index 100% rename from tests/run-coverage/drop_trait.rs rename to tests/coverage/drop_trait.rs diff --git a/tests/run-coverage/fn_sig_into_try.coverage b/tests/coverage/fn_sig_into_try.coverage similarity index 100% rename from tests/run-coverage/fn_sig_into_try.coverage rename to tests/coverage/fn_sig_into_try.coverage diff --git a/tests/run-coverage/fn_sig_into_try.rs b/tests/coverage/fn_sig_into_try.rs similarity index 100% rename from tests/run-coverage/fn_sig_into_try.rs rename to tests/coverage/fn_sig_into_try.rs diff --git a/tests/run-coverage/generics.coverage b/tests/coverage/generics.coverage similarity index 100% rename from tests/run-coverage/generics.coverage rename to tests/coverage/generics.coverage diff --git a/tests/run-coverage/generics.rs b/tests/coverage/generics.rs similarity index 100% rename from tests/run-coverage/generics.rs rename to tests/coverage/generics.rs diff --git a/tests/run-coverage/if.coverage b/tests/coverage/if.coverage similarity index 100% rename from tests/run-coverage/if.coverage rename to tests/coverage/if.coverage diff --git a/tests/run-coverage/if.rs b/tests/coverage/if.rs similarity index 100% rename from tests/run-coverage/if.rs rename to tests/coverage/if.rs diff --git a/tests/run-coverage/if_else.coverage b/tests/coverage/if_else.coverage similarity index 100% rename from tests/run-coverage/if_else.coverage rename to tests/coverage/if_else.coverage diff --git a/tests/run-coverage/if_else.rs b/tests/coverage/if_else.rs similarity index 100% rename from tests/run-coverage/if_else.rs rename to tests/coverage/if_else.rs diff --git a/tests/run-coverage/inline-dead.coverage b/tests/coverage/inline-dead.coverage similarity index 100% rename from tests/run-coverage/inline-dead.coverage rename to tests/coverage/inline-dead.coverage diff --git a/tests/run-coverage/inline-dead.rs b/tests/coverage/inline-dead.rs similarity index 100% rename from tests/run-coverage/inline-dead.rs rename to tests/coverage/inline-dead.rs diff --git a/tests/run-coverage/inline.coverage b/tests/coverage/inline.coverage similarity index 100% rename from tests/run-coverage/inline.coverage rename to tests/coverage/inline.coverage diff --git a/tests/run-coverage/inline.rs b/tests/coverage/inline.rs similarity index 100% rename from tests/run-coverage/inline.rs rename to tests/coverage/inline.rs diff --git a/tests/run-coverage/inner_items.coverage b/tests/coverage/inner_items.coverage similarity index 100% rename from tests/run-coverage/inner_items.coverage rename to tests/coverage/inner_items.coverage diff --git a/tests/run-coverage/inner_items.rs b/tests/coverage/inner_items.rs similarity index 100% rename from tests/run-coverage/inner_items.rs rename to tests/coverage/inner_items.rs diff --git a/tests/run-coverage/issue-83601.coverage b/tests/coverage/issue-83601.coverage similarity index 100% rename from tests/run-coverage/issue-83601.coverage rename to tests/coverage/issue-83601.coverage diff --git a/tests/run-coverage/issue-83601.rs b/tests/coverage/issue-83601.rs similarity index 100% rename from tests/run-coverage/issue-83601.rs rename to tests/coverage/issue-83601.rs diff --git a/tests/run-coverage/issue-84561.coverage b/tests/coverage/issue-84561.coverage similarity index 100% rename from tests/run-coverage/issue-84561.coverage rename to tests/coverage/issue-84561.coverage diff --git a/tests/run-coverage/issue-84561.rs b/tests/coverage/issue-84561.rs similarity index 100% rename from tests/run-coverage/issue-84561.rs rename to tests/coverage/issue-84561.rs diff --git a/tests/run-coverage/issue-85461.coverage b/tests/coverage/issue-85461.coverage similarity index 100% rename from tests/run-coverage/issue-85461.coverage rename to tests/coverage/issue-85461.coverage diff --git a/tests/run-coverage/issue-85461.rs b/tests/coverage/issue-85461.rs similarity index 100% rename from tests/run-coverage/issue-85461.rs rename to tests/coverage/issue-85461.rs diff --git a/tests/run-coverage/issue-93054.coverage b/tests/coverage/issue-93054.coverage similarity index 100% rename from tests/run-coverage/issue-93054.coverage rename to tests/coverage/issue-93054.coverage diff --git a/tests/run-coverage/issue-93054.rs b/tests/coverage/issue-93054.rs similarity index 100% rename from tests/run-coverage/issue-93054.rs rename to tests/coverage/issue-93054.rs diff --git a/tests/run-coverage/lazy_boolean.coverage b/tests/coverage/lazy_boolean.coverage similarity index 100% rename from tests/run-coverage/lazy_boolean.coverage rename to tests/coverage/lazy_boolean.coverage diff --git a/tests/run-coverage/lazy_boolean.rs b/tests/coverage/lazy_boolean.rs similarity index 100% rename from tests/run-coverage/lazy_boolean.rs rename to tests/coverage/lazy_boolean.rs diff --git a/tests/run-coverage/long_and_wide.coverage b/tests/coverage/long_and_wide.coverage similarity index 100% rename from tests/run-coverage/long_and_wide.coverage rename to tests/coverage/long_and_wide.coverage diff --git a/tests/run-coverage/long_and_wide.rs b/tests/coverage/long_and_wide.rs similarity index 100% rename from tests/run-coverage/long_and_wide.rs rename to tests/coverage/long_and_wide.rs diff --git a/tests/run-coverage/loop_break_value.coverage b/tests/coverage/loop_break_value.coverage similarity index 100% rename from tests/run-coverage/loop_break_value.coverage rename to tests/coverage/loop_break_value.coverage diff --git a/tests/run-coverage/loop_break_value.rs b/tests/coverage/loop_break_value.rs similarity index 100% rename from tests/run-coverage/loop_break_value.rs rename to tests/coverage/loop_break_value.rs diff --git a/tests/run-coverage/loops_branches.coverage b/tests/coverage/loops_branches.coverage similarity index 100% rename from tests/run-coverage/loops_branches.coverage rename to tests/coverage/loops_branches.coverage diff --git a/tests/run-coverage/loops_branches.rs b/tests/coverage/loops_branches.rs similarity index 100% rename from tests/run-coverage/loops_branches.rs rename to tests/coverage/loops_branches.rs diff --git a/tests/run-coverage/match_or_pattern.coverage b/tests/coverage/match_or_pattern.coverage similarity index 100% rename from tests/run-coverage/match_or_pattern.coverage rename to tests/coverage/match_or_pattern.coverage diff --git a/tests/run-coverage/match_or_pattern.rs b/tests/coverage/match_or_pattern.rs similarity index 100% rename from tests/run-coverage/match_or_pattern.rs rename to tests/coverage/match_or_pattern.rs diff --git a/tests/run-coverage/nested_loops.coverage b/tests/coverage/nested_loops.coverage similarity index 100% rename from tests/run-coverage/nested_loops.coverage rename to tests/coverage/nested_loops.coverage diff --git a/tests/run-coverage/nested_loops.rs b/tests/coverage/nested_loops.rs similarity index 100% rename from tests/run-coverage/nested_loops.rs rename to tests/coverage/nested_loops.rs diff --git a/tests/run-coverage/no_cov_crate.coverage b/tests/coverage/no_cov_crate.coverage similarity index 100% rename from tests/run-coverage/no_cov_crate.coverage rename to tests/coverage/no_cov_crate.coverage diff --git a/tests/run-coverage/no_cov_crate.rs b/tests/coverage/no_cov_crate.rs similarity index 100% rename from tests/run-coverage/no_cov_crate.rs rename to tests/coverage/no_cov_crate.rs diff --git a/tests/run-coverage/overflow.coverage b/tests/coverage/overflow.coverage similarity index 100% rename from tests/run-coverage/overflow.coverage rename to tests/coverage/overflow.coverage diff --git a/tests/run-coverage/overflow.rs b/tests/coverage/overflow.rs similarity index 100% rename from tests/run-coverage/overflow.rs rename to tests/coverage/overflow.rs diff --git a/tests/run-coverage/panic_unwind.coverage b/tests/coverage/panic_unwind.coverage similarity index 100% rename from tests/run-coverage/panic_unwind.coverage rename to tests/coverage/panic_unwind.coverage diff --git a/tests/run-coverage/panic_unwind.rs b/tests/coverage/panic_unwind.rs similarity index 100% rename from tests/run-coverage/panic_unwind.rs rename to tests/coverage/panic_unwind.rs diff --git a/tests/run-coverage/partial_eq.coverage b/tests/coverage/partial_eq.coverage similarity index 100% rename from tests/run-coverage/partial_eq.coverage rename to tests/coverage/partial_eq.coverage diff --git a/tests/run-coverage/partial_eq.rs b/tests/coverage/partial_eq.rs similarity index 100% rename from tests/run-coverage/partial_eq.rs rename to tests/coverage/partial_eq.rs diff --git a/tests/run-coverage/simple_loop.coverage b/tests/coverage/simple_loop.coverage similarity index 100% rename from tests/run-coverage/simple_loop.coverage rename to tests/coverage/simple_loop.coverage diff --git a/tests/run-coverage/simple_loop.rs b/tests/coverage/simple_loop.rs similarity index 100% rename from tests/run-coverage/simple_loop.rs rename to tests/coverage/simple_loop.rs diff --git a/tests/run-coverage/simple_match.coverage b/tests/coverage/simple_match.coverage similarity index 100% rename from tests/run-coverage/simple_match.coverage rename to tests/coverage/simple_match.coverage diff --git a/tests/run-coverage/simple_match.rs b/tests/coverage/simple_match.rs similarity index 100% rename from tests/run-coverage/simple_match.rs rename to tests/coverage/simple_match.rs diff --git a/tests/run-coverage/sort_groups.coverage b/tests/coverage/sort_groups.coverage similarity index 100% rename from tests/run-coverage/sort_groups.coverage rename to tests/coverage/sort_groups.coverage diff --git a/tests/run-coverage/sort_groups.rs b/tests/coverage/sort_groups.rs similarity index 100% rename from tests/run-coverage/sort_groups.rs rename to tests/coverage/sort_groups.rs diff --git a/tests/run-coverage/test_harness.coverage b/tests/coverage/test_harness.coverage similarity index 100% rename from tests/run-coverage/test_harness.coverage rename to tests/coverage/test_harness.coverage diff --git a/tests/run-coverage/test_harness.rs b/tests/coverage/test_harness.rs similarity index 100% rename from tests/run-coverage/test_harness.rs rename to tests/coverage/test_harness.rs diff --git a/tests/run-coverage/tight_inf_loop.coverage b/tests/coverage/tight_inf_loop.coverage similarity index 100% rename from tests/run-coverage/tight_inf_loop.coverage rename to tests/coverage/tight_inf_loop.coverage diff --git a/tests/run-coverage/tight_inf_loop.rs b/tests/coverage/tight_inf_loop.rs similarity index 100% rename from tests/run-coverage/tight_inf_loop.rs rename to tests/coverage/tight_inf_loop.rs diff --git a/tests/run-coverage/trivial.coverage b/tests/coverage/trivial.coverage similarity index 100% rename from tests/run-coverage/trivial.coverage rename to tests/coverage/trivial.coverage diff --git a/tests/run-coverage/trivial.rs b/tests/coverage/trivial.rs similarity index 100% rename from tests/run-coverage/trivial.rs rename to tests/coverage/trivial.rs diff --git a/tests/run-coverage/try_error_result.coverage b/tests/coverage/try_error_result.coverage similarity index 100% rename from tests/run-coverage/try_error_result.coverage rename to tests/coverage/try_error_result.coverage diff --git a/tests/run-coverage/try_error_result.rs b/tests/coverage/try_error_result.rs similarity index 100% rename from tests/run-coverage/try_error_result.rs rename to tests/coverage/try_error_result.rs diff --git a/tests/run-coverage/unreachable.coverage b/tests/coverage/unreachable.coverage similarity index 100% rename from tests/run-coverage/unreachable.coverage rename to tests/coverage/unreachable.coverage diff --git a/tests/run-coverage/unreachable.rs b/tests/coverage/unreachable.rs similarity index 100% rename from tests/run-coverage/unreachable.rs rename to tests/coverage/unreachable.rs diff --git a/tests/run-coverage/unused.coverage b/tests/coverage/unused.coverage similarity index 100% rename from tests/run-coverage/unused.coverage rename to tests/coverage/unused.coverage diff --git a/tests/run-coverage/unused.rs b/tests/coverage/unused.rs similarity index 100% rename from tests/run-coverage/unused.rs rename to tests/coverage/unused.rs diff --git a/tests/run-coverage/unused_mod.coverage b/tests/coverage/unused_mod.coverage similarity index 100% rename from tests/run-coverage/unused_mod.coverage rename to tests/coverage/unused_mod.coverage diff --git a/tests/run-coverage/unused_mod.rs b/tests/coverage/unused_mod.rs similarity index 100% rename from tests/run-coverage/unused_mod.rs rename to tests/coverage/unused_mod.rs diff --git a/tests/run-coverage/uses_crate.coverage b/tests/coverage/uses_crate.coverage similarity index 100% rename from tests/run-coverage/uses_crate.coverage rename to tests/coverage/uses_crate.coverage diff --git a/tests/run-coverage/uses_crate.rs b/tests/coverage/uses_crate.rs similarity index 100% rename from tests/run-coverage/uses_crate.rs rename to tests/coverage/uses_crate.rs diff --git a/tests/run-coverage/uses_inline_crate.coverage b/tests/coverage/uses_inline_crate.coverage similarity index 100% rename from tests/run-coverage/uses_inline_crate.coverage rename to tests/coverage/uses_inline_crate.coverage diff --git a/tests/run-coverage/uses_inline_crate.rs b/tests/coverage/uses_inline_crate.rs similarity index 100% rename from tests/run-coverage/uses_inline_crate.rs rename to tests/coverage/uses_inline_crate.rs diff --git a/tests/run-coverage/while.coverage b/tests/coverage/while.coverage similarity index 100% rename from tests/run-coverage/while.coverage rename to tests/coverage/while.coverage diff --git a/tests/run-coverage/while.rs b/tests/coverage/while.rs similarity index 100% rename from tests/run-coverage/while.rs rename to tests/coverage/while.rs diff --git a/tests/run-coverage/while_early_ret.coverage b/tests/coverage/while_early_ret.coverage similarity index 100% rename from tests/run-coverage/while_early_ret.coverage rename to tests/coverage/while_early_ret.coverage diff --git a/tests/run-coverage/while_early_ret.rs b/tests/coverage/while_early_ret.rs similarity index 100% rename from tests/run-coverage/while_early_ret.rs rename to tests/coverage/while_early_ret.rs diff --git a/tests/run-coverage/yield.coverage b/tests/coverage/yield.coverage similarity index 100% rename from tests/run-coverage/yield.coverage rename to tests/coverage/yield.coverage diff --git a/tests/run-coverage/yield.rs b/tests/coverage/yield.rs similarity index 100% rename from tests/run-coverage/yield.rs rename to tests/coverage/yield.rs From 49127c64d6998526d9f723a653312d0cf5310454 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 1 Nov 2023 21:28:53 +1100 Subject: [PATCH 10/11] coverage: Migrate `tests/coverage-map` into `tests/coverage` --- src/bootstrap/src/core/build_steps/test.rs | 18 +- tests/coverage-map/abort.rs | 66 ------ tests/coverage-map/assert.rs | 32 --- tests/coverage-map/async.rs | 128 ---------- tests/coverage-map/async2.rs | 57 ----- .../auxiliary/inline_always_with_dead_code.rs | 22 -- .../auxiliary/unused_mod_helper.rs | 4 - tests/coverage-map/auxiliary/used_crate.rs | 103 -------- .../auxiliary/used_inline_crate.rs | 85 ------- tests/coverage-map/bad_counter_ids.rs | 66 ------ tests/coverage-map/closure.rs | 220 ------------------ tests/coverage-map/closure_bug.rs | 44 ---- tests/coverage-map/closure_macro.rs | 40 ---- tests/coverage-map/closure_macro_async.rs | 77 ------ tests/coverage-map/conditions.rs | 86 ------- tests/coverage-map/continue.rs | 69 ------ tests/coverage-map/coroutine.rs | 30 --- tests/coverage-map/dead_code.rs | 37 --- tests/coverage-map/drop_trait.rs | 33 --- tests/coverage-map/fn_sig_into_try.rs | 41 ---- tests/coverage-map/generics.rs | 44 ---- tests/coverage-map/if.rs | 28 --- tests/coverage-map/if_else.rs | 40 ---- tests/coverage-map/inline-dead.rs | 27 --- tests/coverage-map/inline.rs | 51 ---- tests/coverage-map/inner_items.rs | 57 ----- tests/coverage-map/issue-83601.rs | 14 -- tests/coverage-map/issue-84561.rs | 182 --------------- tests/coverage-map/issue-85461.rs | 11 - tests/coverage-map/issue-93054.rs | 30 --- tests/coverage-map/lazy_boolean.rs | 61 ----- tests/coverage-map/long_and_wide.rs | 150 ------------ tests/coverage-map/loop_break_value.rs | 13 -- tests/coverage-map/loops_branches.rs | 60 ----- tests/coverage-map/match_or_pattern.rs | 43 ---- tests/coverage-map/nested_loops.rs | 25 -- tests/coverage-map/no_cov_crate.rs | 88 ------- tests/coverage-map/overflow.rs | 64 ----- tests/coverage-map/panic_unwind.rs | 31 --- tests/coverage-map/partial_eq.rs | 46 ---- tests/coverage-map/simple_loop.rs | 35 --- tests/coverage-map/simple_match.rs | 43 ---- tests/coverage-map/sort_groups.rs | 23 -- tests/coverage-map/test_harness.rs | 10 - tests/coverage-map/tight_inf_loop.rs | 5 - tests/coverage-map/trivial.rs | 3 - tests/coverage-map/try_error_result.rs | 118 ---------- tests/coverage-map/unreachable.rs | 37 --- tests/coverage-map/unused.rs | 41 ---- tests/coverage-map/unused_mod.rs | 6 - tests/coverage-map/uses_crate.rs | 19 -- tests/coverage-map/uses_inline_crate.rs | 22 -- tests/coverage-map/while.rs | 5 - tests/coverage-map/while_early_ret.rs | 42 ---- tests/coverage-map/yield.rs | 37 --- tests/{coverage-map => coverage}/README.md | 0 .../{coverage-map => coverage}/abort.cov-map | 0 .../{coverage-map => coverage}/assert.cov-map | 0 .../{coverage-map => coverage}/async.cov-map | 0 .../{coverage-map => coverage}/async2.cov-map | 0 .../bad_counter_ids.cov-map | 0 .../closure.cov-map | 0 .../closure_bug.cov-map | 0 .../closure_macro.cov-map | 0 .../closure_macro_async.cov-map | 0 .../conditions.cov-map | 0 .../continue.cov-map | 0 .../coroutine.cov-map | 0 .../dead_code.cov-map | 0 .../drop_trait.cov-map | 0 .../fn_sig_into_try.cov-map | 0 .../generics.cov-map | 0 tests/{coverage-map => coverage}/if.cov-map | 0 .../if_else.cov-map | 0 .../inline-dead.cov-map | 0 .../{coverage-map => coverage}/inline.cov-map | 0 .../inner_items.cov-map | 0 .../issue-83601.cov-map | 0 .../issue-84561.cov-map | 0 .../issue-85461.cov-map | 0 .../issue-93054.cov-map | 0 .../lazy_boolean.cov-map | 0 .../long_and_wide.cov-map | 0 .../loop_break_value.cov-map | 0 .../loops_branches.cov-map | 0 .../match_or_pattern.cov-map | 0 .../nested_loops.cov-map | 0 .../no_cov_crate.cov-map | 0 .../overflow.cov-map | 0 .../panic_unwind.cov-map | 0 .../partial_eq.cov-map | 0 .../simple_loop.cov-map | 0 .../simple_match.cov-map | 0 .../sort_groups.cov-map | 0 .../test_harness.cov-map | 0 .../tight_inf_loop.cov-map | 0 .../trivial.cov-map | 0 .../try_error_result.cov-map | 0 .../unreachable.cov-map | 0 .../{coverage-map => coverage}/unused.cov-map | 0 .../unused_mod.cov-map | 0 .../uses_crate.cov-map | 0 .../uses_inline_crate.cov-map | 0 .../{coverage-map => coverage}/while.cov-map | 0 .../while_early_ret.cov-map | 0 .../{coverage-map => coverage}/yield.cov-map | 0 106 files changed, 5 insertions(+), 2764 deletions(-) delete mode 100644 tests/coverage-map/abort.rs delete mode 100644 tests/coverage-map/assert.rs delete mode 100644 tests/coverage-map/async.rs delete mode 100644 tests/coverage-map/async2.rs delete mode 100644 tests/coverage-map/auxiliary/inline_always_with_dead_code.rs delete mode 100644 tests/coverage-map/auxiliary/unused_mod_helper.rs delete mode 100644 tests/coverage-map/auxiliary/used_crate.rs delete mode 100644 tests/coverage-map/auxiliary/used_inline_crate.rs delete mode 100644 tests/coverage-map/bad_counter_ids.rs delete mode 100644 tests/coverage-map/closure.rs delete mode 100644 tests/coverage-map/closure_bug.rs delete mode 100644 tests/coverage-map/closure_macro.rs delete mode 100644 tests/coverage-map/closure_macro_async.rs delete mode 100644 tests/coverage-map/conditions.rs delete mode 100644 tests/coverage-map/continue.rs delete mode 100644 tests/coverage-map/coroutine.rs delete mode 100644 tests/coverage-map/dead_code.rs delete mode 100644 tests/coverage-map/drop_trait.rs delete mode 100644 tests/coverage-map/fn_sig_into_try.rs delete mode 100644 tests/coverage-map/generics.rs delete mode 100644 tests/coverage-map/if.rs delete mode 100644 tests/coverage-map/if_else.rs delete mode 100644 tests/coverage-map/inline-dead.rs delete mode 100644 tests/coverage-map/inline.rs delete mode 100644 tests/coverage-map/inner_items.rs delete mode 100644 tests/coverage-map/issue-83601.rs delete mode 100644 tests/coverage-map/issue-84561.rs delete mode 100644 tests/coverage-map/issue-85461.rs delete mode 100644 tests/coverage-map/issue-93054.rs delete mode 100644 tests/coverage-map/lazy_boolean.rs delete mode 100644 tests/coverage-map/long_and_wide.rs delete mode 100644 tests/coverage-map/loop_break_value.rs delete mode 100644 tests/coverage-map/loops_branches.rs delete mode 100644 tests/coverage-map/match_or_pattern.rs delete mode 100644 tests/coverage-map/nested_loops.rs delete mode 100644 tests/coverage-map/no_cov_crate.rs delete mode 100644 tests/coverage-map/overflow.rs delete mode 100644 tests/coverage-map/panic_unwind.rs delete mode 100644 tests/coverage-map/partial_eq.rs delete mode 100644 tests/coverage-map/simple_loop.rs delete mode 100644 tests/coverage-map/simple_match.rs delete mode 100644 tests/coverage-map/sort_groups.rs delete mode 100644 tests/coverage-map/test_harness.rs delete mode 100644 tests/coverage-map/tight_inf_loop.rs delete mode 100644 tests/coverage-map/trivial.rs delete mode 100644 tests/coverage-map/try_error_result.rs delete mode 100644 tests/coverage-map/unreachable.rs delete mode 100644 tests/coverage-map/unused.rs delete mode 100644 tests/coverage-map/unused_mod.rs delete mode 100644 tests/coverage-map/uses_crate.rs delete mode 100644 tests/coverage-map/uses_inline_crate.rs delete mode 100644 tests/coverage-map/while.rs delete mode 100644 tests/coverage-map/while_early_ret.rs delete mode 100644 tests/coverage-map/yield.rs rename tests/{coverage-map => coverage}/README.md (100%) rename tests/{coverage-map => coverage}/abort.cov-map (100%) rename tests/{coverage-map => coverage}/assert.cov-map (100%) rename tests/{coverage-map => coverage}/async.cov-map (100%) rename tests/{coverage-map => coverage}/async2.cov-map (100%) rename tests/{coverage-map => coverage}/bad_counter_ids.cov-map (100%) rename tests/{coverage-map => coverage}/closure.cov-map (100%) rename tests/{coverage-map => coverage}/closure_bug.cov-map (100%) rename tests/{coverage-map => coverage}/closure_macro.cov-map (100%) rename tests/{coverage-map => coverage}/closure_macro_async.cov-map (100%) rename tests/{coverage-map => coverage}/conditions.cov-map (100%) rename tests/{coverage-map => coverage}/continue.cov-map (100%) rename tests/{coverage-map => coverage}/coroutine.cov-map (100%) rename tests/{coverage-map => coverage}/dead_code.cov-map (100%) rename tests/{coverage-map => coverage}/drop_trait.cov-map (100%) rename tests/{coverage-map => coverage}/fn_sig_into_try.cov-map (100%) rename tests/{coverage-map => coverage}/generics.cov-map (100%) rename tests/{coverage-map => coverage}/if.cov-map (100%) rename tests/{coverage-map => coverage}/if_else.cov-map (100%) rename tests/{coverage-map => coverage}/inline-dead.cov-map (100%) rename tests/{coverage-map => coverage}/inline.cov-map (100%) rename tests/{coverage-map => coverage}/inner_items.cov-map (100%) rename tests/{coverage-map => coverage}/issue-83601.cov-map (100%) rename tests/{coverage-map => coverage}/issue-84561.cov-map (100%) rename tests/{coverage-map => coverage}/issue-85461.cov-map (100%) rename tests/{coverage-map => coverage}/issue-93054.cov-map (100%) rename tests/{coverage-map => coverage}/lazy_boolean.cov-map (100%) rename tests/{coverage-map => coverage}/long_and_wide.cov-map (100%) rename tests/{coverage-map => coverage}/loop_break_value.cov-map (100%) rename tests/{coverage-map => coverage}/loops_branches.cov-map (100%) rename tests/{coverage-map => coverage}/match_or_pattern.cov-map (100%) rename tests/{coverage-map => coverage}/nested_loops.cov-map (100%) rename tests/{coverage-map => coverage}/no_cov_crate.cov-map (100%) rename tests/{coverage-map => coverage}/overflow.cov-map (100%) rename tests/{coverage-map => coverage}/panic_unwind.cov-map (100%) rename tests/{coverage-map => coverage}/partial_eq.cov-map (100%) rename tests/{coverage-map => coverage}/simple_loop.cov-map (100%) rename tests/{coverage-map => coverage}/simple_match.cov-map (100%) rename tests/{coverage-map => coverage}/sort_groups.cov-map (100%) rename tests/{coverage-map => coverage}/test_harness.cov-map (100%) rename tests/{coverage-map => coverage}/tight_inf_loop.cov-map (100%) rename tests/{coverage-map => coverage}/trivial.cov-map (100%) rename tests/{coverage-map => coverage}/try_error_result.cov-map (100%) rename tests/{coverage-map => coverage}/unreachable.cov-map (100%) rename tests/{coverage-map => coverage}/unused.cov-map (100%) rename tests/{coverage-map => coverage}/unused_mod.cov-map (100%) rename tests/{coverage-map => coverage}/uses_crate.cov-map (100%) rename tests/{coverage-map => coverage}/uses_inline_crate.cov-map (100%) rename tests/{coverage-map => coverage}/while.cov-map (100%) rename tests/{coverage-map => coverage}/while_early_ret.cov-map (100%) rename tests/{coverage-map => coverage}/yield.cov-map (100%) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 11c9e1c7bc25b..da4b135083c63 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1433,24 +1433,16 @@ impl Step for Coverage { } fn run(self, builder: &Builder<'_>) { - builder.ensure(Compiletest { - compiler: self.compiler, - target: self.target, - mode: "coverage-map", - suite: "coverage-map", - path: "tests/coverage-map", - compare_mode: None, - }); + self.run_unified_suite(builder, CoverageMap::MODE); self.run_unified_suite(builder, RunCoverage::MODE); } } -default_test!(CoverageMap { - path: "tests/coverage-map", - mode: "coverage-map", - suite: "coverage-map" +coverage_test_alias!(CoverageMap { + alias_and_mode: "coverage-map", + default: true, + only_hosts: false, }); - coverage_test_alias!(RunCoverage { alias_and_mode: "run-coverage", default: true, diff --git a/tests/coverage-map/abort.rs b/tests/coverage-map/abort.rs deleted file mode 100644 index 98264bdc1afe5..0000000000000 --- a/tests/coverage-map/abort.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![feature(c_unwind)] -#![allow(unused_assignments)] - -extern "C" fn might_abort(should_abort: bool) { - if should_abort { - println!("aborting..."); - panic!("panics and aborts"); - } else { - println!("Don't Panic"); - } -} - -fn main() -> Result<(), u8> { - let mut countdown = 10; - while countdown > 0 { - if countdown < 5 { - might_abort(false); - } - // See discussion (below the `Notes` section) on coverage results for the closing brace. - if countdown < 5 { might_abort(false); } // Counts for different regions on one line. - // For the following example, the closing brace is the last character on the line. - // This shows the character after the closing brace is highlighted, even if that next - // character is a newline. - if countdown < 5 { might_abort(false); } - countdown -= 1; - } - Ok(()) -} - -// Notes: -// 1. Compare this program and its coverage results to those of the similar tests -// `panic_unwind.rs` and `try_error_result.rs`. -// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`. -// 3. The test does not invoke the abort. By executing to a successful completion, the coverage -// results show where the program did and did not execute. -// 4. If the program actually aborted, the coverage counters would not be saved (which "works as -// intended"). Coverage results would show no executed coverage regions. -// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status -// (on Linux at least). - -/* - -Expect the following coverage results: - -```text - 16| 11| while countdown > 0 { - 17| 10| if countdown < 5 { - 18| 4| might_abort(false); - 19| 6| } -``` - -This is actually correct. - -The condition `countdown < 5` executed 10 times (10 loop iterations). - -It evaluated to `true` 4 times, and executed the `might_abort()` call. - -It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit -`else`, the coverage implementation injects a counter, at the character immediately after the `if`s -closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the -non-true condition. - -As another example of why this is important, say the condition was `countdown < 50`, which is always -`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called. -The closing brace would have a count of `0`, highlighting the missed coverage. -*/ diff --git a/tests/coverage-map/assert.rs b/tests/coverage-map/assert.rs deleted file mode 100644 index 85e6662a6adc8..0000000000000 --- a/tests/coverage-map/assert.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![allow(unused_assignments)] -// failure-status: 101 - -fn might_fail_assert(one_plus_one: u32) { - println!("does 1 + 1 = {}?", one_plus_one); - assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); -} - -fn main() -> Result<(), u8> { - let mut countdown = 10; - while countdown > 0 { - if countdown == 1 { - might_fail_assert(3); - } else if countdown < 5 { - might_fail_assert(2); - } - countdown -= 1; - } - Ok(()) -} - -// Notes: -// 1. Compare this program and its coverage results to those of the very similar test -// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`. -// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or -// related `assert_*!()` macro. -// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce -// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to -// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails). -// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test -// (and in many other coverage tests). The `Assert` terminator is typically generated by the -// Rust compiler to check for runtime failures, such as numeric overflows. diff --git a/tests/coverage-map/async.rs b/tests/coverage-map/async.rs deleted file mode 100644 index efd9e62d64e1d..0000000000000 --- a/tests/coverage-map/async.rs +++ /dev/null @@ -1,128 +0,0 @@ -#![allow(unused_assignments, dead_code)] - -// compile-flags: --edition=2018 -C opt-level=1 - -async fn c(x: u8) -> u8 { - if x == 8 { - 1 - } else { - 0 - } -} - -async fn d() -> u8 { 1 } - -async fn e() -> u8 { 1 } // unused function; executor does not block on `g()` - -async fn f() -> u8 { 1 } - -async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()` - -pub async fn g(x: u8) { - match x { - y if e().await == y => (), - y if f().await == y => (), - _ => (), - } -} - -async fn h(x: usize) { // The function signature is counted when called, but the body is not - // executed (not awaited) so the open brace has a `0` count (at least when - // displayed with `llvm-cov show` in color-mode). - match x { - y if foo().await[y] => (), - _ => (), - } -} - -async fn i(x: u8) { // line coverage is 1, but there are 2 regions: - // (a) the function signature, counted when the function is called; and - // (b) the open brace for the function body, counted once when the body is - // executed asynchronously. - match x { - y if c(x).await == y + 1 => { d().await; } - y if f().await == y + 1 => (), - _ => (), - } -} - -fn j(x: u8) { - // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`. - fn c(x: u8) -> u8 { - if x == 8 { - 1 // This line appears covered, but the 1-character expression span covering the `1` - // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because - // `fn j()` executes the open brace for the function body, followed by the function's - // first executable statement, `match x`. Inner function declarations are not - // "visible" to the MIR for `j()`, so the code region counts all lines between the - // open brace and the first statement as executed, which is, in a sense, true. - // `llvm-cov show` overcomes this kind of situation by showing the actual counts - // of the enclosed coverages, (that is, the `1` expression was not executed, and - // accurately displays a `0`). - } else { - 0 - } - } - fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed - fn f() -> u8 { 1 } - match x { - y if c(x) == y + 1 => { d(); } - y if f() == y + 1 => (), - _ => (), - } -} - -fn k(x: u8) { // unused function - match x { - 1 => (), - 2 => (), - _ => (), - } -} - -fn l(x: u8) { - match x { - 1 => (), - 2 => (), - _ => (), - } -} - -async fn m(x: u8) -> u8 { x - 1 } - -fn main() { - let _ = g(10); - let _ = h(9); - let mut future = Box::pin(i(8)); - j(7); - l(6); - let _ = m(5); - executor::block_on(future.as_mut()); -} - -mod executor { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; - - pub fn block_on(mut future: F) -> F::Output { - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - use std::hint::unreachable_unchecked; - static VTABLE: RawWakerVTable = RawWakerVTable::new( - |_| unsafe { unreachable_unchecked() }, // clone - |_| unsafe { unreachable_unchecked() }, // wake - |_| unsafe { unreachable_unchecked() }, // wake_by_ref - |_| (), - ); - let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - let mut context = Context::from_waker(&waker); - - loop { - if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - break val; - } - } - } -} diff --git a/tests/coverage-map/async2.rs b/tests/coverage-map/async2.rs deleted file mode 100644 index 2884ff297affd..0000000000000 --- a/tests/coverage-map/async2.rs +++ /dev/null @@ -1,57 +0,0 @@ -// compile-flags: --edition=2018 - -fn non_async_func() { - println!("non_async_func was covered"); - let b = true; - if b { - println!("non_async_func println in block"); - } -} - -async fn async_func() { - println!("async_func was covered"); - let b = true; - if b { - println!("async_func println in block"); - } -} - -async fn async_func_just_println() { - println!("async_func_just_println was covered"); -} - -fn main() { - println!("codecovsample::main"); - - non_async_func(); - - executor::block_on(async_func()); - executor::block_on(async_func_just_println()); -} - -mod executor { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; - - pub fn block_on(mut future: F) -> F::Output { - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - use std::hint::unreachable_unchecked; - static VTABLE: RawWakerVTable = RawWakerVTable::new( - |_| unsafe { unreachable_unchecked() }, // clone - |_| unsafe { unreachable_unchecked() }, // wake - |_| unsafe { unreachable_unchecked() }, // wake_by_ref - |_| (), - ); - let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - let mut context = Context::from_waker(&waker); - - loop { - if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - break val; - } - } - } -} diff --git a/tests/coverage-map/auxiliary/inline_always_with_dead_code.rs b/tests/coverage-map/auxiliary/inline_always_with_dead_code.rs deleted file mode 100644 index 9dc50dae25ae2..0000000000000 --- a/tests/coverage-map/auxiliary/inline_always_with_dead_code.rs +++ /dev/null @@ -1,22 +0,0 @@ -// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0 - -#![allow(dead_code)] - -mod foo { - #[inline(always)] - pub fn called() {} - - fn uncalled() {} -} - -pub mod bar { - pub fn call_me() { - super::foo::called(); - } -} - -pub mod baz { - pub fn call_me() { - super::foo::called(); - } -} diff --git a/tests/coverage-map/auxiliary/unused_mod_helper.rs b/tests/coverage-map/auxiliary/unused_mod_helper.rs deleted file mode 100644 index 88c5dac65cb50..0000000000000 --- a/tests/coverage-map/auxiliary/unused_mod_helper.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[allow(dead_code)] -pub fn never_called_function() { - println!("I am never called"); -} diff --git a/tests/coverage-map/auxiliary/used_crate.rs b/tests/coverage-map/auxiliary/used_crate.rs deleted file mode 100644 index c086ef21e1a9f..0000000000000 --- a/tests/coverage-map/auxiliary/used_crate.rs +++ /dev/null @@ -1,103 +0,0 @@ -#![allow(unused_assignments, unused_variables)] -// Verify that coverage works with optimizations: -// compile-flags: -C opt-level=3 - -use std::fmt::Debug; - -pub fn used_function() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - let mut countdown = 0; - if is_true { - countdown = 10; - } - use_this_lib_crate(); -} - -pub fn used_only_from_bin_crate_generic_function(arg: T) { - println!("used_only_from_bin_crate_generic_function with {:?}", arg); -} -// Expect for above function: `Unexecuted instantiation` (see below) -pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); -} - -pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); -} - -pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); -} - -pub fn unused_generic_function(arg: T) { - println!("unused_generic_function with {:?}", arg); -} - -pub fn unused_function() { - let is_true = std::env::args().len() == 1; - let mut countdown = 2; - if !is_true { - countdown = 20; - } -} - -#[allow(dead_code)] -fn unused_private_function() { - let is_true = std::env::args().len() == 1; - let mut countdown = 2; - if !is_true { - countdown = 20; - } -} - -fn use_this_lib_crate() { - used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); - used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - "used from library used_crate.rs", - ); - let some_vec = vec![5, 6, 7, 8]; - used_only_from_this_lib_crate_generic_function(some_vec); - used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); -} - -// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results, -// for example: -// -// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_> -// -// These notices appear when `llvm-cov` shows instantiations. This may be a -// default option, but it can be suppressed with: -// -// ```shell -// $ `llvm-cov show --show-instantiations=0 ...` -// ``` -// -// The notice is triggered because the function is unused by the library itself, -// and when the library is compiled, a synthetic function is generated, so -// unused function coverage can be reported. Coverage can be skipped for unused -// generic functions with: -// -// ```shell -// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...` -// ``` -// -// Even though this function is used by `uses_crate.rs` (and -// counted), with substitutions for `T`, those instantiations are only generated -// when the generic function is actually used (from the binary, not from this -// library crate). So the test result shows coverage for all instantiated -// versions and their generic type substitutions, plus the `Unexecuted -// instantiation` message for the non-substituted version. This is valid, but -// unfortunately a little confusing. -// -// The library crate has its own coverage map, and the only way to show unused -// coverage of a generic function is to include the generic function in the -// coverage map, marked as an "unused function". If the library were used by -// another binary that never used this generic function, then it would be valid -// to show the unused generic, with unknown substitution (`_`). -// -// The alternative is to exclude all generics from being included in the "unused -// functions" list, which would then omit coverage results for -// `unused_generic_function()`, below. diff --git a/tests/coverage-map/auxiliary/used_inline_crate.rs b/tests/coverage-map/auxiliary/used_inline_crate.rs deleted file mode 100644 index e8929de6b360a..0000000000000 --- a/tests/coverage-map/auxiliary/used_inline_crate.rs +++ /dev/null @@ -1,85 +0,0 @@ -#![allow(unused_assignments, unused_variables)] -// Verify that coverage works with optimizations: -// compile-flags: -C opt-level=3 - -use std::fmt::Debug; - -pub fn used_function() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - let mut countdown = 0; - if is_true { - countdown = 10; - } - use_this_lib_crate(); -} - -#[inline(always)] -pub fn used_inline_function() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - let mut countdown = 0; - if is_true { - countdown = 10; - } - use_this_lib_crate(); -} - -#[inline(always)] -pub fn used_only_from_bin_crate_generic_function(arg: T) { - println!("used_only_from_bin_crate_generic_function with {:?}", arg); -} -// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`) - -#[inline(always)] -pub fn used_only_from_this_lib_crate_generic_function(arg: T) { - println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); -} - -#[inline(always)] -pub fn used_from_bin_crate_and_lib_crate_generic_function(arg: T) { - println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); -} - -#[inline(always)] -pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function(arg: T) { - println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); -} - -#[inline(always)] -pub fn unused_generic_function(arg: T) { - println!("unused_generic_function with {:?}", arg); -} - -#[inline(always)] -pub fn unused_function() { - let is_true = std::env::args().len() == 1; - let mut countdown = 2; - if !is_true { - countdown = 20; - } -} - -#[inline(always)] -#[allow(dead_code)] -fn unused_private_function() { - let is_true = std::env::args().len() == 1; - let mut countdown = 2; - if !is_true { - countdown = 20; - } -} - -fn use_this_lib_crate() { - used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); - used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - "used from library used_crate.rs", - ); - let some_vec = vec![5, 6, 7, 8]; - used_only_from_this_lib_crate_generic_function(some_vec); - used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); -} diff --git a/tests/coverage-map/bad_counter_ids.rs b/tests/coverage-map/bad_counter_ids.rs deleted file mode 100644 index ef5460102b70c..0000000000000 --- a/tests/coverage-map/bad_counter_ids.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![feature(coverage_attribute)] -// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 - -// Regression test for . -// -// If some coverage counters were removed by MIR optimizations, we need to take -// care not to refer to those counter IDs in coverage mappings, and instead -// replace them with a constant zero value. If we don't, `llvm-cov` might see -// a too-large counter ID and silently discard the entire function from its -// coverage reports. - -#[derive(Debug, PartialEq, Eq)] -struct Foo(u32); - -fn eq_good() { - println!("a"); - assert_eq!(Foo(1), Foo(1)); -} - -fn eq_good_message() { - println!("b"); - assert_eq!(Foo(1), Foo(1), "message b"); -} - -fn ne_good() { - println!("c"); - assert_ne!(Foo(1), Foo(3)); -} - -fn ne_good_message() { - println!("d"); - assert_ne!(Foo(1), Foo(3), "message d"); -} - -fn eq_bad() { - println!("e"); - assert_eq!(Foo(1), Foo(3)); -} - -fn eq_bad_message() { - println!("f"); - assert_eq!(Foo(1), Foo(3), "message f"); -} - -fn ne_bad() { - println!("g"); - assert_ne!(Foo(1), Foo(1)); -} - -fn ne_bad_message() { - println!("h"); - assert_ne!(Foo(1), Foo(1), "message h"); -} - -#[coverage(off)] -fn main() { - eq_good(); - eq_good_message(); - ne_good(); - ne_good_message(); - - assert!(std::panic::catch_unwind(eq_bad).is_err()); - assert!(std::panic::catch_unwind(eq_bad_message).is_err()); - assert!(std::panic::catch_unwind(ne_bad).is_err()); - assert!(std::panic::catch_unwind(ne_bad_message).is_err()); -} diff --git a/tests/coverage-map/closure.rs b/tests/coverage-map/closure.rs deleted file mode 100644 index 16a2c4e33bd48..0000000000000 --- a/tests/coverage-map/closure.rs +++ /dev/null @@ -1,220 +0,0 @@ -#![allow(unused_assignments, unused_variables)] -// compile-flags: -C opt-level=2 - -// This test used to be sensitive to certain coverage-specific hacks in -// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by -// . - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - let is_false = !is_true; - - let mut some_string = Some(String::from("the string content")); - println!( - "The string or alt: {}" - , - some_string - . - unwrap_or_else - ( - || - { - let mut countdown = 0; - if is_false { - countdown = 10; - } - "alt string 1".to_owned() - } - ) - ); - - some_string = Some(String::from("the string content")); - let - a - = - || - { - let mut countdown = 0; - if is_false { - countdown = 10; - } - "alt string 2".to_owned() - }; - println!( - "The string or alt: {}" - , - some_string - . - unwrap_or_else - ( - a - ) - ); - - some_string = None; - println!( - "The string or alt: {}" - , - some_string - . - unwrap_or_else - ( - || - { - let mut countdown = 0; - if is_false { - countdown = 10; - } - "alt string 3".to_owned() - } - ) - ); - - some_string = None; - let - a - = - || - { - let mut countdown = 0; - if is_false { - countdown = 10; - } - "alt string 4".to_owned() - }; - println!( - "The string or alt: {}" - , - some_string - . - unwrap_or_else - ( - a - ) - ); - - let - quote_closure - = - |val| - { - let mut countdown = 0; - if is_false { - countdown = 10; - } - format!("'{}'", val) - }; - println!( - "Repeated, quoted string: {:?}" - , - std::iter::repeat("repeat me") - .take(5) - .map - ( - quote_closure - ) - .collect::>() - ); - - let - _unused_closure - = - | - mut countdown - | - { - if is_false { - countdown = 10; - } - "closure should be unused".to_owned() - }; - - let mut countdown = 10; - let _short_unused_closure = | _unused_arg: u8 | countdown += 1; - - - let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); - let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); - let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); - - - - - let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") }; - - let _shortish_unused_closure = | _unused_arg: u8 | { - println!("not called") - }; - - let _as_short_unused_closure = | - _unused_arg: u8 - | { println!("not called") }; - - let _almost_as_short_unused_closure = | - _unused_arg: u8 - | { println!("not called") } - ; - - - - - - let _short_unused_closure_line_break_no_block = | _unused_arg: u8 | -println!("not called") - ; - - let _short_unused_closure_line_break_no_block2 = - | _unused_arg: u8 | - println!( - "not called" - ) - ; - - let short_used_not_covered_closure_line_break_no_block_embedded_branch = - | _unused_arg: u8 | - println!( - "not called: {}", - if is_true { "check" } else { "me" } - ) - ; - - let short_used_not_covered_closure_line_break_block_embedded_branch = - | _unused_arg: u8 | - { - println!( - "not called: {}", - if is_true { "check" } else { "me" } - ) - } - ; - - let short_used_covered_closure_line_break_no_block_embedded_branch = - | _unused_arg: u8 | - println!( - "not called: {}", - if is_true { "check" } else { "me" } - ) - ; - - let short_used_covered_closure_line_break_block_embedded_branch = - | _unused_arg: u8 | - { - println!( - "not called: {}", - if is_true { "check" } else { "me" } - ) - } - ; - - if is_false { - short_used_not_covered_closure_macro(0); - short_used_not_covered_closure_line_break_no_block_embedded_branch(0); - short_used_not_covered_closure_line_break_block_embedded_branch(0); - } - short_used_covered_closure_macro(0); - short_used_covered_closure_line_break_no_block_embedded_branch(0); - short_used_covered_closure_line_break_block_embedded_branch(0); -} diff --git a/tests/coverage-map/closure_bug.rs b/tests/coverage-map/closure_bug.rs deleted file mode 100644 index 739bc5f0b51c9..0000000000000 --- a/tests/coverage-map/closure_bug.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Regression test for #115930. -// All of these closures are identical, and should produce identical output in -// the coverage report. However, an unstable sort was causing them to be treated -// inconsistently when preparing coverage spans. - -fn main() { - let truthy = std::env::args().len() == 1; - - let a - = - | - | - if truthy { true } else { false }; - - a(); - if truthy { a(); } - - let b - = - | - | - if truthy { true } else { false }; - - b(); - if truthy { b(); } - - let c - = - | - | - if truthy { true } else { false }; - - c(); - if truthy { c(); } - - let d - = - | - | - if truthy { true } else { false }; - - d(); - if truthy { d(); } -} diff --git a/tests/coverage-map/closure_macro.rs b/tests/coverage-map/closure_macro.rs deleted file mode 100644 index 9b289141c2e54..0000000000000 --- a/tests/coverage-map/closure_macro.rs +++ /dev/null @@ -1,40 +0,0 @@ -// compile-flags: --edition=2018 -#![feature(coverage_attribute)] - -macro_rules! bail { - ($msg:literal $(,)?) => { - if $msg.len() > 0 { - println!("no msg"); - } else { - println!($msg); - } - return Err(String::from($msg)); - }; -} - -macro_rules! on_error { - ($value:expr, $error_message:expr) => { - $value.or_else(|e| { // FIXME(85000): no coverage in closure macros - let message = format!($error_message, e); - if message.len() > 0 { - println!("{}", message); - Ok(String::from("ok")) - } else { - bail!("error"); - } - }) - }; -} - -fn load_configuration_files() -> Result { - Ok(String::from("config")) -} - -pub fn main() -> Result<(), String> { - println!("Starting service"); - let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; - - let startup_delay_duration = String::from("arg"); - let _ = (config, startup_delay_duration); - Ok(()) -} diff --git a/tests/coverage-map/closure_macro_async.rs b/tests/coverage-map/closure_macro_async.rs deleted file mode 100644 index b4275599e5991..0000000000000 --- a/tests/coverage-map/closure_macro_async.rs +++ /dev/null @@ -1,77 +0,0 @@ -// compile-flags: --edition=2018 -#![feature(coverage_attribute)] - -macro_rules! bail { - ($msg:literal $(,)?) => { - if $msg.len() > 0 { - println!("no msg"); - } else { - println!($msg); - } - return Err(String::from($msg)); - }; -} - -macro_rules! on_error { - ($value:expr, $error_message:expr) => { - $value.or_else(|e| { // FIXME(85000): no coverage in closure macros - let message = format!($error_message, e); - if message.len() > 0 { - println!("{}", message); - Ok(String::from("ok")) - } else { - bail!("error"); - } - }) - }; -} - -fn load_configuration_files() -> Result { - Ok(String::from("config")) -} - -pub async fn test() -> Result<(), String> { - println!("Starting service"); - let config = on_error!(load_configuration_files(), "Error loading configs: {}")?; - - let startup_delay_duration = String::from("arg"); - let _ = (config, startup_delay_duration); - Ok(()) -} - -#[coverage(off)] -fn main() { - executor::block_on(test()).unwrap(); -} - -mod executor { - use core::{ - future::Future, - pin::Pin, - task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, - }; - - #[coverage(off)] - pub fn block_on(mut future: F) -> F::Output { - let mut future = unsafe { Pin::new_unchecked(&mut future) }; - use std::hint::unreachable_unchecked; - static VTABLE: RawWakerVTable = RawWakerVTable::new( - #[coverage(off)] - |_| unsafe { unreachable_unchecked() }, // clone - #[coverage(off)] - |_| unsafe { unreachable_unchecked() }, // wake - #[coverage(off)] - |_| unsafe { unreachable_unchecked() }, // wake_by_ref - #[coverage(off)] - |_| (), - ); - let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; - let mut context = Context::from_waker(&waker); - - loop { - if let Poll::Ready(val) = future.as_mut().poll(&mut context) { - break val; - } - } - } -} diff --git a/tests/coverage-map/conditions.rs b/tests/coverage-map/conditions.rs deleted file mode 100644 index fa7f2a116c21e..0000000000000 --- a/tests/coverage-map/conditions.rs +++ /dev/null @@ -1,86 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - let mut countdown = 0; - if true { - countdown = 10; - } - - const B: u32 = 100; - let x = if countdown > 7 { - countdown -= 4; - B - } else if countdown > 2 { - if countdown < 1 || countdown > 5 || countdown != 9 { - countdown = 0; - } - countdown -= 5; - countdown - } else { - return; - }; - - let mut countdown = 0; - if true { - countdown = 10; - } - - if countdown > 7 { - countdown -= 4; - } else if countdown > 2 { - if countdown < 1 || countdown > 5 || countdown != 9 { - countdown = 0; - } - countdown -= 5; - } else { - return; - } - - if true { - let mut countdown = 0; - if true { - countdown = 10; - } - - if countdown > 7 { - countdown -= 4; - } - else if countdown > 2 { - if countdown < 1 || countdown > 5 || countdown != 9 { - countdown = 0; - } - countdown -= 5; - } else { - return; - } - } - - let mut countdown = 0; - if true { - countdown = 1; - } - - let z = if countdown > 7 { - countdown -= 4; - } else if countdown > 2 { - if countdown < 1 || countdown > 5 || countdown != 9 { - countdown = 0; - } - countdown -= 5; - } else { - let should_be_reachable = countdown; - println!("reached"); - return; - }; - - let w = if countdown > 7 { - countdown -= 4; - } else if countdown > 2 { - if countdown < 1 || countdown > 5 || countdown != 9 { - countdown = 0; - } - countdown -= 5; - } else { - return; - }; -} diff --git a/tests/coverage-map/continue.rs b/tests/coverage-map/continue.rs deleted file mode 100644 index 624aa98341b80..0000000000000 --- a/tests/coverage-map/continue.rs +++ /dev/null @@ -1,69 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - let is_true = std::env::args().len() == 1; - - let mut x = 0; - for _ in 0..10 { - match is_true { - true => { - continue; - } - _ => { - x = 1; - } - } - x = 3; - } - for _ in 0..10 { - match is_true { - false => { - x = 1; - } - _ => { - continue; - } - } - x = 3; - } - for _ in 0..10 { - match is_true { - true => { - x = 1; - } - _ => { - continue; - } - } - x = 3; - } - for _ in 0..10 { - if is_true { - continue; - } - x = 3; - } - for _ in 0..10 { - match is_true { - false => { - x = 1; - } - _ => { - let _ = x; - } - } - x = 3; - } - for _ in 0..10 { - match is_true { - false => { - x = 1; - } - _ => { - break; - } - } - x = 3; - } - let _ = x; -} diff --git a/tests/coverage-map/coroutine.rs b/tests/coverage-map/coroutine.rs deleted file mode 100644 index 86d19af6f4f08..0000000000000 --- a/tests/coverage-map/coroutine.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![feature(coroutines, coroutine_trait)] - -use std::ops::{Coroutine, CoroutineState}; -use std::pin::Pin; - -// The following implementation of a function called from a `yield` statement -// (apparently requiring the Result and the `String` type or constructor) -// creates conditions where the `coroutine::StateTransform` MIR transform will -// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic -// to handle this condition, and still report dead block coverage. -fn get_u32(val: bool) -> Result { - if val { Ok(1) } else { Err(String::from("some error")) } -} - -fn main() { - let is_true = std::env::args().len() == 1; - let mut coroutine = || { - yield get_u32(is_true); - return "foo"; - }; - - match Pin::new(&mut coroutine).resume(()) { - CoroutineState::Yielded(Ok(1)) => {} - _ => panic!("unexpected return from resume"), - } - match Pin::new(&mut coroutine).resume(()) { - CoroutineState::Complete("foo") => {} - _ => panic!("unexpected return from resume"), - } -} diff --git a/tests/coverage-map/dead_code.rs b/tests/coverage-map/dead_code.rs deleted file mode 100644 index 3492712a6f98e..0000000000000 --- a/tests/coverage-map/dead_code.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![allow(dead_code, unused_assignments, unused_variables)] - -pub fn unused_pub_fn_not_in_library() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - if is_true { - countdown = 10; - } -} - -fn unused_fn() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - if is_true { - countdown = 10; - } -} - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - if is_true { - countdown = 10; - } -} diff --git a/tests/coverage-map/drop_trait.rs b/tests/coverage-map/drop_trait.rs deleted file mode 100644 index 7b062719c6b02..0000000000000 --- a/tests/coverage-map/drop_trait.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![allow(unused_assignments)] -// failure-status: 1 - -struct Firework { - strength: i32, -} - -impl Drop for Firework { - fn drop(&mut self) { - println!("BOOM times {}!!!", self.strength); - } -} - -fn main() -> Result<(), u8> { - let _firecracker = Firework { strength: 1 }; - - let _tnt = Firework { strength: 100 }; - - if true { - println!("Exiting with error..."); - return Err(1); - } - - let _ = Firework { strength: 1000 }; - - Ok(()) -} - -// Expected program output: -// Exiting with error... -// BOOM times 100!!! -// BOOM times 1!!! -// Error: 1 diff --git a/tests/coverage-map/fn_sig_into_try.rs b/tests/coverage-map/fn_sig_into_try.rs deleted file mode 100644 index 92850c8a188fc..0000000000000 --- a/tests/coverage-map/fn_sig_into_try.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![feature(coverage_attribute)] -// compile-flags: --edition=2021 - -// Regression test for inconsistent handling of function signature spans that -// are followed by code using the `?` operator. -// -// For each of these similar functions, the line containing the function -// signature should be handled in the same way. - -fn a() -> Option -{ - Some(7i32); - Some(0) -} - -fn b() -> Option -{ - Some(7i32)?; - Some(0) -} - -fn c() -> Option -{ - let _ = Some(7i32)?; - Some(0) -} - -fn d() -> Option -{ - let _: () = (); - Some(7i32)?; - Some(0) -} - -#[coverage(off)] -fn main() { - a(); - b(); - c(); - d(); -} diff --git a/tests/coverage-map/generics.rs b/tests/coverage-map/generics.rs deleted file mode 100644 index bf4c2d8d68532..0000000000000 --- a/tests/coverage-map/generics.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![allow(unused_assignments)] -// failure-status: 1 - -struct Firework where T: Copy + std::fmt::Display { - strength: T, -} - -impl Firework where T: Copy + std::fmt::Display { - #[inline(always)] - fn set_strength(&mut self, new_strength: T) { - self.strength = new_strength; - } -} - -impl Drop for Firework where T: Copy + std::fmt::Display { - #[inline(always)] - fn drop(&mut self) { - println!("BOOM times {}!!!", self.strength); - } -} - -fn main() -> Result<(), u8> { - let mut firecracker = Firework { strength: 1 }; - firecracker.set_strength(2); - - let mut tnt = Firework { strength: 100.1 }; - tnt.set_strength(200.1); - tnt.set_strength(300.3); - - if true { - println!("Exiting with error..."); - return Err(1); - } - - let _ = Firework { strength: 1000 }; - - Ok(()) -} - -// Expected program output: -// Exiting with error... -// BOOM times 100!!! -// BOOM times 1!!! -// Error: 1 diff --git a/tests/coverage-map/if.rs b/tests/coverage-map/if.rs deleted file mode 100644 index 8ad5042ff7baf..0000000000000 --- a/tests/coverage-map/if.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let - is_true - = - std::env::args().len() - == - 1 - ; - let - mut - countdown - = - 0 - ; - if - is_true - { - countdown - = - 10 - ; - } -} diff --git a/tests/coverage-map/if_else.rs b/tests/coverage-map/if_else.rs deleted file mode 100644 index 3244e1e3afd2b..0000000000000 --- a/tests/coverage-map/if_else.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - if - is_true - { - countdown - = - 10 - ; - } - else // Note coverage region difference without semicolon - { - countdown - = - 100 - } - - if - is_true - { - countdown - = - 10 - ; - } - else - { - countdown - = - 100 - ; - } -} diff --git a/tests/coverage-map/inline-dead.rs b/tests/coverage-map/inline-dead.rs deleted file mode 100644 index 854fa06296752..0000000000000 --- a/tests/coverage-map/inline-dead.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Regression test for issue #98833. -// compile-flags: -Zinline-mir -Cdebug-assertions=off - -fn main() { - println!("{}", live::()); - - let f = |x: bool| { - debug_assert!( - x - ); - }; - f(false); -} - -#[inline] -fn live() -> u32 { - if B { - dead() - } else { - 0 - } -} - -#[inline] -fn dead() -> u32 { - 42 -} diff --git a/tests/coverage-map/inline.rs b/tests/coverage-map/inline.rs deleted file mode 100644 index 9cfab9ddbadf2..0000000000000 --- a/tests/coverage-map/inline.rs +++ /dev/null @@ -1,51 +0,0 @@ -// compile-flags: -Zinline-mir - -use std::fmt::Display; - -fn main() { - permutations(&['a', 'b', 'c']); -} - -#[inline(always)] -fn permutations(xs: &[T]) { - let mut ys = xs.to_owned(); - permutate(&mut ys, 0); -} - -fn permutate(xs: &mut [T], k: usize) { - let n = length(xs); - if k == n { - display(xs); - } else if k < n { - for i in k..n { - swap(xs, i, k); - permutate(xs, k + 1); - swap(xs, i, k); - } - } else { - error(); - } -} - -fn length(xs: &[T]) -> usize { - xs.len() -} - -#[inline] -fn swap(xs: &mut [T], i: usize, j: usize) { - let t = xs[i]; - xs[i] = xs[j]; - xs[j] = t; -} - -fn display(xs: &[T]) { - for x in xs { - print!("{}", x); - } - println!(); -} - -#[inline(always)] -fn error() { - panic!("error"); -} diff --git a/tests/coverage-map/inner_items.rs b/tests/coverage-map/inner_items.rs deleted file mode 100644 index bcb62b3031cd9..0000000000000 --- a/tests/coverage-map/inner_items.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![allow(unused_assignments, unused_variables, dead_code)] - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - if is_true { - countdown = 10; - } - - mod in_mod { - const IN_MOD_CONST: u32 = 1000; - } - - fn in_func(a: u32) { - let b = 1; - let c = a + b; - println!("c = {}", c) - } - - struct InStruct { - in_struct_field: u32, - } - - const IN_CONST: u32 = 1234; - - trait InTrait { - fn trait_func(&mut self, incr: u32); - - fn default_trait_func(&mut self) { - in_func(IN_CONST); - self.trait_func(IN_CONST); - } - } - - impl InTrait for InStruct { - fn trait_func(&mut self, incr: u32) { - self.in_struct_field += incr; - in_func(self.in_struct_field); - } - } - - type InType = String; - - if is_true { - in_func(countdown); - } - - let mut val = InStruct { - in_struct_field: 101, - }; - - val.default_trait_func(); -} diff --git a/tests/coverage-map/issue-83601.rs b/tests/coverage-map/issue-83601.rs deleted file mode 100644 index 0b72a81947cc7..0000000000000 --- a/tests/coverage-map/issue-83601.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Shows that rust-lang/rust/83601 is resolved - -#[derive(Debug, PartialEq, Eq)] -struct Foo(u32); - -fn main() { - let bar = Foo(1); - assert_eq!(bar, Foo(1)); - let baz = Foo(0); - assert_ne!(baz, Foo(1)); - println!("{:?}", Foo(1)); - println!("{:?}", bar); - println!("{:?}", baz); -} diff --git a/tests/coverage-map/issue-84561.rs b/tests/coverage-map/issue-84561.rs deleted file mode 100644 index facf5b5b4cfbe..0000000000000 --- a/tests/coverage-map/issue-84561.rs +++ /dev/null @@ -1,182 +0,0 @@ -// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results. - -// failure-status: 101 -#[derive(PartialEq, Eq)] -struct Foo(u32); -fn test3() { - let is_true = std::env::args().len() == 1; - let bar = Foo(1); - assert_eq!(bar, Foo(1)); - let baz = Foo(0); - assert_ne!(baz, Foo(1)); - println!("{:?}", Foo(1)); - println!("{:?}", bar); - println!("{:?}", baz); - - assert_eq!(Foo(1), Foo(1)); - assert_ne!(Foo(0), Foo(1)); - assert_eq!(Foo(2), Foo(2)); - let bar = Foo(0); - assert_ne!(bar, Foo(3)); - assert_ne!(Foo(0), Foo(4)); - assert_eq!(Foo(3), Foo(3), "with a message"); - println!("{:?}", bar); - println!("{:?}", Foo(1)); - - assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" }); - assert_ne!( - Foo(0) - , - Foo(5) - , - "{}" - , - if - is_true - { - "true message" - } else { - "false message" - } - ); - - let is_true = std::env::args().len() == 1; - - assert_eq!( - Foo(1), - Foo(1) - ); - assert_ne!( - Foo(0), - Foo(1) - ); - assert_eq!( - Foo(2), - Foo(2) - ); - let bar = Foo(1); - assert_ne!( - bar, - Foo(3) - ); - if is_true { - assert_ne!( - Foo(0), - Foo(4) - ); - } else { - assert_eq!( - Foo(3), - Foo(3) - ); - } - if is_true { - assert_ne!( - Foo(0), - Foo(4), - "with a message" - ); - } else { - assert_eq!( - Foo(3), - Foo(3), - "with a message" - ); - } - assert_ne!( - if is_true { - Foo(0) - } else { - Foo(1) - }, - Foo(5) - ); - assert_ne!( - Foo(5), - if is_true { - Foo(0) - } else { - Foo(1) - } - ); - assert_ne!( - if is_true { - assert_eq!( - Foo(3), - Foo(3) - ); - Foo(0) - } else { - assert_ne!( - if is_true { - Foo(0) - } else { - Foo(1) - }, - Foo(5) - ); - Foo(1) - }, - Foo(5), - "with a message" - ); - assert_eq!( - Foo(1), - Foo(3), - "this assert should fail" - ); - assert_eq!( - Foo(3), - Foo(3), - "this assert should not be reached" - ); -} - -impl std::fmt::Debug for Foo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "try and succeed")?; - Ok(()) - } -} - -static mut DEBUG_LEVEL_ENABLED: bool = false; - -macro_rules! debug { - ($($arg:tt)+) => ( - if unsafe { DEBUG_LEVEL_ENABLED } { - println!($($arg)+); - } - ); -} - -fn test1() { - debug!("debug is enabled"); - debug!("debug is enabled"); - let _ = 0; - debug!("debug is enabled"); - unsafe { - DEBUG_LEVEL_ENABLED = true; - } - debug!("debug is enabled"); -} - -macro_rules! call_debug { - ($($arg:tt)+) => ( - fn call_print(s: &str) { - print!("{}", s); - } - - call_print("called from call_debug: "); - debug!($($arg)+); - ); -} - -fn test2() { - call_debug!("debug is enabled"); -} - -fn main() { - test1(); - test2(); - test3(); -} diff --git a/tests/coverage-map/issue-85461.rs b/tests/coverage-map/issue-85461.rs deleted file mode 100644 index 9d4c90a827eeb..0000000000000 --- a/tests/coverage-map/issue-85461.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)] - -// aux-build:inline_always_with_dead_code.rs -extern crate inline_always_with_dead_code; - -use inline_always_with_dead_code::{bar, baz}; - -fn main() { - bar::call_me(); - baz::call_me(); -} diff --git a/tests/coverage-map/issue-93054.rs b/tests/coverage-map/issue-93054.rs deleted file mode 100644 index da546cfeef854..0000000000000 --- a/tests/coverage-map/issue-93054.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![allow(dead_code, unreachable_code)] - -// Regression test for #93054: Functions using uninhabited types often only have a single, -// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail. -// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them. - -// compile-flags: --edition=2021 - -enum Never {} - -impl Never { - fn foo(self) { - match self {} - make().map(|never| match never {}); - } - - fn bar(&self) { - match *self {} - } -} - -async fn foo2(never: Never) { - match never {} -} - -fn make() -> Option { - None -} - -fn main() {} diff --git a/tests/coverage-map/lazy_boolean.rs b/tests/coverage-map/lazy_boolean.rs deleted file mode 100644 index bb6219e851c8a..0000000000000 --- a/tests/coverage-map/lazy_boolean.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let (mut a, mut b, mut c) = (0, 0, 0); - if is_true { - a = 1; - b = 10; - c = 100; - } - let - somebool - = - a < b - || - b < c - ; - let - somebool - = - b < a - || - b < c - ; - let somebool = a < b && b < c; - let somebool = b < a && b < c; - - if - ! - is_true - { - a = 2 - ; - } - - if - is_true - { - b = 30 - ; - } - else - { - c = 400 - ; - } - - if !is_true { - a = 2; - } - - if is_true { - b = 30; - } else { - c = 400; - } -} diff --git a/tests/coverage-map/long_and_wide.rs b/tests/coverage-map/long_and_wide.rs deleted file mode 100644 index a7cbcd4802791..0000000000000 --- a/tests/coverage-map/long_and_wide.rs +++ /dev/null @@ -1,150 +0,0 @@ -// compile-flags: --edition=2021 -// ignore-tidy-linelength - -// This file deliberately contains line and column numbers larger than 127, -// to verify that `coverage-dump`'s ULEB128 parser can handle them. - -fn main() { - wide_function(); - long_function(); - far_function(); -} - -#[rustfmt::skip] -fn wide_function() { /* */ (); } - -fn long_function() { - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // -} - -fn far_function() {} diff --git a/tests/coverage-map/loop_break_value.rs b/tests/coverage-map/loop_break_value.rs deleted file mode 100644 index dbc4fad7a2316..0000000000000 --- a/tests/coverage-map/loop_break_value.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - let result - = - loop - { - break - 10 - ; - } - ; -} diff --git a/tests/coverage-map/loops_branches.rs b/tests/coverage-map/loops_branches.rs deleted file mode 100644 index f3a343bcc1f42..0000000000000 --- a/tests/coverage-map/loops_branches.rs +++ /dev/null @@ -1,60 +0,0 @@ -#![allow(unused_assignments, unused_variables, while_true)] - -// This test confirms that (1) unexecuted infinite loops are handled correctly by the -// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped. - -struct DebugTest; - -impl std::fmt::Debug for DebugTest { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - if true { - if false { - while true {} - } - write!(f, "cool")?; - } else { - } - - for i in 0..10 { - if true { - if false { - while true {} - } - write!(f, "cool")?; - } else { - } - } - Ok(()) - } -} - -struct DisplayTest; - -impl std::fmt::Display for DisplayTest { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - if false { - } else { - if false { - while true {} - } - write!(f, "cool")?; - } - for i in 0..10 { - if false { - } else { - if false { - while true {} - } - write!(f, "cool")?; - } - } - Ok(()) - } -} - -fn main() { - let debug_test = DebugTest; - println!("{:?}", debug_test); - let display_test = DisplayTest; - println!("{}", display_test); -} diff --git a/tests/coverage-map/match_or_pattern.rs b/tests/coverage-map/match_or_pattern.rs deleted file mode 100644 index ab7aee51d1bc4..0000000000000 --- a/tests/coverage-map/match_or_pattern.rs +++ /dev/null @@ -1,43 +0,0 @@ -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut a: u8 = 0; - let mut b: u8 = 0; - if is_true { - a = 2; - b = 0; - } - match (a, b) { - // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`. - // This test confirms a fix for Issue #79569. - (0 | 1, 2 | 3) => {} - _ => {} - } - if is_true { - a = 0; - b = 0; - } - match (a, b) { - (0 | 1, 2 | 3) => {} - _ => {} - } - if is_true { - a = 2; - b = 2; - } - match (a, b) { - (0 | 1, 2 | 3) => {} - _ => {} - } - if is_true { - a = 0; - b = 2; - } - match (a, b) { - (0 | 1, 2 | 3) => {} - _ => {} - } -} diff --git a/tests/coverage-map/nested_loops.rs b/tests/coverage-map/nested_loops.rs deleted file mode 100644 index 4c7c784279650..0000000000000 --- a/tests/coverage-map/nested_loops.rs +++ /dev/null @@ -1,25 +0,0 @@ -fn main() { - let is_true = std::env::args().len() == 1; - let mut countdown = 10; - - 'outer: while countdown > 0 { - let mut a = 100; - let mut b = 100; - for _ in 0..50 { - if a < 30 { - break; - } - a -= 5; - b -= 5; - if b < 90 { - a -= 10; - if is_true { - break 'outer; - } else { - a -= 2; - } - } - } - countdown -= 1; - } -} diff --git a/tests/coverage-map/no_cov_crate.rs b/tests/coverage-map/no_cov_crate.rs deleted file mode 100644 index e12e4bc55e3e4..0000000000000 --- a/tests/coverage-map/no_cov_crate.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Enables `coverage(off)` on the entire crate -#![feature(coverage_attribute)] - -#[coverage(off)] -fn do_not_add_coverage_1() { - println!("called but not covered"); -} - -fn do_not_add_coverage_2() { - #![coverage(off)] - println!("called but not covered"); -} - -#[coverage(off)] -#[allow(dead_code)] -fn do_not_add_coverage_not_called() { - println!("not called and not covered"); -} - -fn add_coverage_1() { - println!("called and covered"); -} - -fn add_coverage_2() { - println!("called and covered"); -} - -#[allow(dead_code)] -fn add_coverage_not_called() { - println!("not called but covered"); -} - -// FIXME: These test-cases illustrate confusing results of nested functions. -// See https://github.com/rust-lang/rust/issues/93319 -mod nested_fns { - #[coverage(off)] - pub fn outer_not_covered(is_true: bool) { - fn inner(is_true: bool) { - if is_true { - println!("called and covered"); - } else { - println!("absolutely not covered"); - } - } - println!("called but not covered"); - inner(is_true); - } - - pub fn outer(is_true: bool) { - println!("called and covered"); - inner_not_covered(is_true); - - #[coverage(off)] - fn inner_not_covered(is_true: bool) { - if is_true { - println!("called but not covered"); - } else { - println!("absolutely not covered"); - } - } - } - - pub fn outer_both_covered(is_true: bool) { - println!("called and covered"); - inner(is_true); - - fn inner(is_true: bool) { - if is_true { - println!("called and covered"); - } else { - println!("absolutely not covered"); - } - } - } -} - -fn main() { - let is_true = std::env::args().len() == 1; - - do_not_add_coverage_1(); - do_not_add_coverage_2(); - add_coverage_1(); - add_coverage_2(); - - nested_fns::outer_not_covered(is_true); - nested_fns::outer(is_true); - nested_fns::outer_both_covered(is_true); -} diff --git a/tests/coverage-map/overflow.rs b/tests/coverage-map/overflow.rs deleted file mode 100644 index 1c40771b27478..0000000000000 --- a/tests/coverage-map/overflow.rs +++ /dev/null @@ -1,64 +0,0 @@ -#![allow(unused_assignments)] -// compile-flags: -Coverflow-checks=yes -// failure-status: 101 - -fn might_overflow(to_add: u32) -> u32 { - if to_add > 5 { - println!("this will probably overflow"); - } - let add_to = u32::MAX - 5; - println!("does {} + {} overflow?", add_to, to_add); - let result = to_add + add_to; - println!("continuing after overflow check"); - result -} - -fn main() -> Result<(), u8> { - let mut countdown = 10; - while countdown > 0 { - if countdown == 1 { - let result = might_overflow(10); - println!("Result: {}", result); - } else if countdown < 5 { - let result = might_overflow(1); - println!("Result: {}", result); - } - countdown -= 1; - } - Ok(()) -} - -// Notes: -// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`, -// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`. -// 2. This test confirms the coverage generated when a program passes or fails a -// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case). -// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`, -// compiler-generated assertion failures are assumed to be a symptom of a program bug, not -// expected behavior. To simplify the coverage graphs and keep instrumented programs as -// small and fast as possible, `Assert` terminators are assumed to always succeed, and -// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not -// get its own coverage counter. -// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive. -// In this test, the final count for the statements after the `if` block in `might_overflow()` -// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending -// on the MIR graph and the structure of the code, this count could have been 3 (which might -// have been valid for the overflowed add `+`, but should have been 4 for the lines before -// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented -// via StatementKind::Counter at the end of the block, but (as in the case in this test), -// a CounterKind::Expression is always evaluated. In this case, the expression was based on -// a `Counter` incremented as part of the evaluation of the `if` expression, which was -// executed, and counted, 4 times, before reaching the overflow add. - -// If the program did not overflow, the coverage for `might_overflow()` would look like this: -// -// 4| |fn might_overflow(to_add: u32) -> u32 { -// 5| 4| if to_add > 5 { -// 6| 0| println!("this will probably overflow"); -// 7| 4| } -// 8| 4| let add_to = u32::MAX - 5; -// 9| 4| println!("does {} + {} overflow?", add_to, to_add); -// 10| 4| let result = to_add + add_to; -// 11| 4| println!("continuing after overflow check"); -// 12| 4| result -// 13| 4|} diff --git a/tests/coverage-map/panic_unwind.rs b/tests/coverage-map/panic_unwind.rs deleted file mode 100644 index 638d2eb6aaaf8..0000000000000 --- a/tests/coverage-map/panic_unwind.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![allow(unused_assignments)] -// failure-status: 101 - -fn might_panic(should_panic: bool) { - if should_panic { - println!("panicking..."); - panic!("panics"); - } else { - println!("Don't Panic"); - } -} - -fn main() -> Result<(), u8> { - let mut countdown = 10; - while countdown > 0 { - if countdown == 1 { - might_panic(true); - } else if countdown < 5 { - might_panic(false); - } - countdown -= 1; - } - Ok(()) -} - -// Notes: -// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and -// `try_error_result.rs`. -// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the -// normal program exit cleanup, including writing out the current values of the coverage -// counters. diff --git a/tests/coverage-map/partial_eq.rs b/tests/coverage-map/partial_eq.rs deleted file mode 100644 index dd8b42c18cea9..0000000000000 --- a/tests/coverage-map/partial_eq.rs +++ /dev/null @@ -1,46 +0,0 @@ -// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the -// structure of this test. - -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] -pub struct Version { - major: usize, - minor: usize, - patch: usize, -} - -impl Version { - pub fn new(major: usize, minor: usize, patch: usize) -> Self { - Self { - major, - minor, - patch, - } - } -} - -fn main() { - let version_3_2_1 = Version::new(3, 2, 1); - let version_3_3_0 = Version::new(3, 3, 0); - - println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0); -} - -/* - -This test verifies a bug was fixed that otherwise generated this error: - -thread 'rustc' panicked at 'No counters provided the source_hash for function: - Instance { - def: Item(WithOptConstParam { - did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp), - const_param_did: None - }), - args: [] - }' -The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage -without a code region associated with any `Counter`. Code regions were associated with at least -one expression, which is allowed, but the `function_source_hash` was only passed to the codegen -(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the -`function_source_hash` without a code region, if necessary. - -*/ diff --git a/tests/coverage-map/simple_loop.rs b/tests/coverage-map/simple_loop.rs deleted file mode 100644 index 6f7f23475b826..0000000000000 --- a/tests/coverage-map/simple_loop.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![allow(unused_assignments)] - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - - if - is_true - { - countdown - = - 10 - ; - } - - loop - { - if - countdown - == - 0 - { - break - ; - } - countdown - -= - 1 - ; - } -} diff --git a/tests/coverage-map/simple_match.rs b/tests/coverage-map/simple_match.rs deleted file mode 100644 index be99e59a82685..0000000000000 --- a/tests/coverage-map/simple_match.rs +++ /dev/null @@ -1,43 +0,0 @@ -#![allow(unused_assignments, unused_variables)] - -fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 1; - if is_true { - countdown = 0; - } - - for - _ - in - 0..2 - { - let z - ; - match - countdown - { - x - if - x - < - 1 - => - { - z = countdown - ; - let y = countdown - ; - countdown = 10 - ; - } - _ - => - {} - } - } -} diff --git a/tests/coverage-map/sort_groups.rs b/tests/coverage-map/sort_groups.rs deleted file mode 100644 index 5adbbc6a87d1f..0000000000000 --- a/tests/coverage-map/sort_groups.rs +++ /dev/null @@ -1,23 +0,0 @@ -// compile-flags: --edition=2021 - -// Demonstrate that `sort_subviews.py` can sort instantiation groups into a -// predictable order, while preserving their heterogeneous contents. - -fn main() { - let cond = std::env::args().len() > 1; - generic_fn::<()>(cond); - generic_fn::<&'static str>(!cond); - if std::hint::black_box(false) { - generic_fn::(cond); - } - generic_fn::(cond); - other_fn(); -} - -fn generic_fn(cond: bool) { - if cond { - println!("{}", std::any::type_name::()); - } -} - -fn other_fn() {} diff --git a/tests/coverage-map/test_harness.rs b/tests/coverage-map/test_harness.rs deleted file mode 100644 index 12a755734c198..0000000000000 --- a/tests/coverage-map/test_harness.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Verify that the entry point injected by the test harness doesn't cause -// weird artifacts in the coverage report (e.g. issue #10749). - -// compile-flags: --test - -#[allow(dead_code)] -fn unused() {} - -#[test] -fn my_test() {} diff --git a/tests/coverage-map/tight_inf_loop.rs b/tests/coverage-map/tight_inf_loop.rs deleted file mode 100644 index cef99027aaa4f..0000000000000 --- a/tests/coverage-map/tight_inf_loop.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - if false { - loop {} - } -} diff --git a/tests/coverage-map/trivial.rs b/tests/coverage-map/trivial.rs deleted file mode 100644 index d0a9b44fb3605..0000000000000 --- a/tests/coverage-map/trivial.rs +++ /dev/null @@ -1,3 +0,0 @@ -// compile-flags: --edition=2021 - -fn main() {} diff --git a/tests/coverage-map/try_error_result.rs b/tests/coverage-map/try_error_result.rs deleted file mode 100644 index 557cbf22bfad4..0000000000000 --- a/tests/coverage-map/try_error_result.rs +++ /dev/null @@ -1,118 +0,0 @@ -#![allow(unused_assignments)] -// failure-status: 1 - -fn call(return_error: bool) -> Result<(), ()> { - if return_error { - Err(()) - } else { - Ok(()) - } -} - -fn test1() -> Result<(), ()> { - let mut - countdown = 10 - ; - for - _ - in - 0..10 - { - countdown - -= 1 - ; - if - countdown < 5 - { - call(/*return_error=*/ true)?; - call(/*return_error=*/ false)?; - } - else - { - call(/*return_error=*/ false)?; - } - } - Ok(()) -} - -struct Thing1; -impl Thing1 { - fn get_thing_2(&self, return_error: bool) -> Result { - if return_error { - Err(()) - } else { - Ok(Thing2 {}) - } - } -} - -struct Thing2; -impl Thing2 { - fn call(&self, return_error: bool) -> Result { - if return_error { - Err(()) - } else { - Ok(57) - } - } -} - -fn test2() -> Result<(), ()> { - let thing1 = Thing1{}; - let mut - countdown = 10 - ; - for - _ - in - 0..10 - { - countdown - -= 1 - ; - if - countdown < 5 - { - thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail"); - thing1 - . - get_thing_2(/*return_error=*/ false) - ? - . - call(/*return_error=*/ true) - . - expect_err( - "call should fail" - ); - let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?; - assert_eq!(val, 57); - let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?; - assert_eq!(val, 57); - } - else - { - let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?; - assert_eq!(val, 57); - let val = thing1 - .get_thing_2(/*return_error=*/ false)? - .call(/*return_error=*/ false)?; - assert_eq!(val, 57); - let val = thing1 - .get_thing_2(/*return_error=*/ false) - ? - .call(/*return_error=*/ false) - ? - ; - assert_eq!(val, 57); - } - } - Ok(()) -} - -fn main() -> Result<(), ()> { - test1().expect_err("test1 should fail"); - test2() - ? - ; - Ok(()) -} diff --git a/tests/coverage-map/unreachable.rs b/tests/coverage-map/unreachable.rs deleted file mode 100644 index 6385bfa160d7d..0000000000000 --- a/tests/coverage-map/unreachable.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![feature(core_intrinsics)] -#![feature(coverage_attribute)] -// compile-flags: --edition=2021 - -// -// If we instrument a function for coverage, but all of its counter-increment -// statements are removed by MIR optimizations, LLVM will think it isn't -// instrumented and it will disappear from coverage maps and coverage reports. -// Most MIR opts won't cause this because they tend not to remove statements -// from bb0, but `UnreachablePropagation` can do so if it sees that bb0 ends -// with `TerminatorKind::Unreachable`. - -use std::hint::{black_box, unreachable_unchecked}; - -static UNREACHABLE_CLOSURE: fn() = || unsafe { unreachable_unchecked() }; - -fn unreachable_function() { - unsafe { unreachable_unchecked() } -} - -// Use an intrinsic to more reliably trigger unreachable-propagation. -fn unreachable_intrinsic() { - unsafe { std::intrinsics::unreachable() } -} - -#[coverage(off)] -fn main() { - if black_box(false) { - UNREACHABLE_CLOSURE(); - } - if black_box(false) { - unreachable_function(); - } - if black_box(false) { - unreachable_intrinsic(); - } -} diff --git a/tests/coverage-map/unused.rs b/tests/coverage-map/unused.rs deleted file mode 100644 index d985af135470e..0000000000000 --- a/tests/coverage-map/unused.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![allow(dead_code, unused_assignments, unused_must_use, unused_variables)] - -fn foo(x: T) { - let mut i = 0; - while i < 10 { - i != 0 || i != 0; - i += 1; - } -} - -fn unused_template_func(x: T) { - let mut i = 0; - while i < 10 { - i != 0 || i != 0; - i += 1; - } -} - -fn unused_func(mut a: u32) { - if a != 0 { - a += 1; - } -} - -fn unused_func2(mut a: u32) { - if a != 0 { - a += 1; - } -} - -fn unused_func3(mut a: u32) { - if a != 0 { - a += 1; - } -} - -fn main() -> Result<(), u8> { - foo::(0); - foo::(0.0); - Ok(()) -} diff --git a/tests/coverage-map/unused_mod.rs b/tests/coverage-map/unused_mod.rs deleted file mode 100644 index 6e62839c99856..0000000000000 --- a/tests/coverage-map/unused_mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[path = "auxiliary/unused_mod_helper.rs"] -mod unused_module; - -fn main() { - println!("hello world!"); -} diff --git a/tests/coverage-map/uses_crate.rs b/tests/coverage-map/uses_crate.rs deleted file mode 100644 index ab203ad781d66..0000000000000 --- a/tests/coverage-map/uses_crate.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This test was failing on Linux for a while due to #110393 somehow making -// the unused functions not instrumented, but it seems to be fine now. - -// Validates coverage now works with optimizations -// compile-flags: -C opt-level=3 - -#![allow(unused_assignments, unused_variables)] - -// aux-build:used_crate.rs -extern crate used_crate; - -fn main() { - used_crate::used_function(); - let some_vec = vec![1, 2, 3, 4]; - used_crate::used_only_from_bin_crate_generic_function(&some_vec); - used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); - used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); - used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); -} diff --git a/tests/coverage-map/uses_inline_crate.rs b/tests/coverage-map/uses_inline_crate.rs deleted file mode 100644 index d7b4c3c057f46..0000000000000 --- a/tests/coverage-map/uses_inline_crate.rs +++ /dev/null @@ -1,22 +0,0 @@ -// This test was failing on Linux for a while due to #110393 somehow making -// the unused functions not instrumented, but it seems to be fine now. - -// Validates coverage now works with optimizations -// compile-flags: -C opt-level=3 - -#![allow(unused_assignments, unused_variables)] - -// aux-build:used_inline_crate.rs -extern crate used_inline_crate; - -fn main() { - used_inline_crate::used_function(); - used_inline_crate::used_inline_function(); - let some_vec = vec![1, 2, 3, 4]; - used_inline_crate::used_only_from_bin_crate_generic_function(&some_vec); - used_inline_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); - used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); - used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - "interesting?", - ); -} diff --git a/tests/coverage-map/while.rs b/tests/coverage-map/while.rs deleted file mode 100644 index 781b90b35663e..0000000000000 --- a/tests/coverage-map/while.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let num = 9; - while num >= 10 { - } -} diff --git a/tests/coverage-map/while_early_ret.rs b/tests/coverage-map/while_early_ret.rs deleted file mode 100644 index b2f0eee2cc0f4..0000000000000 --- a/tests/coverage-map/while_early_ret.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![allow(unused_assignments)] -// failure-status: 1 - -fn main() -> Result<(), u8> { - let mut countdown = 10; - while - countdown - > - 0 - { - if - countdown - < - 5 - { - return - if - countdown - > - 8 - { - Ok(()) - } - else - { - Err(1) - } - ; - } - countdown - -= - 1 - ; - } - Ok(()) -} - -// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and -// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux -// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program -// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical -// to the coverage test for early returns, but this is a limitation that should be fixed. diff --git a/tests/coverage-map/yield.rs b/tests/coverage-map/yield.rs deleted file mode 100644 index b7e2ba31b59c1..0000000000000 --- a/tests/coverage-map/yield.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![feature(coroutines, coroutine_trait)] -#![allow(unused_assignments)] - -use std::ops::{Coroutine, CoroutineState}; -use std::pin::Pin; - -fn main() { - let mut coroutine = || { - yield 1; - return "foo"; - }; - - match Pin::new(&mut coroutine).resume(()) { - CoroutineState::Yielded(1) => {} - _ => panic!("unexpected value from resume"), - } - match Pin::new(&mut coroutine).resume(()) { - CoroutineState::Complete("foo") => {} - _ => panic!("unexpected value from resume"), - } - - let mut coroutine = || { - yield 1; - yield 2; - yield 3; - return "foo"; - }; - - match Pin::new(&mut coroutine).resume(()) { - CoroutineState::Yielded(1) => {} - _ => panic!("unexpected value from resume"), - } - match Pin::new(&mut coroutine).resume(()) { - CoroutineState::Yielded(2) => {} - _ => panic!("unexpected value from resume"), - } -} diff --git a/tests/coverage-map/README.md b/tests/coverage/README.md similarity index 100% rename from tests/coverage-map/README.md rename to tests/coverage/README.md diff --git a/tests/coverage-map/abort.cov-map b/tests/coverage/abort.cov-map similarity index 100% rename from tests/coverage-map/abort.cov-map rename to tests/coverage/abort.cov-map diff --git a/tests/coverage-map/assert.cov-map b/tests/coverage/assert.cov-map similarity index 100% rename from tests/coverage-map/assert.cov-map rename to tests/coverage/assert.cov-map diff --git a/tests/coverage-map/async.cov-map b/tests/coverage/async.cov-map similarity index 100% rename from tests/coverage-map/async.cov-map rename to tests/coverage/async.cov-map diff --git a/tests/coverage-map/async2.cov-map b/tests/coverage/async2.cov-map similarity index 100% rename from tests/coverage-map/async2.cov-map rename to tests/coverage/async2.cov-map diff --git a/tests/coverage-map/bad_counter_ids.cov-map b/tests/coverage/bad_counter_ids.cov-map similarity index 100% rename from tests/coverage-map/bad_counter_ids.cov-map rename to tests/coverage/bad_counter_ids.cov-map diff --git a/tests/coverage-map/closure.cov-map b/tests/coverage/closure.cov-map similarity index 100% rename from tests/coverage-map/closure.cov-map rename to tests/coverage/closure.cov-map diff --git a/tests/coverage-map/closure_bug.cov-map b/tests/coverage/closure_bug.cov-map similarity index 100% rename from tests/coverage-map/closure_bug.cov-map rename to tests/coverage/closure_bug.cov-map diff --git a/tests/coverage-map/closure_macro.cov-map b/tests/coverage/closure_macro.cov-map similarity index 100% rename from tests/coverage-map/closure_macro.cov-map rename to tests/coverage/closure_macro.cov-map diff --git a/tests/coverage-map/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map similarity index 100% rename from tests/coverage-map/closure_macro_async.cov-map rename to tests/coverage/closure_macro_async.cov-map diff --git a/tests/coverage-map/conditions.cov-map b/tests/coverage/conditions.cov-map similarity index 100% rename from tests/coverage-map/conditions.cov-map rename to tests/coverage/conditions.cov-map diff --git a/tests/coverage-map/continue.cov-map b/tests/coverage/continue.cov-map similarity index 100% rename from tests/coverage-map/continue.cov-map rename to tests/coverage/continue.cov-map diff --git a/tests/coverage-map/coroutine.cov-map b/tests/coverage/coroutine.cov-map similarity index 100% rename from tests/coverage-map/coroutine.cov-map rename to tests/coverage/coroutine.cov-map diff --git a/tests/coverage-map/dead_code.cov-map b/tests/coverage/dead_code.cov-map similarity index 100% rename from tests/coverage-map/dead_code.cov-map rename to tests/coverage/dead_code.cov-map diff --git a/tests/coverage-map/drop_trait.cov-map b/tests/coverage/drop_trait.cov-map similarity index 100% rename from tests/coverage-map/drop_trait.cov-map rename to tests/coverage/drop_trait.cov-map diff --git a/tests/coverage-map/fn_sig_into_try.cov-map b/tests/coverage/fn_sig_into_try.cov-map similarity index 100% rename from tests/coverage-map/fn_sig_into_try.cov-map rename to tests/coverage/fn_sig_into_try.cov-map diff --git a/tests/coverage-map/generics.cov-map b/tests/coverage/generics.cov-map similarity index 100% rename from tests/coverage-map/generics.cov-map rename to tests/coverage/generics.cov-map diff --git a/tests/coverage-map/if.cov-map b/tests/coverage/if.cov-map similarity index 100% rename from tests/coverage-map/if.cov-map rename to tests/coverage/if.cov-map diff --git a/tests/coverage-map/if_else.cov-map b/tests/coverage/if_else.cov-map similarity index 100% rename from tests/coverage-map/if_else.cov-map rename to tests/coverage/if_else.cov-map diff --git a/tests/coverage-map/inline-dead.cov-map b/tests/coverage/inline-dead.cov-map similarity index 100% rename from tests/coverage-map/inline-dead.cov-map rename to tests/coverage/inline-dead.cov-map diff --git a/tests/coverage-map/inline.cov-map b/tests/coverage/inline.cov-map similarity index 100% rename from tests/coverage-map/inline.cov-map rename to tests/coverage/inline.cov-map diff --git a/tests/coverage-map/inner_items.cov-map b/tests/coverage/inner_items.cov-map similarity index 100% rename from tests/coverage-map/inner_items.cov-map rename to tests/coverage/inner_items.cov-map diff --git a/tests/coverage-map/issue-83601.cov-map b/tests/coverage/issue-83601.cov-map similarity index 100% rename from tests/coverage-map/issue-83601.cov-map rename to tests/coverage/issue-83601.cov-map diff --git a/tests/coverage-map/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map similarity index 100% rename from tests/coverage-map/issue-84561.cov-map rename to tests/coverage/issue-84561.cov-map diff --git a/tests/coverage-map/issue-85461.cov-map b/tests/coverage/issue-85461.cov-map similarity index 100% rename from tests/coverage-map/issue-85461.cov-map rename to tests/coverage/issue-85461.cov-map diff --git a/tests/coverage-map/issue-93054.cov-map b/tests/coverage/issue-93054.cov-map similarity index 100% rename from tests/coverage-map/issue-93054.cov-map rename to tests/coverage/issue-93054.cov-map diff --git a/tests/coverage-map/lazy_boolean.cov-map b/tests/coverage/lazy_boolean.cov-map similarity index 100% rename from tests/coverage-map/lazy_boolean.cov-map rename to tests/coverage/lazy_boolean.cov-map diff --git a/tests/coverage-map/long_and_wide.cov-map b/tests/coverage/long_and_wide.cov-map similarity index 100% rename from tests/coverage-map/long_and_wide.cov-map rename to tests/coverage/long_and_wide.cov-map diff --git a/tests/coverage-map/loop_break_value.cov-map b/tests/coverage/loop_break_value.cov-map similarity index 100% rename from tests/coverage-map/loop_break_value.cov-map rename to tests/coverage/loop_break_value.cov-map diff --git a/tests/coverage-map/loops_branches.cov-map b/tests/coverage/loops_branches.cov-map similarity index 100% rename from tests/coverage-map/loops_branches.cov-map rename to tests/coverage/loops_branches.cov-map diff --git a/tests/coverage-map/match_or_pattern.cov-map b/tests/coverage/match_or_pattern.cov-map similarity index 100% rename from tests/coverage-map/match_or_pattern.cov-map rename to tests/coverage/match_or_pattern.cov-map diff --git a/tests/coverage-map/nested_loops.cov-map b/tests/coverage/nested_loops.cov-map similarity index 100% rename from tests/coverage-map/nested_loops.cov-map rename to tests/coverage/nested_loops.cov-map diff --git a/tests/coverage-map/no_cov_crate.cov-map b/tests/coverage/no_cov_crate.cov-map similarity index 100% rename from tests/coverage-map/no_cov_crate.cov-map rename to tests/coverage/no_cov_crate.cov-map diff --git a/tests/coverage-map/overflow.cov-map b/tests/coverage/overflow.cov-map similarity index 100% rename from tests/coverage-map/overflow.cov-map rename to tests/coverage/overflow.cov-map diff --git a/tests/coverage-map/panic_unwind.cov-map b/tests/coverage/panic_unwind.cov-map similarity index 100% rename from tests/coverage-map/panic_unwind.cov-map rename to tests/coverage/panic_unwind.cov-map diff --git a/tests/coverage-map/partial_eq.cov-map b/tests/coverage/partial_eq.cov-map similarity index 100% rename from tests/coverage-map/partial_eq.cov-map rename to tests/coverage/partial_eq.cov-map diff --git a/tests/coverage-map/simple_loop.cov-map b/tests/coverage/simple_loop.cov-map similarity index 100% rename from tests/coverage-map/simple_loop.cov-map rename to tests/coverage/simple_loop.cov-map diff --git a/tests/coverage-map/simple_match.cov-map b/tests/coverage/simple_match.cov-map similarity index 100% rename from tests/coverage-map/simple_match.cov-map rename to tests/coverage/simple_match.cov-map diff --git a/tests/coverage-map/sort_groups.cov-map b/tests/coverage/sort_groups.cov-map similarity index 100% rename from tests/coverage-map/sort_groups.cov-map rename to tests/coverage/sort_groups.cov-map diff --git a/tests/coverage-map/test_harness.cov-map b/tests/coverage/test_harness.cov-map similarity index 100% rename from tests/coverage-map/test_harness.cov-map rename to tests/coverage/test_harness.cov-map diff --git a/tests/coverage-map/tight_inf_loop.cov-map b/tests/coverage/tight_inf_loop.cov-map similarity index 100% rename from tests/coverage-map/tight_inf_loop.cov-map rename to tests/coverage/tight_inf_loop.cov-map diff --git a/tests/coverage-map/trivial.cov-map b/tests/coverage/trivial.cov-map similarity index 100% rename from tests/coverage-map/trivial.cov-map rename to tests/coverage/trivial.cov-map diff --git a/tests/coverage-map/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map similarity index 100% rename from tests/coverage-map/try_error_result.cov-map rename to tests/coverage/try_error_result.cov-map diff --git a/tests/coverage-map/unreachable.cov-map b/tests/coverage/unreachable.cov-map similarity index 100% rename from tests/coverage-map/unreachable.cov-map rename to tests/coverage/unreachable.cov-map diff --git a/tests/coverage-map/unused.cov-map b/tests/coverage/unused.cov-map similarity index 100% rename from tests/coverage-map/unused.cov-map rename to tests/coverage/unused.cov-map diff --git a/tests/coverage-map/unused_mod.cov-map b/tests/coverage/unused_mod.cov-map similarity index 100% rename from tests/coverage-map/unused_mod.cov-map rename to tests/coverage/unused_mod.cov-map diff --git a/tests/coverage-map/uses_crate.cov-map b/tests/coverage/uses_crate.cov-map similarity index 100% rename from tests/coverage-map/uses_crate.cov-map rename to tests/coverage/uses_crate.cov-map diff --git a/tests/coverage-map/uses_inline_crate.cov-map b/tests/coverage/uses_inline_crate.cov-map similarity index 100% rename from tests/coverage-map/uses_inline_crate.cov-map rename to tests/coverage/uses_inline_crate.cov-map diff --git a/tests/coverage-map/while.cov-map b/tests/coverage/while.cov-map similarity index 100% rename from tests/coverage-map/while.cov-map rename to tests/coverage/while.cov-map diff --git a/tests/coverage-map/while_early_ret.cov-map b/tests/coverage/while_early_ret.cov-map similarity index 100% rename from tests/coverage-map/while_early_ret.cov-map rename to tests/coverage/while_early_ret.cov-map diff --git a/tests/coverage-map/yield.cov-map b/tests/coverage/yield.cov-map similarity index 100% rename from tests/coverage-map/yield.cov-map rename to tests/coverage/yield.cov-map From 4e6f438d2ace2f5297cea2d3e331c6dccd4e18c2 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Wed, 1 Nov 2023 21:07:07 +1100 Subject: [PATCH 11/11] coverage: Register `test::Coverage` as the test suite for `tests/coverage` This restores the ability to run a coverage test by specifying its path, e.g. `./x.py test tests/coverage/if.rs`. This runs the test in both modes. --- src/bootstrap/src/core/build_steps/test.rs | 3 ++- tests/coverage/README.md | 17 ++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index da4b135083c63..39667d16b7b6d 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1423,7 +1423,7 @@ impl Step for Coverage { const ONLY_HOSTS: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.alias(Self::SUITE) + run.suite_path(Self::PATH) } fn make_run(run: RunConfig<'_>) { @@ -1438,6 +1438,7 @@ impl Step for Coverage { } } +// Aliases for running the coverage tests in only one mode. coverage_test_alias!(CoverageMap { alias_and_mode: "coverage-map", default: true, diff --git a/tests/coverage/README.md b/tests/coverage/README.md index 146fbff5b204d..f1e403c65e35e 100644 --- a/tests/coverage/README.md +++ b/tests/coverage/README.md @@ -1,13 +1,16 @@ -Many of these tests were copied from `tests/run-coverage` in order to -capture the current behavior of the instrumentor on non-trivial programs. -The actual mappings have not been closely inspected. +The tests in this directory are shared by two different test modes, and can be +run in multiple different ways: + +- `./x.py test coverage-map` (compiles to LLVM IR and checks coverage mappings) +- `./x.py test run-coverage` (runs a test binary and checks its coverage report) +- `./x.py test coverage` (runs both `coverage-map` and `run-coverage`) ## Maintenance note These tests can be sensitive to small changes in MIR spans or MIR control flow, especially in HIR-to-MIR lowering or MIR optimizations. -If you haven't touched the coverage code directly, and the `run-coverage` test -suite still works, then it should usually be OK to just `--bless` these -coverage mapping tests as necessary, without worrying too much about the exact -changes. +If you haven't touched the coverage code directly, and the tests still pass in +`run-coverage` mode, then it should usually be OK to just re-bless the mappings +as necessary with `./x.py test coverage-map --bless`, without worrying too much +about the exact changes.