From a2c0b388970c95e9ccb088e2abc2cb4f02ed90ae Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 12 Jun 2023 18:07:04 +1000 Subject: [PATCH] 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. --- src/tools/compiletest/src/runtest.rs | 12 ++++++++++++ .../auxiliary}/doctest_crate.rs | 0 .../doctest.coverage} | 6 +++--- .../coverage => run-coverage-rustdoc}/doctest.rs | 2 +- .../auxiliary}/inline_always_with_dead_code.rs | 0 .../auxiliary}/unused_mod_helper.rs | 0 .../lib => run-coverage/auxiliary}/used_crate.rs | 4 ++-- .../auxiliary}/used_inline_crate.rs | 4 ++-- .../issue-85461.coverage} | 6 +++--- .../coverage => run-coverage}/issue-85461.rs | 2 +- .../unused_mod.coverage} | 0 .../coverage => run-coverage}/unused_mod.rs | 2 +- .../uses_crate.coverage} | 4 ++-- .../coverage => run-coverage}/uses_crate.rs | 8 ++++++-- .../uses_inline_crate.coverage} | 4 ++-- .../coverage => run-coverage}/uses_inline_crate.rs | 8 +++++--- 16 files changed, 40 insertions(+), 22 deletions(-) rename tests/{run-make/coverage/lib => run-coverage-rustdoc/auxiliary}/doctest_crate.rs (100%) rename tests/{run-make/coverage-reports/expected_show_coverage.doctest.txt => run-coverage-rustdoc/doctest.coverage} (98%) rename tests/{run-make/coverage => run-coverage-rustdoc}/doctest.rs (99%) rename tests/{run-make/coverage/lib => run-coverage/auxiliary}/inline_always_with_dead_code.rs (100%) rename tests/{run-make/coverage/lib => run-coverage/auxiliary}/unused_mod_helper.rs (100%) rename tests/{run-make/coverage/lib => run-coverage/auxiliary}/used_crate.rs (97%) rename tests/{run-make/coverage/lib => run-coverage/auxiliary}/used_inline_crate.rs (96%) rename tests/{run-make/coverage-reports/expected_show_coverage.issue-85461.txt => run-coverage/issue-85461.coverage} (88%) rename tests/{run-make/coverage => run-coverage}/issue-85461.rs (84%) rename tests/{run-make/coverage-reports/expected_show_coverage.unused_mod.txt => run-coverage/unused_mod.coverage} (100%) rename tests/{run-make/coverage => run-coverage}/unused_mod.rs (59%) rename tests/{run-make/coverage-reports/expected_show_coverage.uses_crate.txt => run-coverage/uses_crate.coverage} (98%) rename tests/{run-make/coverage => run-coverage}/uses_crate.rs (79%) rename tests/{run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt => run-coverage/uses_inline_crate.coverage} (98%) rename tests/{run-make/coverage => run-coverage}/uses_inline_crate.rs (82%) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8bdc2d65d27..9f2c45ca1cf 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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()); @@ -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. diff --git a/tests/run-make/coverage/lib/doctest_crate.rs b/tests/run-coverage-rustdoc/auxiliary/doctest_crate.rs similarity index 100% rename from tests/run-make/coverage/lib/doctest_crate.rs rename to tests/run-coverage-rustdoc/auxiliary/doctest_crate.rs diff --git a/tests/run-make/coverage-reports/expected_show_coverage.doctest.txt b/tests/run-coverage-rustdoc/doctest.coverage similarity index 98% rename from tests/run-make/coverage-reports/expected_show_coverage.doctest.txt rename to tests/run-coverage-rustdoc/doctest.coverage index 732de652627..8cd25ec371b 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.doctest.txt +++ b/tests/run-coverage-rustdoc/doctest.coverage @@ -1,4 +1,4 @@ -../coverage/doctest.rs: +$DIR/doctest.rs: 1| |//! This test ensures that code from doctests is properly re-mapped. 2| |//! See for more info. 3| |//! @@ -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; @@ -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 { diff --git a/tests/run-make/coverage/doctest.rs b/tests/run-coverage-rustdoc/doctest.rs similarity index 99% rename from tests/run-make/coverage/doctest.rs rename to tests/run-coverage-rustdoc/doctest.rs index ec04ea57063..251b0c291e9 100644 --- a/tests/run-make/coverage/doctest.rs +++ b/tests/run-coverage-rustdoc/doctest.rs @@ -63,7 +63,7 @@ //! doctest_main() //! } //! ``` - +// aux-build:doctest_crate.rs /// doctest attached to fn testing external code: /// ``` /// extern crate doctest_crate; diff --git a/tests/run-make/coverage/lib/inline_always_with_dead_code.rs b/tests/run-coverage/auxiliary/inline_always_with_dead_code.rs similarity index 100% rename from tests/run-make/coverage/lib/inline_always_with_dead_code.rs rename to tests/run-coverage/auxiliary/inline_always_with_dead_code.rs diff --git a/tests/run-make/coverage/lib/unused_mod_helper.rs b/tests/run-coverage/auxiliary/unused_mod_helper.rs similarity index 100% rename from tests/run-make/coverage/lib/unused_mod_helper.rs rename to tests/run-coverage/auxiliary/unused_mod_helper.rs diff --git a/tests/run-make/coverage/lib/used_crate.rs b/tests/run-coverage/auxiliary/used_crate.rs similarity index 97% rename from tests/run-make/coverage/lib/used_crate.rs rename to tests/run-coverage/auxiliary/used_crate.rs index 8b8b1f7f351..16592d48dda 100644 --- a/tests/run-make/coverage/lib/used_crate.rs +++ b/tests/run-coverage/auxiliary/used_crate.rs @@ -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 diff --git a/tests/run-make/coverage/lib/used_inline_crate.rs b/tests/run-coverage/auxiliary/used_inline_crate.rs similarity index 96% rename from tests/run-make/coverage/lib/used_inline_crate.rs rename to tests/run-coverage/auxiliary/used_inline_crate.rs index 4a052756d4e..8b8e9d5483f 100644 --- a/tests/run-make/coverage/lib/used_inline_crate.rs +++ b/tests/run-coverage/auxiliary/used_inline_crate.rs @@ -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() { diff --git a/tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt b/tests/run-coverage/issue-85461.coverage similarity index 88% rename from tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt rename to tests/run-coverage/issue-85461.coverage index 1aa4a22c33e..0f11a69bd7a 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt +++ b/tests/run-coverage/issue-85461.coverage @@ -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}; @@ -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)] diff --git a/tests/run-make/coverage/issue-85461.rs b/tests/run-coverage/issue-85461.rs similarity index 84% rename from tests/run-make/coverage/issue-85461.rs rename to tests/run-coverage/issue-85461.rs index a1b9ebb1ed3..6f626b4a65b 100644 --- a/tests/run-make/coverage/issue-85461.rs +++ b/tests/run-coverage/issue-85461.rs @@ -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}; diff --git a/tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt b/tests/run-coverage/unused_mod.coverage similarity index 100% rename from tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt rename to tests/run-coverage/unused_mod.coverage diff --git a/tests/run-make/coverage/unused_mod.rs b/tests/run-coverage/unused_mod.rs similarity index 59% rename from tests/run-make/coverage/unused_mod.rs rename to tests/run-coverage/unused_mod.rs index 679b4e53188..6e62839c998 100644 --- a/tests/run-make/coverage/unused_mod.rs +++ b/tests/run-coverage/unused_mod.rs @@ -1,4 +1,4 @@ -#[path = "lib/unused_mod_helper.rs"] +#[path = "auxiliary/unused_mod_helper.rs"] mod unused_module; fn main() { diff --git a/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt b/tests/run-coverage/uses_crate.coverage similarity index 98% rename from tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt rename to tests/run-coverage/uses_crate.coverage index 412f4a93b9c..5eb6d2667be 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt +++ b/tests/run-coverage/uses_crate.coverage @@ -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 diff --git a/tests/run-make/coverage/uses_crate.rs b/tests/run-coverage/uses_crate.rs similarity index 79% rename from tests/run-make/coverage/uses_crate.rs rename to tests/run-coverage/uses_crate.rs index 1ee8037a1e7..ab466970f8e 100644 --- a/tests/run-make/coverage/uses_crate.rs +++ b/tests/run-coverage/uses_crate.rs @@ -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() { diff --git a/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt b/tests/run-coverage/uses_inline_crate.coverage similarity index 98% rename from tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt rename to tests/run-coverage/uses_inline_crate.coverage index 66ca9e80a32..9ba7177ef35 100644 --- a/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt +++ b/tests/run-coverage/uses_inline_crate.coverage @@ -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() { diff --git a/tests/run-make/coverage/uses_inline_crate.rs b/tests/run-coverage/uses_inline_crate.rs similarity index 82% rename from tests/run-make/coverage/uses_inline_crate.rs rename to tests/run-coverage/uses_inline_crate.rs index f7aff3c3f8a..4bd66d2f89c 100644 --- a/tests/run-make/coverage/uses_inline_crate.rs +++ b/tests/run-coverage/uses_inline_crate.rs @@ -1,10 +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_inline_crate.rs extern crate used_inline_crate; fn main() {