Skip to content

Commit b4f64fd

Browse files
committed
compiletest: Isolate APIs used by bin/main.rs
1 parent 8f08156 commit b4f64fd

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed
Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
use std::env;
2-
use std::io::IsTerminal;
3-
use std::sync::Arc;
4-
5-
use compiletest::{early_config_check, parse_config, run_tests};
6-
71
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-
run_tests(config);
2+
compiletest::cli::main();
233
}

src/tools/compiletest/src/cli.rs

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

src/tools/compiletest/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#[cfg(test)]
44
mod tests;
55

6+
pub mod cli;
67
pub mod common;
78
mod debuggers;
89
pub mod diagnostics;

0 commit comments

Comments
 (0)