Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage: Unify tests/coverage-map and tests/run-coverage into tests/coverage #117484

Merged
merged 11 commits into from
Nov 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
Zalathar committed Nov 7, 2023
commit 7f8a6de72c1ddf25775da648dc42198847ca0a23
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
@@ -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 => {
8 changes: 4 additions & 4 deletions tests/coverage-map/status-quo/overflow.cov-map
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions tests/coverage-map/status-quo/overflow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(unused_assignments)]
// compile-flags: -Coverflow-checks=yes
// failure-status: 101

fn might_overflow(to_add: u32) -> u32 {
29 changes: 22 additions & 7 deletions tests/coverage-map/status-quo/sort_groups.cov-map
Original file line number Diff line number Diff line change
@@ -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::<char>
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::<i32>
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]
2 changes: 1 addition & 1 deletion tests/coverage-map/status-quo/sort_groups.rs
Original file line number Diff line number Diff line change
@@ -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::<char>(cond);
}
generic_fn::<i32>(cond);
1 change: 1 addition & 0 deletions tests/run-coverage/overflow.coverage
Original file line number Diff line number Diff line change
@@ -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 {
1 change: 1 addition & 0 deletions tests/run-coverage/overflow.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![allow(unused_assignments)]
// compile-flags: -Coverflow-checks=yes
// failure-status: 101

fn might_overflow(to_add: u32) -> u32 {
2 changes: 1 addition & 1 deletion tests/run-coverage/sort_groups.coverage
Original file line number Diff line number Diff line change
@@ -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::<char>(cond);
LL| 1| }
LL| 1| generic_fn::<i32>(cond);
2 changes: 1 addition & 1 deletion tests/run-coverage/sort_groups.rs
Original file line number Diff line number Diff line change
@@ -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::<char>(cond);
}
generic_fn::<i32>(cond);