Skip to content

Commit 3c538ea

Browse files
committed
[nextest-runner] use 1 thread in the miri environment by default
Define a new profile `default-miri`, and use it when `miri` is detected. See rust-lang/miri#2398 (comment) for discussion.
1 parent f584d1f commit 3c538ea

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

cargo-nextest/src/dispatch.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,17 @@ impl App {
937937
profile_name: Option<&str>,
938938
config: &'cfg NextestConfig,
939939
) -> Result<NextestProfile<'cfg>> {
940+
let profile_name = profile_name.unwrap_or_else(|| {
941+
// The "official" way to detect a miri environment is with MIRI_SYSROOT.
942+
// https://github.com/rust-lang/miri/pull/2398#issuecomment-1190747685
943+
if std::env::var_os("MIRI_SYSROOT").is_some() {
944+
NextestConfig::DEFAULT_MIRI_PROFILE
945+
} else {
946+
NextestConfig::DEFAULT_PROFILE
947+
}
948+
});
940949
let profile = config
941-
.profile(profile_name.unwrap_or(NextestConfig::DEFAULT_PROFILE))
950+
.profile(profile_name)
942951
.map_err(ExpectedError::profile_not_found)?;
943952
let store_dir = profile.store_dir();
944953
std::fs::create_dir_all(&store_dir).map_err(|err| ExpectedError::StoreDirCreateError {

nextest-runner/default-config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ leak-timeout = "100ms"
8484
# reports across different test runs, it may be useful to provide separate names
8585
# for each report.
8686
report-name = "nextest-run"
87+
88+
# This profile is activated if MIRI_SYSROOT is set.
89+
[profile.default-miri]
90+
# Miri tests take up a lot of memory, so only run 1 test at a time by default.
91+
test-threads = 1

nextest-runner/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ impl NextestConfig {
4848
/// The name of the default profile.
4949
pub const DEFAULT_PROFILE: &'static str = "default";
5050

51+
/// The name of the default profile used for miri.
52+
pub const DEFAULT_MIRI_PROFILE: &'static str = "default-miri";
53+
5154
/// Reads the nextest config from the given file, or if not specified from `.config/nextest.toml`
5255
/// in the workspace root.
5356
///

0 commit comments

Comments
 (0)