Skip to content

Commit 604e91b

Browse files
committed
Fixes to previously-failing tests
1 parent 8d46b2c commit 604e91b

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

nextest-runner/src/list/test_list.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use nextest_metadata::{
2424
use once_cell::sync::{Lazy, OnceCell};
2525
use owo_colors::OwoColorize;
2626
use std::{
27-
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
27+
collections::{BTreeMap, BTreeSet, HashMap},
2828
ffi::{OsStr, OsString},
2929
io,
3030
io::Write,
@@ -908,10 +908,13 @@ pub(crate) fn make_test_command(
908908
};
909909

910910
// NB: we will always override user-provided environment variables with the
911-
// ones we set below.
912-
let mut existing_keys: HashSet<_> = std::env::vars_os()
913-
.map(|(k, _v)| k)
914-
.map(make_windows_compatible_key)
911+
// `CARGO_*` and `NEXTEST_*` variables set directly on `cmd` below.
912+
enum EnvSource {
913+
Env,
914+
CargoConfig,
915+
}
916+
let mut existing_keys: HashMap<OsString, EnvSource> = std::env::vars_os()
917+
.map(|(k, _v)| (make_windows_compatible_key(k), EnvSource::Env))
915918
.collect();
916919
for CargoEnvironmentVariable {
917920
source,
@@ -922,7 +925,20 @@ pub(crate) fn make_test_command(
922925
} in env
923926
{
924927
let name_os_string = make_windows_compatible_key(OsString::from(name));
925-
if !existing_keys.insert(name_os_string) && !force {
928+
let should_set_value = match existing_keys.insert(name_os_string, EnvSource::CargoConfig) {
929+
None => {
930+
// No key with this name was set, proceed to set the value.
931+
true
932+
}
933+
Some(EnvSource::CargoConfig) => {
934+
// Always prefer previously-set cargo config values, since they have higher
935+
// precedence. Note that `force` only applies to overwriting environment variables,
936+
// not other cargo config values.
937+
false
938+
}
939+
Some(EnvSource::Env) => *force,
940+
};
941+
if !should_set_value {
926942
continue;
927943
}
928944

0 commit comments

Comments
 (0)