Skip to content

Commit 405336e

Browse files
authored
Unrolled build for #143229
Rollup merge of #143229 - jieyouxu:compiletest-maintenance-1, r=Kobzol [COMPILETEST-UNTANGLE 1/N] Move some some early config checks to the lib and move the compiletest binary This is part of a patch series to untangle `compiletest` to hopefully nudge it towards being more maintainable. This PR: - Moves some early config checks (some warnings) to the compiletest library. - Moves `src/main.rs` to `src/bin/main.rs` to make the separation (as in, compiletest's library component vs the tool binary component) more obvious. r? ``@Kobzol`` (or reroll)
2 parents f26e580 + e664e7e commit 405336e

File tree

4 files changed

+50
-42
lines changed

4 files changed

+50
-42
lines changed

src/tools/compiletest/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ edition = "2024"
66
[lib]
77
doctest = false
88

9+
[[bin]]
10+
name = "compiletest"
11+
path = "src/bin/main.rs"
12+
913
[dependencies]
1014
# tidy-alphabetical-start
1115
anstyle-svg = "0.1.3"

src/tools/compiletest/src/bin/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::env;
2+
use std::io::IsTerminal;
3+
use std::sync::Arc;
4+
5+
use compiletest::{early_config_check, log_config, parse_config, run_tests};
6+
7+
fn main() {
8+
tracing_subscriber::fmt::init();
9+
10+
// colored checks stdout by default, but for some reason only stderr is a terminal.
11+
// compiletest *does* print many things to stdout, but it doesn't really matter.
12+
if std::io::stderr().is_terminal()
13+
&& matches!(std::env::var("NO_COLOR").as_deref(), Err(_) | Ok("0"))
14+
{
15+
colored::control::set_override(true);
16+
}
17+
18+
let config = Arc::new(parse_config(env::args().collect()));
19+
20+
early_config_check(&config);
21+
22+
log_config(&config);
23+
run_tests(config);
24+
}

src/tools/compiletest/src/lib.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ use crate::util::logv;
5151
/// some code here that inspects environment variables or even runs executables
5252
/// (e.g. when discovering debugger versions).
5353
pub fn parse_config(args: Vec<String>) -> Config {
54-
if env::var("RUST_TEST_NOCAPTURE").is_ok() {
55-
eprintln!(
56-
"WARNING: RUST_TEST_NOCAPTURE is not supported. Use the `--no-capture` flag instead."
57-
);
58-
}
59-
6054
let mut opts = Options::new();
6155
opts.reqopt("", "compile-lib-path", "path to host shared libraries", "PATH")
6256
.reqopt("", "run-lib-path", "path to target shared libraries", "PATH")
@@ -1111,3 +1105,25 @@ fn check_for_overlapping_test_paths(found_path_stems: &HashSet<Utf8PathBuf>) {
11111105
);
11121106
}
11131107
}
1108+
1109+
pub fn early_config_check(config: &Config) {
1110+
if !config.has_html_tidy && config.mode == Mode::Rustdoc {
1111+
eprintln!("warning: `tidy` (html-tidy.org) is not installed; diffs will not be generated");
1112+
}
1113+
1114+
if !config.profiler_runtime && config.mode == Mode::CoverageRun {
1115+
let actioned = if config.bless { "blessed" } else { "checked" };
1116+
eprintln!(
1117+
r#"
1118+
WARNING: profiler runtime is not available, so `.coverage` files won't be {actioned}
1119+
help: try setting `profiler = true` in the `[build]` section of `bootstrap.toml`"#
1120+
);
1121+
}
1122+
1123+
// `RUST_TEST_NOCAPTURE` is a libtest env var, but we don't callout to libtest.
1124+
if env::var("RUST_TEST_NOCAPTURE").is_ok() {
1125+
eprintln!(
1126+
"WARNING: RUST_TEST_NOCAPTURE is not supported. Use the `--no-capture` flag instead."
1127+
);
1128+
}
1129+
}

src/tools/compiletest/src/main.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)