about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-06-12 18:07:04 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-06-28 11:09:19 +1000
commita2c0b388970c95e9ccb088e2abc2cb4f02ed90ae (patch)
tree481333e971402d7239b3cad765e9ab3a188b4773
parent9d2564a1102bf20f5310c872582518302e5f049b (diff)
downloadrust-a2c0b388970c95e9ccb088e2abc2cb4f02ed90ae.tar.gz
rust-a2c0b388970c95e9ccb088e2abc2cb4f02ed90ae.zip
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.
-rw-r--r--src/tools/compiletest/src/runtest.rs12
-rw-r--r--tests/run-coverage-rustdoc/auxiliary/doctest_crate.rs (renamed from tests/run-make/coverage/lib/doctest_crate.rs)0
-rw-r--r--tests/run-coverage-rustdoc/doctest.coverage (renamed from tests/run-make/coverage-reports/expected_show_coverage.doctest.txt)6
-rw-r--r--tests/run-coverage-rustdoc/doctest.rs (renamed from tests/run-make/coverage/doctest.rs)2
-rw-r--r--tests/run-coverage/auxiliary/inline_always_with_dead_code.rs (renamed from tests/run-make/coverage/lib/inline_always_with_dead_code.rs)0
-rw-r--r--tests/run-coverage/auxiliary/unused_mod_helper.rs (renamed from tests/run-make/coverage/lib/unused_mod_helper.rs)0
-rw-r--r--tests/run-coverage/auxiliary/used_crate.rs (renamed from tests/run-make/coverage/lib/used_crate.rs)4
-rw-r--r--tests/run-coverage/auxiliary/used_inline_crate.rs (renamed from tests/run-make/coverage/lib/used_inline_crate.rs)4
-rw-r--r--tests/run-coverage/issue-85461.coverage (renamed from tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt)6
-rw-r--r--tests/run-coverage/issue-85461.rs (renamed from tests/run-make/coverage/issue-85461.rs)2
-rw-r--r--tests/run-coverage/unused_mod.coverage (renamed from tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt)0
-rw-r--r--tests/run-coverage/unused_mod.rs (renamed from tests/run-make/coverage/unused_mod.rs)2
-rw-r--r--tests/run-coverage/uses_crate.coverage (renamed from tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt)4
-rw-r--r--tests/run-coverage/uses_crate.rs (renamed from tests/run-make/coverage/uses_crate.rs)8
-rw-r--r--tests/run-coverage/uses_inline_crate.coverage (renamed from tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt)4
-rw-r--r--tests/run-coverage/uses_inline_crate.rs (renamed from tests/run-make/coverage/uses_inline_crate.rs)8
16 files changed, 40 insertions, 22 deletions
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
index c3210146d69..c3210146d69 100644
--- a/tests/run-make/coverage/lib/doctest_crate.rs
+++ b/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
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 <https://github.com/rust-lang/rust/issues/79417> 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
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
index 2b21dee6ccf..2b21dee6ccf 100644
--- a/tests/run-make/coverage/lib/inline_always_with_dead_code.rs
+++ b/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
index ae1cc1531ed..ae1cc1531ed 100644
--- a/tests/run-make/coverage/lib/unused_mod_helper.rs
+++ b/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
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
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
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
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
index 82d6fccc271..82d6fccc271 100644
--- a/tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt
+++ b/tests/run-coverage/unused_mod.coverage
diff --git a/tests/run-make/coverage/unused_mod.rs b/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
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
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
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
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
 
-#![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() {