From 83909b6b05b38daaf69af523d4c852a45e252d2b Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 5 Dec 2024 00:29:29 +0300 Subject: [PATCH 1/2] skip formatting when `--json-output` is used Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/test.rs | 32 ++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 4fa91c1a57144..98bfc40fd7a9b 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -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"); From 31c4057bb8edb92671e632e22eec2c14ef19c556 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 5 Dec 2024 10:17:26 +0000 Subject: [PATCH 2/2] handle `json_output` in `test::run_cargo_test` Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/test.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 98bfc40fd7a9b..db246b97515e5 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2634,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");