Skip to content

Commit a2c0b38

Browse files
committed
Migrate the remaining run-make/coverage-reports tests over to run-coverage
To make it easier to verify that the output snapshots have been migrated faithfully, this change adds some temporary helper code that lets us avoid having to completely re-bless the existing snapshots. A later change in this PR will then re-bless the tests and remove the temporary helper code.
1 parent 9d2564a commit a2c0b38

16 files changed

+40
-22
lines changed

src/tools/compiletest/src/runtest.rs

+12
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ impl<'test> TestCx<'test> {
524524
let proc_res = self.run_llvm_tool("llvm-cov", |cmd| {
525525
cmd.args(["show", "--format=text", "--show-line-counts-or-regions"]);
526526

527+
// Temporarily ignore these files so that we can migrate the
528+
// existing output snapshots mostly as-is.
529+
// This code will be removed later in the same PR.
530+
cmd.args([
531+
"--ignore-filename-regex",
532+
"(uses_crate.rs|uses_inline_crate.rs|unused_mod.rs)",
533+
]);
534+
527535
cmd.arg("--Xdemangler");
528536
cmd.arg(self.config.rust_demangler_path.as_ref().unwrap());
529537

@@ -690,6 +698,10 @@ impl<'test> TestCx<'test> {
690698
// Sort the file sections (not including the final empty "section").
691699
let except_last = sections.len() - 1;
692700
(&mut sections[..except_last]).sort();
701+
// Temporarily sort the file sections in reverse order so that we can
702+
// migrate the existing output snapshots mostly as-is.
703+
// This code will be removed later in the same PR.
704+
(&mut sections[..except_last]).sort_by(|a, b| b.cmp(a));
693705

694706
// Join the file sections back into a flat list of lines, with
695707
// sections separated by blank lines.

tests/run-make/coverage-reports/expected_show_coverage.doctest.txt renamed to tests/run-coverage-rustdoc/doctest.coverage

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
../coverage/doctest.rs:
1+
$DIR/doctest.rs:
22
1| |//! This test ensures that code from doctests is properly re-mapped.
33
2| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
44
3| |//!
@@ -67,7 +67,7 @@
6767
63| |//! doctest_main()
6868
64| |//! }
6969
65| |//! ```
70-
66| |
70+
66| |// aux-build:doctest_crate.rs
7171
67| |/// doctest attached to fn testing external code:
7272
68| |/// ```
7373
69| 1|/// extern crate doctest_crate;
@@ -102,7 +102,7 @@
102102
98| |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care
103103
99| |// if the indentation changed. I don't know if there is a more viable solution.
104104

105-
../coverage/lib/doctest_crate.rs:
105+
$DIR/auxiliary/doctest_crate.rs:
106106
1| |/// A function run only from within doctests
107107
2| 3|pub fn fn_run_in_doctests(conditional: usize) {
108108
3| 3| match conditional {

tests/run-make/coverage/doctest.rs renamed to tests/run-coverage-rustdoc/doctest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
//! doctest_main()
6464
//! }
6565
//! ```
66-
66+
// aux-build:doctest_crate.rs
6767
/// doctest attached to fn testing external code:
6868
/// ```
6969
/// extern crate doctest_crate;

tests/run-make/coverage/lib/used_crate.rs renamed to tests/run-coverage/auxiliary/used_crate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(unused_assignments, unused_variables)]
2-
// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
3-
use std::fmt::Debug;
2+
// compile-flags: -C opt-level=3
3+
use std::fmt::Debug; // ^^ validates coverage now works with optimizations
44

55
pub fn used_function() {
66
// Initialize test constants in a way that cannot be determined at compile time, to ensure

tests/run-make/coverage/lib/used_inline_crate.rs renamed to tests/run-coverage/auxiliary/used_inline_crate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(unused_assignments, unused_variables)]
22

3-
// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
4-
3+
// compile-flags: -C opt-level=3
4+
// ^^ validates coverage now works with optimizations
55
use std::fmt::Debug;
66

77
pub fn used_function() {
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
../coverage/issue-85461.rs:
1+
$DIR/issue-85461.rs:
22
1| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
3-
2| |
3+
2| |// aux-build:inline_always_with_dead_code.rs
44
3| |extern crate inline_always_with_dead_code;
55
4| |
66
5| |use inline_always_with_dead_code::{bar, baz};
@@ -10,7 +10,7 @@
1010
9| 1| baz::call_me();
1111
10| 1|}
1212

13-
../coverage/lib/inline_always_with_dead_code.rs:
13+
$DIR/auxiliary/inline_always_with_dead_code.rs:
1414
1| |// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0
1515
2| |
1616
3| |#![allow(dead_code)]

tests/run-make/coverage/issue-85461.rs renamed to tests/run-coverage/issue-85461.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
2-
2+
// aux-build:inline_always_with_dead_code.rs
33
extern crate inline_always_with_dead_code;
44

55
use inline_always_with_dead_code::{bar, baz};

tests/run-make/coverage/unused_mod.rs renamed to tests/run-coverage/unused_mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[path = "lib/unused_mod_helper.rs"]
1+
#[path = "auxiliary/unused_mod_helper.rs"]
22
mod unused_module;
33

44
fn main() {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1| |#![allow(unused_assignments, unused_variables)]
2-
2| |// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
3-
3| |use std::fmt::Debug;
2+
2| |// compile-flags: -C opt-level=3
3+
3| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations
44
4| |
55
5| 1|pub fn used_function() {
66
6| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure

tests/run-make/coverage/uses_crate.rs renamed to tests/run-coverage/uses_crate.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// FIXME #110395
2-
// ignore-llvm-cov-show-diffs
2+
// ignore-linux
3+
4+
// Validates coverage now works with optimizations
5+
// compile-flags: -C opt-level=3
36

47
#![allow(unused_assignments, unused_variables)]
5-
// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
8+
9+
// aux-build:used_crate.rs
610
extern crate used_crate;
711

812
fn main() {
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
1| |#![allow(unused_assignments, unused_variables)]
22
2| |
3-
3| |// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
4-
4| |
3+
3| |// compile-flags: -C opt-level=3
4+
4| |// ^^ validates coverage now works with optimizations
55
5| |use std::fmt::Debug;
66
6| |
77
7| 1|pub fn used_function() {

tests/run-make/coverage/uses_inline_crate.rs renamed to tests/run-coverage/uses_inline_crate.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// FIXME #110395
2-
// ignore-llvm-cov-show-diffs
2+
// ignore-linux
33

4-
#![allow(unused_assignments, unused_variables)]
4+
// Validates coverage now works with optimizations
5+
// compile-flags: -C opt-level=3
56

6-
// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
7+
#![allow(unused_assignments, unused_variables)]
78

9+
// aux-build:used_inline_crate.rs
810
extern crate used_inline_crate;
911

1012
fn main() {

0 commit comments

Comments
 (0)