Take &self
in CompletedProcess
assert matchers
This commit is contained in:
parent
a3167859f2
commit
168d5c245f
@ -107,38 +107,38 @@ pub fn status(&self) -> ExitStatus {
|
|||||||
|
|
||||||
/// Checks that trimmed `stdout` matches trimmed `content`.
|
/// Checks that trimmed `stdout` matches trimmed `content`.
|
||||||
#[track_caller]
|
#[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());
|
assert_eq!(self.stdout_utf8().trim(), content.as_ref().trim());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[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());
|
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that trimmed `stderr` matches trimmed `content`.
|
/// Checks that trimmed `stderr` matches trimmed `content`.
|
||||||
#[track_caller]
|
#[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());
|
assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[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()));
|
assert!(self.stderr_utf8().contains(needle.as_ref()));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[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());
|
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[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));
|
assert!(self.output.status.code() == Some(code));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user