run_make_support: allow obtaining raw stdout/stderr

And match `stdout/stderr` lossy UTF-8 helpers.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-10-18 16:53:43 +08:00
parent f225713007
commit 921e2f8f66

View File

@ -222,6 +222,12 @@ pub struct CompletedProcess {
}
impl CompletedProcess {
#[must_use]
#[track_caller]
pub fn stdout(&self) -> Vec<u8> {
self.output.stdout.clone()
}
#[must_use]
#[track_caller]
pub fn stdout_utf8(&self) -> String {
@ -234,12 +240,24 @@ pub fn invalid_stdout_utf8(&self) -> String {
String::from_utf8_lossy(&self.output.stdout.clone()).to_string()
}
#[must_use]
#[track_caller]
pub fn stderr(&self) -> Vec<u8> {
self.output.stderr.clone()
}
#[must_use]
#[track_caller]
pub fn stderr_utf8(&self) -> String {
String::from_utf8(self.output.stderr.clone()).expect("stderr is not valid UTF-8")
}
#[must_use]
#[track_caller]
pub fn invalid_stderr_utf8(&self) -> String {
String::from_utf8_lossy(&self.output.stderr.clone()).to_string()
}
#[must_use]
pub fn status(&self) -> ExitStatus {
self.output.status