Skip to content

Commit

Permalink
Unrolled build for rust-lang#126253
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#126253 - Kobzol:run-make-assert-ref-self, r=jieyouxu

Simplify assert matchers in `run-make-support`

See [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/421156-gsoc/topic/Project.3A.20Rewriting.20Makefile.20Tests.20Using.20Rust/near/443922302) for context. This should make it easier to use the matchers.

r? `@jieyouxu`
  • Loading branch information
rust-timer authored Jun 11, 2024
2 parents 336e6ab + 168d5c2 commit 9125f14
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,38 @@ impl CompletedProcess {

/// Checks that trimmed `stdout` matches trimmed `content`.
#[track_caller]
pub fn assert_stdout_equals<S: AsRef<str>>(self, content: S) -> Self {
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<S: AsRef<str>>(self, needle: S) -> Self {
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<S: AsRef<str>>(self, content: S) -> Self {
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<S: AsRef<str>>(self, needle: S) -> Self {
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<S: AsRef<str>>(self, needle: S) -> Self {
pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
self
}

#[track_caller]
pub fn assert_exit_code(self, code: i32) -> Self {
pub fn assert_exit_code(&self, code: i32) -> &Self {
assert!(self.output.status.code() == Some(code));
self
}
Expand Down

0 comments on commit 9125f14

Please sign in to comment.