From c8cef5bfaa57d58ef87799281f1394286ab85b0a Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 30 Jun 2025 15:03:17 +0800 Subject: [PATCH 1/3] Move some early config checks to the compiletest lib --- src/tools/compiletest/src/lib.rs | 15 +++++++++++++++ src/tools/compiletest/src/main.rs | 16 ++-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 0db4d3f6a4100..c1a4839605cf2 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -1111,3 +1111,18 @@ fn check_for_overlapping_test_paths(found_path_stems: &HashSet) { ); } } + +pub fn early_config_check(config: &Config) { + if !config.has_html_tidy && config.mode == Mode::Rustdoc { + eprintln!("warning: `tidy` (html-tidy.org) is not installed; diffs will not be generated"); + } + + if !config.profiler_runtime && config.mode == Mode::CoverageRun { + let actioned = if config.bless { "blessed" } else { "checked" }; + eprintln!( + r#" +WARNING: profiler runtime is not available, so `.coverage` files won't be {actioned} +help: try setting `profiler = true` in the `[build]` section of `bootstrap.toml`"# + ); + } +} diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index b9ae583581ef2..1f777e71cf97f 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -2,8 +2,7 @@ use std::env; use std::io::IsTerminal; use std::sync::Arc; -use compiletest::common::Mode; -use compiletest::{log_config, parse_config, run_tests}; +use compiletest::{early_config_check, log_config, parse_config, run_tests}; fn main() { tracing_subscriber::fmt::init(); @@ -18,18 +17,7 @@ fn main() { let config = Arc::new(parse_config(env::args().collect())); - if !config.has_html_tidy && config.mode == Mode::Rustdoc { - eprintln!("warning: `tidy` (html-tidy.org) is not installed; diffs will not be generated"); - } - - if !config.profiler_runtime && config.mode == Mode::CoverageRun { - let actioned = if config.bless { "blessed" } else { "checked" }; - eprintln!( - r#" -WARNING: profiler runtime is not available, so `.coverage` files won't be {actioned} -help: try setting `profiler = true` in the `[build]` section of `bootstrap.toml`"# - ); - } + early_config_check(&config); log_config(&config); run_tests(config); From f03074da23c4b3e4e8ffcff3408151929a583fdf Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 30 Jun 2025 15:09:03 +0800 Subject: [PATCH 2/3] Move compiletest `main.rs` to `src/bin/` To make it obvious `compiletest`-the-tool has two components: 1. The core compiletest library, and 2. The tool binary, which will be executed by bootstrap. --- src/tools/compiletest/Cargo.toml | 4 ++++ src/tools/compiletest/src/{ => bin}/main.rs | 0 2 files changed, 4 insertions(+) rename src/tools/compiletest/src/{ => bin}/main.rs (100%) diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml index 3b544d8b82817..cdada5a223062 100644 --- a/src/tools/compiletest/Cargo.toml +++ b/src/tools/compiletest/Cargo.toml @@ -6,6 +6,10 @@ edition = "2024" [lib] doctest = false +[[bin]] +name = "compiletest" +path = "src/bin/main.rs" + [dependencies] # tidy-alphabetical-start anstyle-svg = "0.1.3" diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/bin/main.rs similarity index 100% rename from src/tools/compiletest/src/main.rs rename to src/tools/compiletest/src/bin/main.rs From e664e7e1166d4b15e7631c9e5014f107449e8d06 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Mon, 30 Jun 2025 15:16:22 +0800 Subject: [PATCH 3/3] Move `RUST_TEST_NOCAPTURE` warning to early config check --- src/tools/compiletest/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index c1a4839605cf2..23a4dd73796e2 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -51,12 +51,6 @@ use crate::util::logv; /// some code here that inspects environment variables or even runs executables /// (e.g. when discovering debugger versions). pub fn parse_config(args: Vec) -> Config { - if env::var("RUST_TEST_NOCAPTURE").is_ok() { - eprintln!( - "WARNING: RUST_TEST_NOCAPTURE is not supported. Use the `--no-capture` flag instead." - ); - } - let mut opts = Options::new(); opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH") .reqopt("", "run-lib-path", "path to target shared libraries", "PATH") @@ -1125,4 +1119,11 @@ WARNING: profiler runtime is not available, so `.coverage` files won't be {actio help: try setting `profiler = true` in the `[build]` section of `bootstrap.toml`"# ); } + + // `RUST_TEST_NOCAPTURE` is a libtest env var, but we don't callout to libtest. + if env::var("RUST_TEST_NOCAPTURE").is_ok() { + eprintln!( + "WARNING: RUST_TEST_NOCAPTURE is not supported. Use the `--no-capture` flag instead." + ); + } }