compiletest/
cli.rs

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
4use std::env;
5use std::io::IsTerminal;
6use std::sync::Arc;
7
8use crate::{early_config_check, parse_config, run_tests};
9
10pub 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}