From 4d4944dfd828f1092efdfccbbca2ef6f846100da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 7 Jun 2024 15:56:06 +0200 Subject: [PATCH] Address review comments --- src/tools/run-make-support/src/command.rs | 24 +++++++++---------- tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs | 2 +- tests/run-make/crate-data-smoke/rmake.rs | 10 ++++---- tests/run-make/non-unicode-env/rmake.rs | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs index c31da1e1cb688..b9e56ab632add 100644 --- a/src/tools/run-make-support/src/command.rs +++ b/src/tools/run-make-support/src/command.rs @@ -25,7 +25,7 @@ impl Command { /// Run the constructed command and assert that it is successfully run. #[track_caller] pub fn run(&mut self) -> CompletedProcess { - let caller_location = ::std::panic::Location::caller(); + let caller_location = std::panic::Location::caller(); let caller_line_number = caller_location.line(); let output = self.command_output(); @@ -38,7 +38,7 @@ impl Command { /// Run the constructed command and assert that it does not successfully run. #[track_caller] pub fn run_fail(&mut self) -> CompletedProcess { - let caller_location = ::std::panic::Location::caller(); + let caller_location = std::panic::Location::caller(); let caller_line_number = caller_location.line(); let output = self.command_output(); @@ -107,33 +107,33 @@ impl CompletedProcess { /// Checks that trimmed `stdout` matches trimmed `content`. #[track_caller] - pub fn assert_stdout_equals(self, content: &str) -> Self { - assert_eq!(self.stdout_utf8().trim(), content.trim()); + pub fn assert_stdout_equals>(self, content: S) -> Self { + assert_eq!(self.stdout_utf8().trim(), content.as_ref().trim()); self } #[track_caller] - pub fn assert_stdout_not_contains(self, needle: &str) -> Self { - assert_not_contains(&self.stdout_utf8(), needle); + pub fn assert_stdout_not_contains>(self, needle: S) -> Self { + assert_not_contains(&self.stdout_utf8(), needle.as_ref()); self } /// Checks that trimmed `stderr` matches trimmed `content`. #[track_caller] - pub fn assert_stderr_equals(self, content: &str) -> Self { - assert_eq!(self.stderr_utf8().trim(), content.trim()); + pub fn assert_stderr_equals>(self, content: S) -> Self { + assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim()); self } #[track_caller] - pub fn assert_stderr_contains(self, needle: &str) -> Self { - assert!(self.stderr_utf8().contains(needle)); + pub fn assert_stderr_contains>(self, needle: S) -> Self { + assert!(self.stderr_utf8().contains(needle.as_ref())); self } #[track_caller] - pub fn assert_stderr_not_contains(self, needle: &str) -> Self { - assert_not_contains(&self.stdout_utf8(), needle); + pub fn assert_stderr_not_contains>(self, needle: S) -> Self { + assert_not_contains(&self.stdout_utf8(), needle.as_ref()); self } diff --git a/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs b/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs index bb9bff7832776..9fa4e9f465de4 100644 --- a/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs +++ b/tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs @@ -15,5 +15,5 @@ fn main() { let version = include_str!(concat!(env!("S"), "/src/version")); let expected_string = format!("stable since {}", version.trim()); - output.assert_stderr_contains(&expected_string); + output.assert_stderr_contains(expected_string); } diff --git a/tests/run-make/crate-data-smoke/rmake.rs b/tests/run-make/crate-data-smoke/rmake.rs index 6f0f0efbdf239..c6a9a531112a3 100644 --- a/tests/run-make/crate-data-smoke/rmake.rs +++ b/tests/run-make/crate-data-smoke/rmake.rs @@ -2,24 +2,24 @@ use run_make_support::{bin_name, rust_lib_name, rustc}; fn main() { rustc().print("crate-name").input("crate.rs").run().assert_stdout_equals("foo"); - rustc().print("file-names").input("crate.rs").run().assert_stdout_equals(&bin_name("foo")); + rustc().print("file-names").input("crate.rs").run().assert_stdout_equals(bin_name("foo")); rustc() .print("file-names") .crate_type("lib") .arg("--test") .input("crate.rs") .run() - .assert_stdout_equals(&bin_name("foo")); + .assert_stdout_equals(bin_name("foo")); rustc() .print("file-names") .arg("--test") .input("lib.rs") .run() - .assert_stdout_equals(&bin_name("mylib")); - rustc().print("file-names").input("lib.rs").run().assert_stdout_equals(&rust_lib_name("mylib")); + .assert_stdout_equals(bin_name("mylib")); + rustc().print("file-names").input("lib.rs").run().assert_stdout_equals(rust_lib_name("mylib")); rustc() .print("file-names") .input("rlib.rs") .run() - .assert_stdout_equals(&rust_lib_name("mylib")); + .assert_stdout_equals(rust_lib_name("mylib")); } diff --git a/tests/run-make/non-unicode-env/rmake.rs b/tests/run-make/non-unicode-env/rmake.rs index 64f66eb7ce841..ed40d7a6d7f07 100644 --- a/tests/run-make/non-unicode-env/rmake.rs +++ b/tests/run-make/non-unicode-env/rmake.rs @@ -7,5 +7,5 @@ fn main() { let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]); let output = rustc().input("non_unicode_env.rs").env("NON_UNICODE_VAR", non_unicode).run_fail(); let expected = std::fs::read_to_string("non_unicode_env.stderr").unwrap(); - output.assert_stderr_equals(&expected); + output.assert_stderr_equals(expected); }