Skip to content

Rollup of 7 pull requests #128017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9f7e049
Distribute rustc_codegen_cranelift for arm64 macOS
bjorn3 Jun 30, 2024
64ec270
Promote Mac Catalyst targets to tier 2, and ship with rustup
madsmtm Jun 13, 2024
d12d122
rewrite and rename issue-14698 to rmake
Oneirical Jul 16, 2024
5a10ceb
rewrite and rename issue-33329 to ui test
Oneirical Jul 16, 2024
1a0baaa
rewrite and rename issue-107094 to rmake
Oneirical Jul 16, 2024
ead6aad
Make command output capturing more explicit
Kobzol Jul 7, 2024
1984a46
Make it easier to detect when bootstrap tries to read uncaptured stdo…
Kobzol Jul 7, 2024
5b0b4ff
Update wasi-sdk in CI to latest release
alexcrichton Jul 19, 2024
006c884
Fix two new failing tests
alexcrichton Jul 19, 2024
7b19389
rewrite test-benches to rmake
Oneirical Jul 19, 2024
2733494
rewrite c-unwind-abi-catch-panic to rmake
Oneirical Jul 19, 2024
2192a91
rewrite compiler-lookup-paths-2 to rmake
Oneirical Jul 19, 2024
59429e6
Rewrite `test-float-parse` in Rust
tgross35 Jul 20, 2024
51827ce
Move `test-float-parse` to the global workspace
tgross35 Jul 20, 2024
6062059
Expose `test-float-parse` via bootstrap
tgross35 Jul 20, 2024
7f7ec2d
Run `test-float-parse` as part of CI
tgross35 Jul 20, 2024
6c2944d
Rollup merge of #126450 - madsmtm:promote-mac-catalyst, r=Mark-Simula…
matthiaskrgr Jul 20, 2024
ef5b297
Rollup merge of #127177 - bjorn3:arm64_macos_cg_clif, r=Mark-Simulacrum
matthiaskrgr Jul 20, 2024
89049ae
Rollup merge of #127510 - tgross35:test-float-parse-update, r=Mark-Si…
matthiaskrgr Jul 20, 2024
5582a3e
Rollup merge of #127799 - Kobzol:bootstrap-cmd-refactor-7, r=onur-ozkan
matthiaskrgr Jul 20, 2024
f31c7a5
Rollup merge of #127820 - Oneirical:intestellar-travel, r=jieyouxu
matthiaskrgr Jul 20, 2024
863fcea
Rollup merge of #127977 - alexcrichton:update-wasi-sdk, r=Mark-Simula…
matthiaskrgr Jul 20, 2024
7c6d836
Rollup merge of #127985 - Oneirical:testibule-of-hell, r=Kobzol
matthiaskrgr Jul 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make it easier to detect when bootstrap tries to read uncaptured stdo…
…ut/stderr

If e.g. only stdout is captured, but the caller tries to read stderr, previously
they would get back an empty string. Now the code will explicitly panic when
accessing an uncaptured output stream.
  • Loading branch information
Kobzol committed Jul 19, 2024
commit 1984a463df694e40b3415d7beb50f414a3a78f49
6 changes: 4 additions & 2 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,9 @@ impl Build {
let mut message = String::new();
let output: CommandOutput = match output {
// Command has succeeded
Ok(output) if output.status.success() => output.into(),
Ok(output) if output.status.success() => {
CommandOutput::from_output(output, stdout, stderr)
}
// Command has started, but then it failed
Ok(output) => {
writeln!(
Expand All @@ -982,7 +984,7 @@ Executed at: {executed_at}"#,
)
.unwrap();

let output: CommandOutput = output.into();
let output: CommandOutput = CommandOutput::from_output(output, stdout, stderr);

// If the output mode is OutputMode::Capture, we can now print the output.
// If it is OutputMode::Print, then the output has already been printed to
Expand Down
46 changes: 28 additions & 18 deletions src/bootstrap/src/utils/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,31 @@ pub fn command<S: AsRef<OsStr>>(program: S) -> BootstrapCommand {
}

/// Represents the output of an executed process.
#[allow(unused)]
pub struct CommandOutput {
status: CommandStatus,
stdout: Vec<u8>,
stderr: Vec<u8>,
stdout: Option<Vec<u8>>,
stderr: Option<Vec<u8>>,
}

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

#[must_use]
pub fn from_output(output: Output, stdout: OutputMode, stderr: OutputMode) -> Self {
Self {
status: CommandStatus::Finished(output.status),
stdout: match stdout {
OutputMode::Print => None,
OutputMode::Capture => Some(output.stdout),
},
stderr: match stderr {
OutputMode::Print => None,
OutputMode::Capture => Some(output.stderr),
},
}
}

#[must_use]
Expand All @@ -259,7 +273,10 @@ impl CommandOutput {

#[must_use]
pub fn stdout(&self) -> String {
String::from_utf8(self.stdout.clone()).expect("Cannot parse process stdout as UTF-8")
String::from_utf8(
self.stdout.clone().expect("Accessing stdout of a command that did not capture stdout"),
)
.expect("Cannot parse process stdout as UTF-8")
}

#[must_use]
Expand All @@ -269,26 +286,19 @@ impl CommandOutput {

#[must_use]
pub fn stderr(&self) -> String {
String::from_utf8(self.stderr.clone()).expect("Cannot parse process stderr as UTF-8")
String::from_utf8(
self.stderr.clone().expect("Accessing stderr of a command that did not capture stderr"),
)
.expect("Cannot parse process stderr as UTF-8")
}
}

impl Default for CommandOutput {
fn default() -> Self {
Self {
status: CommandStatus::Finished(ExitStatus::default()),
stdout: vec![],
stderr: vec![],
}
}
}

impl From<Output> for CommandOutput {
fn from(output: Output) -> Self {
Self {
status: CommandStatus::Finished(output.status),
stdout: output.stdout,
stderr: output.stderr,
stdout: Some(vec![]),
stderr: Some(vec![]),
}
}
}
Loading