Skip to content

Commit

Permalink
Migrate the remaining run-make/coverage-reports tests over to `run-…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
Zalathar committed Jun 28, 2023
1 parent 9d2564a commit a2c0b38
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 22 deletions.
12 changes: 12 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ impl<'test> TestCx<'test> {
let proc_res = self.run_llvm_tool("llvm-cov", |cmd| {
cmd.args(["show", "--format=text", "--show-line-counts-or-regions"]);

// Temporarily ignore these files so that we can migrate the
// existing output snapshots mostly as-is.
// This code will be removed later in the same PR.
cmd.args([
"--ignore-filename-regex",
"(uses_crate.rs|uses_inline_crate.rs|unused_mod.rs)",
]);

cmd.arg("--Xdemangler");
cmd.arg(self.config.rust_demangler_path.as_ref().unwrap());

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

// Join the file sections back into a flat list of lines, with
// sections separated by blank lines.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
../coverage/doctest.rs:
$DIR/doctest.rs:
1| |//! This test ensures that code from doctests is properly re-mapped.
2| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
3| |//!
Expand Down Expand Up @@ -67,7 +67,7 @@
63| |//! doctest_main()
64| |//! }
65| |//! ```
66| |
66| |// aux-build:doctest_crate.rs
67| |/// doctest attached to fn testing external code:
68| |/// ```
69| 1|/// extern crate doctest_crate;
Expand Down Expand Up @@ -102,7 +102,7 @@
98| |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care
99| |// if the indentation changed. I don't know if there is a more viable solution.

../coverage/lib/doctest_crate.rs:
$DIR/auxiliary/doctest_crate.rs:
1| |/// A function run only from within doctests
2| 3|pub fn fn_run_in_doctests(conditional: usize) {
3| 3| match conditional {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
//! doctest_main()
//! }
//! ```
// aux-build:doctest_crate.rs
/// doctest attached to fn testing external code:
/// ```
/// extern crate doctest_crate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(unused_assignments, unused_variables)]
// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
use std::fmt::Debug;
// compile-flags: -C opt-level=3
use std::fmt::Debug; // ^^ validates coverage now works with optimizations

pub fn used_function() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused_assignments, unused_variables)]

// compile-flags: -C opt-level=3 # validates coverage now works with optimizations

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

pub fn used_function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
../coverage/issue-85461.rs:
$DIR/issue-85461.rs:
1| |// 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
3| |extern crate inline_always_with_dead_code;
4| |
5| |use inline_always_with_dead_code::{bar, baz};
Expand All @@ -10,7 +10,7 @@
9| 1| baz::call_me();
10| 1|}

../coverage/lib/inline_always_with_dead_code.rs:
$DIR/auxiliary/inline_always_with_dead_code.rs:
1| |// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0
2| |
3| |#![allow(dead_code)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 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};
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[path = "lib/unused_mod_helper.rs"]
#[path = "auxiliary/unused_mod_helper.rs"]
mod unused_module;

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1| |#![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
4| |
5| 1|pub fn used_function() {
6| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// FIXME #110395
// ignore-llvm-cov-show-diffs
// ignore-linux

// Validates coverage now works with optimizations
// compile-flags: -C opt-level=3

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

// aux-build:used_crate.rs
extern crate used_crate;

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1| |#![allow(unused_assignments, unused_variables)]
2| |
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
5| |use std::fmt::Debug;
6| |
7| 1|pub fn used_function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// FIXME #110395
// ignore-llvm-cov-show-diffs
// ignore-linux

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

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

// aux-build:used_inline_crate.rs
extern crate used_inline_crate;

fn main() {
Expand Down

0 comments on commit a2c0b38

Please sign in to comment.