Skip to content

Commit 4d4944d

Browse files
committed
Address review comments
1 parent 1023697 commit 4d4944d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/tools/run-make-support/src/command.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Command {
2525
/// Run the constructed command and assert that it is successfully run.
2626
#[track_caller]
2727
pub fn run(&mut self) -> CompletedProcess {
28-
let caller_location = ::std::panic::Location::caller();
28+
let caller_location = std::panic::Location::caller();
2929
let caller_line_number = caller_location.line();
3030

3131
let output = self.command_output();
@@ -38,7 +38,7 @@ impl Command {
3838
/// Run the constructed command and assert that it does not successfully run.
3939
#[track_caller]
4040
pub fn run_fail(&mut self) -> CompletedProcess {
41-
let caller_location = ::std::panic::Location::caller();
41+
let caller_location = std::panic::Location::caller();
4242
let caller_line_number = caller_location.line();
4343

4444
let output = self.command_output();
@@ -107,33 +107,33 @@ impl CompletedProcess {
107107

108108
/// Checks that trimmed `stdout` matches trimmed `content`.
109109
#[track_caller]
110-
pub fn assert_stdout_equals(self, content: &str) -> Self {
111-
assert_eq!(self.stdout_utf8().trim(), content.trim());
110+
pub fn assert_stdout_equals<S: AsRef<str>>(self, content: S) -> Self {
111+
assert_eq!(self.stdout_utf8().trim(), content.as_ref().trim());
112112
self
113113
}
114114

115115
#[track_caller]
116-
pub fn assert_stdout_not_contains(self, needle: &str) -> Self {
117-
assert_not_contains(&self.stdout_utf8(), needle);
116+
pub fn assert_stdout_not_contains<S: AsRef<str>>(self, needle: S) -> Self {
117+
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
118118
self
119119
}
120120

121121
/// Checks that trimmed `stderr` matches trimmed `content`.
122122
#[track_caller]
123-
pub fn assert_stderr_equals(self, content: &str) -> Self {
124-
assert_eq!(self.stderr_utf8().trim(), content.trim());
123+
pub fn assert_stderr_equals<S: AsRef<str>>(self, content: S) -> Self {
124+
assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim());
125125
self
126126
}
127127

128128
#[track_caller]
129-
pub fn assert_stderr_contains(self, needle: &str) -> Self {
130-
assert!(self.stderr_utf8().contains(needle));
129+
pub fn assert_stderr_contains<S: AsRef<str>>(self, needle: S) -> Self {
130+
assert!(self.stderr_utf8().contains(needle.as_ref()));
131131
self
132132
}
133133

134134
#[track_caller]
135-
pub fn assert_stderr_not_contains(self, needle: &str) -> Self {
136-
assert_not_contains(&self.stdout_utf8(), needle);
135+
pub fn assert_stderr_not_contains<S: AsRef<str>>(self, needle: S) -> Self {
136+
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
137137
self
138138
}
139139

tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ fn main() {
1515

1616
let version = include_str!(concat!(env!("S"), "/src/version"));
1717
let expected_string = format!("stable since {}", version.trim());
18-
output.assert_stderr_contains(&expected_string);
18+
output.assert_stderr_contains(expected_string);
1919
}

tests/run-make/crate-data-smoke/rmake.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ use run_make_support::{bin_name, rust_lib_name, rustc};
22

33
fn main() {
44
rustc().print("crate-name").input("crate.rs").run().assert_stdout_equals("foo");
5-
rustc().print("file-names").input("crate.rs").run().assert_stdout_equals(&bin_name("foo"));
5+
rustc().print("file-names").input("crate.rs").run().assert_stdout_equals(bin_name("foo"));
66
rustc()
77
.print("file-names")
88
.crate_type("lib")
99
.arg("--test")
1010
.input("crate.rs")
1111
.run()
12-
.assert_stdout_equals(&bin_name("foo"));
12+
.assert_stdout_equals(bin_name("foo"));
1313
rustc()
1414
.print("file-names")
1515
.arg("--test")
1616
.input("lib.rs")
1717
.run()
18-
.assert_stdout_equals(&bin_name("mylib"));
19-
rustc().print("file-names").input("lib.rs").run().assert_stdout_equals(&rust_lib_name("mylib"));
18+
.assert_stdout_equals(bin_name("mylib"));
19+
rustc().print("file-names").input("lib.rs").run().assert_stdout_equals(rust_lib_name("mylib"));
2020
rustc()
2121
.print("file-names")
2222
.input("rlib.rs")
2323
.run()
24-
.assert_stdout_equals(&rust_lib_name("mylib"));
24+
.assert_stdout_equals(rust_lib_name("mylib"));
2525
}

tests/run-make/non-unicode-env/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ fn main() {
77
let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]);
88
let output = rustc().input("non_unicode_env.rs").env("NON_UNICODE_VAR", non_unicode).run_fail();
99
let expected = std::fs::read_to_string("non_unicode_env.stderr").unwrap();
10-
output.assert_stderr_equals(&expected);
10+
output.assert_stderr_equals(expected);
1111
}

0 commit comments

Comments
 (0)