Skip to content

Commit aec402b

Browse files
committed
make assert_stderr_contains print its contents on panic
1 parent b6c348f commit aec402b

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
@@ -127,14 +127,14 @@ impl CompletedProcess {
127127

128128
#[track_caller]
129129
pub fn assert_stderr_contains<S: AsRef<str>>(self, needle: S) -> Self {
130+
let needle_str = needle.as_ref();
131+
let stderr_str = self.stderr_utf8().as_str();
132+
130133
assert!(
131-
self.stderr_utf8().contains(needle.as_ref()),
132-
format!(
133-
"The stderr {} did not contain the string {}",
134-
self.stderr_utf8().as_str(),
135-
needle.as_ref(),
136-
)
134+
self.stderr_utf8().contains(needle_str),
135+
format!("The stderr \"{}\" did not contain the string \"{}\"", stderr_str, needle_str)
137136
);
137+
138138
self
139139
}
140140

0 commit comments

Comments
 (0)