about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-10-18 16:53:43 +0800
committer许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-10-22 19:43:22 +0800
commit921e2f8f669afda3b1f217e70f0b57158fb2f7b3 (patch)
treefd14b03cfae82c25f74383410f069eb1a1c48879
parentf2257130074b0f3ee958ae48d6ed85648c365e92 (diff)
downloadrust-921e2f8f669afda3b1f217e70f0b57158fb2f7b3.tar.gz
rust-921e2f8f669afda3b1f217e70f0b57158fb2f7b3.zip
run_make_support: allow obtaining raw stdout/stderr
And match `stdout/stderr` lossy UTF-8 helpers.
-rw-r--r--src/tools/run-make-support/src/command.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs
index 6b58173b343..9e09527d6d0 100644
--- a/src/tools/run-make-support/src/command.rs
+++ b/src/tools/run-make-support/src/command.rs
@@ -224,6 +224,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 {
         String::from_utf8(self.output.stdout.clone()).expect("stdout is not valid UTF-8")
     }
@@ -236,11 +242,23 @@ impl CompletedProcess {
 
     #[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
     }