Skip to content

Commit

Permalink
Unrolled build for rust-lang#133875
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#133875 - onur-ozkan:early-return-rustfmt, r=jieyouxu

handle `--json-output` properly

Because `rustfmt` doesn't support JSON output, `x test --json-output` doesn't respect the `--json-output` flag during formatting step. This change makes that `x test` skips the formatting step if `--json-output` is specified. In addition, resolves rust-lang#133855 with the 2nd commit.
  • Loading branch information
rust-timer authored Dec 7, 2024
2 parents cdb89d6 + 31c4057 commit b8eafae
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,23 +1070,33 @@ impl Step for Tidy {
}

if builder.config.channel == "dev" || builder.config.channel == "nightly" {
builder.info("fmt check");
if builder.initial_rustfmt().is_none() {
let inferred_rustfmt_dir = builder.initial_sysroot.join("bin");
eprintln!(
"\
if !builder.config.json_output {
builder.info("fmt check");
if builder.initial_rustfmt().is_none() {
let inferred_rustfmt_dir = builder.initial_sysroot.join("bin");
eprintln!(
"\
ERROR: no `rustfmt` binary found in {PATH}
INFO: `rust.channel` is currently set to \"{CHAN}\"
HELP: if you are testing a beta branch, set `rust.channel` to \"beta\" in the `config.toml` file
HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to `x.py test`",
PATH = inferred_rustfmt_dir.display(),
CHAN = builder.config.channel,
PATH = inferred_rustfmt_dir.display(),
CHAN = builder.config.channel,
);
crate::exit!(1);
}
let all = false;
crate::core::build_steps::format::format(
builder,
!builder.config.cmd.bless(),
all,
&[],
);
} else {
eprintln!(
"WARNING: `--json-output` is not supported on rustfmt, formatting will be skipped"
);
crate::exit!(1);
}
let all = false;
crate::core::build_steps::format::format(builder, !builder.config.cmd.bless(), all, &[
]);
}

builder.info("tidy check");
Expand Down Expand Up @@ -2624,6 +2634,11 @@ fn prepare_cargo_test(
if builder.kind == Kind::Test && !builder.fail_fast {
cargo.arg("--no-fail-fast");
}

if builder.config.json_output {
cargo.arg("--message-format=json");
}

match builder.doc_tests {
DocTests::Only => {
cargo.arg("--doc");
Expand Down

0 comments on commit b8eafae

Please sign in to comment.