Skip to content

Commit 61207da

Browse files
authoredJun 11, 2024
Rollup merge of #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`
2 parents 76acf26 + 168d5c2 commit 61207da

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -107,38 +107,38 @@ impl CompletedProcess {
107107

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

115115
#[track_caller]
116-
pub fn assert_stdout_not_contains<S: AsRef<str>>(self, needle: S) -> Self {
116+
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
117117
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<S: AsRef<str>>(self, content: S) -> Self {
123+
pub fn assert_stderr_equals<S: AsRef<str>>(&self, content: S) -> &Self {
124124
assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim());
125125
self
126126
}
127127

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

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

140140
#[track_caller]
141-
pub fn assert_exit_code(self, code: i32) -> Self {
141+
pub fn assert_exit_code(&self, code: i32) -> &Self {
142142
assert!(self.output.status.code() == Some(code));
143143
self
144144
}

0 commit comments

Comments
 (0)