diff --git a/Cargo.toml b/Cargo.toml index e445889a58f..ef5b0a0cd78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,6 +50,7 @@ syn = { version = "1.0", features = ["full"] } futures = "0.3" parking_lot = "0.11.2" tokio = { version = "1", features = ["io-util"] } +num_cpus = "1.13" [build-dependencies] rustc_tools_util = { version = "0.2", path = "rustc_tools_util" } diff --git a/tests/compile-test.rs b/tests/compile-test.rs index a82ff182839..6bc74bc1e9a 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -162,6 +162,11 @@ fn run_ui() { let config = base_config("ui"); // use tests/clippy.toml let _g = VarGuard::set("CARGO_MANIFEST_DIR", fs::canonicalize("tests").unwrap()); + let _threads = VarGuard::set( + "RUST_TEST_THREADS", + // if RUST_TEST_THREADS is set, adhere to it, otherwise override it + env::var("RUST_TEST_THREADS").unwrap_or_else(|_| num_cpus::get().to_string()), + ); compiletest::run_tests(&config); }