diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8bdc2d65d271..9f2c45ca1cf2 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 732de6526279..8cd25ec371b9 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 ec04ea570637..251b0c291e94 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 8b8b1f7f351f..16592d48ddac 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 4a052756d4e2..8b8e9d5483f3 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 1aa4a22c33e1..0f11a69bd7a5 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 a1b9ebb1ed34..6f626b4a65b4 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 679b4e531880..6e62839c9985 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 412f4a93b9c9..5eb6d2667be4 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 1ee8037a1e79..ab466970f8e9 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 66ca9e80a327..9ba7177ef35f 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 f7aff3c3f8a5..4bd66d2f89cb 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() {