Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jun 7, 2024
1 parent 1023697 commit 4d4944d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
24 changes: 12 additions & 12 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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<S: AsRef<str>>(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<S: AsRef<str>>(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<S: AsRef<str>>(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<S: AsRef<str>>(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<S: AsRef<str>>(self, needle: S) -> Self {
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
self
}

Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
10 changes: 5 additions & 5 deletions tests/run-make/crate-data-smoke/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
2 changes: 1 addition & 1 deletion tests/run-make/non-unicode-env/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 4d4944d

Please sign in to comment.