Skip to content

Commit 4d8b8de

Browse files
authored
Unrolled build for rust-lang#117040
Rollup merge of rust-lang#117040 - Zalathar:instrument-coverage-ui, r=cjgillot coverage: Add UI tests for values accepted by `-Cinstrument-coverage` I wanted to clean up the code in `parse_instrument_coverage`, but it occurred to me that we currently don't have any UI tests for the various stable and unstable values supported by this flag. --- Normally it might be overkill to individually test all the different variants of `on`/`off`, but in this case the parsing of those values is mixed in with some other custom code, so I think it's worthwhile being thorough.
2 parents 858a42b + 71b7322 commit 4d8b8de

13 files changed

+72
-3
lines changed

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,7 @@ impl<'test> TestCx<'test> {
24702470
}
24712471
CoverageMap => {
24722472
rustc.arg("-Cinstrument-coverage");
2473-
// These tests only compile to MIR, so they don't need the
2473+
// These tests only compile to LLVM IR, so they don't need the
24742474
// profiler runtime to be present.
24752475
rustc.arg("-Zno-profiler-runtime");
24762476
// Coverage mappings are sensitive to MIR optimizations, and

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
const ENTRY_LIMIT: usize = 900;
1212
// FIXME: The following limits should be reduced eventually.
1313
const ISSUES_ENTRY_LIMIT: usize = 1854;
14-
const ROOT_ENTRY_LIMIT: usize = 865;
14+
const ROOT_ENTRY_LIMIT: usize = 866;
1515

1616
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
1717
"rs", // test source files
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Test that `-Cinstrument-coverage=off` does not add coverage instrumentation to LLVM IR.
2+
3+
// needs-profiler-support
4+
// revisions: n no off false zero
5+
// [n] compile-flags: -Cinstrument-coverage=n
6+
// [no] compile-flags: -Cinstrument-coverage=no
7+
// [off] compile-flags: -Cinstrument-coverage=off
8+
// [false] compile-flags: -Cinstrument-coverage=false
9+
// [zero] compile-flags: -Cinstrument-coverage=0
10+
11+
// CHECK-NOT: __llvm_profile_filename
12+
// CHECK-NOT: __llvm_coverage_mapping
13+
14+
#![crate_type="lib"]
15+
16+
#[inline(never)]
17+
fn some_function() {
18+
19+
}
20+
21+
pub fn some_other_function() {
22+
some_function();
23+
}

tests/codegen/instrument-coverage.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
// Test that `-Cinstrument-coverage` creates expected __llvm_profile_filename symbol in LLVM IR.
22

33
// needs-profiler-support
4-
// compile-flags: -Cinstrument-coverage
4+
// revisions: default y yes on true all
5+
// [default] compile-flags: -Cinstrument-coverage
6+
// [y] compile-flags: -Cinstrument-coverage=y
7+
// [yes] compile-flags: -Cinstrument-coverage=yes
8+
// [on] compile-flags: -Cinstrument-coverage=on
9+
// [true] compile-flags: -Cinstrument-coverage=true
10+
// [all] compile-flags: -Cinstrument-coverage=all
511

612
// CHECK: @__llvm_profile_filename = {{.*}}"default_%m_%p.profraw\00"{{.*}}
13+
// CHECK: @__llvm_coverage_mapping
714

815
#![crate_type="lib"]
916

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `bad-value` for codegen option `instrument-coverage` - `all` (default), `except-unused-generics`, `except-unused-functions`, or `off` was expected
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `` for codegen option `instrument-coverage` - `all` (default), `except-unused-generics`, `except-unused-functions`, or `off` was expected
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// revisions: blank bad
2+
// [blank] compile-flags: -Cinstrument-coverage=
3+
// [bad] compile-flags: -Cinstrument-coverage=bad-value
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// compile-flags: -Cinstrument-coverage=except-unused-functions
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: `-C instrument-coverage=except-*` requires `-Z unstable-options`
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// compile-flags: -Cinstrument-coverage=except-unused-generics
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: `-C instrument-coverage=except-*` requires `-Z unstable-options`
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
// revisions: n no off false zero
3+
// [n] compile-flags: -Cinstrument-coverage=n
4+
// [no] compile-flags: -Cinstrument-coverage=no
5+
// [off] compile-flags: -Cinstrument-coverage=off
6+
// [false] compile-flags: -Cinstrument-coverage=false
7+
// [zero] compile-flags: -Cinstrument-coverage=0
8+
9+
fn main() {}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
// needs-profiler-support
3+
// revisions: default y yes on true all
4+
// [default] compile-flags: -Cinstrument-coverage
5+
// [y] compile-flags: -Cinstrument-coverage=y
6+
// [yes] compile-flags: -Cinstrument-coverage=yes
7+
// [on] compile-flags: -Cinstrument-coverage=on
8+
// [true] compile-flags: -Cinstrument-coverage=true
9+
// [all] compile-flags: -Cinstrument-coverage=all
10+
11+
fn main() {}

0 commit comments

Comments
 (0)