about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-17 21:32:16 +0000
committerbors <bors@rust-lang.org>2024-06-17 21:32:16 +0000
commit59e2c01c2217a01546222e4d9ff4e6695ee8a1db (patch)
tree169a3936cf296ecffe84f6fff35d05dd3fff8d00 /src
parent04ab7b2be0db3e6787f5303285c6b2ee6279868d (diff)
parent6228b3e40e78ca0a29fd4599c9b7a3e340bb1572 (diff)
downloadrust-59e2c01c2217a01546222e4d9ff4e6695ee8a1db.tar.gz
rust-59e2c01c2217a01546222e4d9ff4e6695ee8a1db.zip
Auto merge of #125500 - Oneirical:bundle-them-up-why-not, r=jieyouxu
Migrate `link-arg`, `link-dedup` and `issue-26092` `run-make` tests to `rmake` format

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

All of these tests check if rustc's output contains (or does not) contain certain strings. Does that mean these could be better suited to becoming UI/codegen tests?

try-job: x86_64-msvc
Diffstat (limited to 'src')
-rw-r--r--src/tools/run-make-support/src/command.rs44
-rw-r--r--src/tools/run-make-support/src/lib.rs21
-rw-r--r--src/tools/tidy/src/allowed_run_make_makefiles.txt3
3 files changed, 50 insertions, 18 deletions
diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs
index dab18dca2ff..f39bcfd60df 100644
--- a/src/tools/run-make-support/src/command.rs
+++ b/src/tools/run-make-support/src/command.rs
@@ -6,7 +6,7 @@ use std::path::Path;
 use std::process::{Command as StdCommand, ExitStatus, Output, Stdio};
 
 use crate::drop_bomb::DropBomb;
-use crate::{assert_contains, assert_not_contains, handle_failed_output};
+use crate::{assert_contains, assert_equals, assert_not_contains, handle_failed_output};
 
 /// This is a custom command wrapper that simplifies working with commands and makes it easier to
 /// ensure that we check the exit status of executed processes.
@@ -21,6 +21,7 @@ use crate::{assert_contains, assert_not_contains, handle_failed_output};
 ///
 /// [`run`]: Self::run
 /// [`run_fail`]: Self::run_fail
+/// [`run_unchecked`]: Self::run_unchecked
 #[derive(Debug)]
 pub struct Command {
     cmd: StdCommand,
@@ -116,6 +117,15 @@ impl Command {
         output
     }
 
+    /// Run the command but do not check its exit status.
+    /// Only use if you explicitly don't care about the exit status.
+    /// Prefer to use [`Self::run`] and [`Self::run_fail`]
+    /// whenever possible.
+    #[track_caller]
+    pub fn run_unchecked(&mut self) -> CompletedProcess {
+        self.command_output()
+    }
+
     #[track_caller]
     fn command_output(&mut self) -> CompletedProcess {
         self.drop_bomb.defuse();
@@ -163,41 +173,45 @@ impl CompletedProcess {
         self.output.status
     }
 
-    /// Checks that trimmed `stdout` matches trimmed `content`.
+    /// Checks that trimmed `stdout` matches trimmed `expected`.
     #[track_caller]
-    pub fn assert_stdout_equals<S: AsRef<str>>(&self, content: S) -> &Self {
-        assert_eq!(self.stdout_utf8().trim(), content.as_ref().trim());
+    pub fn assert_stdout_equals<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_equals(self.stdout_utf8().trim(), expected.as_ref().trim());
         self
     }
 
+    /// Checks that `stdout` does not contain `unexpected`.
     #[track_caller]
-    pub fn assert_stdout_contains<S: AsRef<str>>(self, needle: S) -> Self {
-        assert_contains(&self.stdout_utf8(), needle.as_ref());
+    pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
+        assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
         self
     }
 
+    /// Checks that `stdout` contains `expected`.
     #[track_caller]
-    pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
-        assert_not_contains(&self.stdout_utf8(), needle.as_ref());
+    pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_contains(&self.stdout_utf8(), expected.as_ref());
         self
     }
 
-    /// Checks that trimmed `stderr` matches trimmed `content`.
+    /// Checks that trimmed `stderr` matches trimmed `expected`.
     #[track_caller]
-    pub fn assert_stderr_equals<S: AsRef<str>>(&self, content: S) -> &Self {
-        assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim());
+    pub fn assert_stderr_equals<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_equals(self.stderr_utf8().trim(), expected.as_ref().trim());
         self
     }
 
+    /// Checks that `stderr` contains `expected`.
     #[track_caller]
-    pub fn assert_stderr_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
-        assert_contains(&self.stderr_utf8(), needle.as_ref());
+    pub fn assert_stderr_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
+        assert_contains(&self.stderr_utf8(), expected.as_ref());
         self
     }
 
+    /// Checks that `stderr` does not contain `unexpected`.
     #[track_caller]
-    pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
-        assert_not_contains(&self.stdout_utf8(), needle.as_ref());
+    pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
+        assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
         self
     }
 
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index ba4524c150c..84b0a4f61ee 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -332,6 +332,18 @@ pub fn read_dir<F: Fn(&Path)>(dir: impl AsRef<Path>, callback: F) {
     }
 }
 
+/// Check that `actual` is equal to `expected`. Panic otherwise.
+#[track_caller]
+pub fn assert_equals(actual: &str, expected: &str) {
+    if actual != expected {
+        eprintln!("=== ACTUAL TEXT ===");
+        eprintln!("{}", actual);
+        eprintln!("=== EXPECTED ===");
+        eprintln!("{}", expected);
+        panic!("expected text was not found in actual text");
+    }
+}
+
 /// Check that `haystack` contains `needle`. Panic otherwise.
 #[track_caller]
 pub fn assert_contains(haystack: &str, needle: &str) {
@@ -468,6 +480,15 @@ macro_rules! impl_common_helpers {
                 self.cmd.run_fail()
             }
 
+            /// Run the command but do not check its exit status.
+            /// Only use if you explicitly don't care about the exit status.
+            /// Prefer to use [`Self::run`] and [`Self::run_fail`]
+            /// whenever possible.
+            #[track_caller]
+            pub fn run_unchecked(&mut self) -> crate::command::CompletedProcess {
+                self.cmd.run_unchecked()
+            }
+
             /// Set the path where the command will be run.
             pub fn current_dir<P: AsRef<::std::path::Path>>(&mut self, path: P) -> &mut Self {
                 self.cmd.current_dir(path);
diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index fdd0be79a4d..69a8aa05360 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -83,7 +83,6 @@ run-make/issue-20626/Makefile
 run-make/issue-22131/Makefile
 run-make/issue-25581/Makefile
 run-make/issue-26006/Makefile
-run-make/issue-26092/Makefile
 run-make/issue-28595/Makefile
 run-make/issue-33329/Makefile
 run-make/issue-35164/Makefile
@@ -109,10 +108,8 @@ run-make/libtest-json/Makefile
 run-make/libtest-junit/Makefile
 run-make/libtest-padding/Makefile
 run-make/libtest-thread-limit/Makefile
-run-make/link-arg/Makefile
 run-make/link-args-order/Makefile
 run-make/link-cfg/Makefile
-run-make/link-dedup/Makefile
 run-make/link-framework/Makefile
 run-make/link-path-order/Makefile
 run-make/linkage-attr-on-static/Makefile