Skip to content

Commit

Permalink
Fix storing of stdout/stderr in bootstrap commands that failed to start
Browse files Browse the repository at this point in the history
Before, their stdout/stderr was forcefully set to `None`, even if the corresponding command tried to capture output.
  • Loading branch information
Kobzol committed Jul 26, 2024
1 parent 603c0af commit abd8768
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ Executed at: {executed_at}"#,
\nIt was not possible to execute the command: {e:?}"
)
.unwrap();
CommandOutput::did_not_start()
CommandOutput::did_not_start(stdout, stderr)
}
};
if !output.is_success() {
Expand Down
14 changes: 12 additions & 2 deletions src/bootstrap/src/utils/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,18 @@ pub struct CommandOutput {

impl CommandOutput {
#[must_use]
pub fn did_not_start() -> Self {
Self { status: CommandStatus::DidNotStart, stdout: None, stderr: None }
pub fn did_not_start(stdout: OutputMode, stderr: OutputMode) -> Self {
Self {
status: CommandStatus::DidNotStart,
stdout: match stdout {
OutputMode::Print => None,
OutputMode::Capture => Some(vec![]),
},
stderr: match stderr {
OutputMode::Print => None,
OutputMode::Capture => Some(vec![]),
},
}
}

#[must_use]
Expand Down

0 comments on commit abd8768

Please sign in to comment.