From 7a15061fbcff6f21aca7fc2b948de484bf21a69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 1 Mar 2022 20:56:03 +0100 Subject: [PATCH] tests: use std::thread::available_parallelism() instead of num_cpus to get thread count removes the dependency added in https://github.com/rust-lang/rust-clippy/pull/8451 --- Cargo.toml | 1 - tests/compile-test.rs | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4ea704296..6cf24a0c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,6 @@ futures = "0.3" parking_lot = "0.11.2" tokio = { version = "1", features = ["io-util"] } rustc-semver = "1.1" -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 fc441e608..c9710e3db 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -168,7 +168,11 @@ fn run_ui() { 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()), + env::var("RUST_TEST_THREADS").unwrap_or_else(|_| { + std::thread::available_parallelism() + .map_or(1, std::num::NonZeroUsize::get) + .to_string() + }), ); compiletest::run_tests(&config); }