Skip to content

Commit d70e9ec

Browse files
committed
Revert "Make it easier to detect when bootstrap tries to read uncaptured stdout/stderr"
This reverts commit 82d5743.
1 parent be9a616 commit d70e9ec

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

src/bootstrap/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,7 @@ impl Build {
10221022
let mut message = String::new();
10231023
let output: CommandOutput = match output {
10241024
// Command has succeeded
1025-
Ok(output) if output.status.success() => {
1026-
CommandOutput::from_output(output, stdout, stderr)
1027-
}
1025+
Ok(output) if output.status.success() => output.into(),
10281026
// Command has started, but then it failed
10291027
Ok(output) => {
10301028
writeln!(
@@ -1038,7 +1036,7 @@ Executed at: {executed_at}"#,
10381036
)
10391037
.unwrap();
10401038

1041-
let output: CommandOutput = CommandOutput::from_output(output, stdout, stderr);
1039+
let output: CommandOutput = output.into();
10421040

10431041
// If the output mode is OutputMode::Capture, we can now print the output.
10441042
// If it is OutputMode::Print, then the output has already been printed to

src/bootstrap/src/utils/exec.rs

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -223,31 +223,17 @@ pub fn command<S: AsRef<OsStr>>(program: S) -> BootstrapCommand {
223223
}
224224

225225
/// Represents the output of an executed process.
226+
#[allow(unused)]
226227
pub struct CommandOutput {
227228
status: CommandStatus,
228-
stdout: Option<Vec<u8>>,
229-
stderr: Option<Vec<u8>>,
229+
stdout: Vec<u8>,
230+
stderr: Vec<u8>,
230231
}
231232

232233
impl CommandOutput {
233234
#[must_use]
234235
pub fn did_not_start() -> Self {
235-
Self { status: CommandStatus::DidNotStart, stdout: None, stderr: None }
236-
}
237-
238-
#[must_use]
239-
pub fn from_output(output: Output, stdout: OutputMode, stderr: OutputMode) -> Self {
240-
Self {
241-
status: CommandStatus::Finished(output.status),
242-
stdout: match stdout {
243-
OutputMode::Print => None,
244-
OutputMode::Capture => Some(output.stdout),
245-
},
246-
stderr: match stderr {
247-
OutputMode::Print => None,
248-
OutputMode::Capture => Some(output.stderr),
249-
},
250-
}
236+
Self { status: CommandStatus::DidNotStart, stdout: vec![], stderr: vec![] }
251237
}
252238

253239
#[must_use]
@@ -273,10 +259,7 @@ impl CommandOutput {
273259

274260
#[must_use]
275261
pub fn stdout(&self) -> String {
276-
String::from_utf8(
277-
self.stdout.clone().expect("Accessing stdout of a command that did not capture stdout"),
278-
)
279-
.expect("Cannot parse process stdout as UTF-8")
262+
String::from_utf8(self.stdout.clone()).expect("Cannot parse process stdout as UTF-8")
280263
}
281264

282265
#[must_use]
@@ -286,19 +269,26 @@ impl CommandOutput {
286269

287270
#[must_use]
288271
pub fn stderr(&self) -> String {
289-
String::from_utf8(
290-
self.stderr.clone().expect("Accessing stderr of a command that did not capture stderr"),
291-
)
292-
.expect("Cannot parse process stderr as UTF-8")
272+
String::from_utf8(self.stderr.clone()).expect("Cannot parse process stderr as UTF-8")
293273
}
294274
}
295275

296276
impl Default for CommandOutput {
297277
fn default() -> Self {
298278
Self {
299279
status: CommandStatus::Finished(ExitStatus::default()),
300-
stdout: Some(vec![]),
301-
stderr: Some(vec![]),
280+
stdout: vec![],
281+
stderr: vec![],
282+
}
283+
}
284+
}
285+
286+
impl From<Output> for CommandOutput {
287+
fn from(output: Output) -> Self {
288+
Self {
289+
status: CommandStatus::Finished(output.status),
290+
stdout: output.stdout,
291+
stderr: output.stderr,
302292
}
303293
}
304294
}

0 commit comments

Comments
 (0)