Skip to content

Commit 5d8a064

Browse files
committed
[ci skip] (wip) Add unit tests for Cfg overriding
1 parent 6f95958 commit 5d8a064

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/config.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@ enum ParseMode {
10461046
mod tests {
10471047
use rustup_macros::unit_test as test;
10481048

1049+
use crate::{cli::common::set_globals, utils::raw};
1050+
10491051
use super::*;
10501052

10511053
#[test]
@@ -1248,4 +1250,27 @@ channel = nightly
12481250
Ok(OverrideFileConfigError::Parsing)
12491251
));
12501252
}
1253+
1254+
/// Checks that `rust-toolchain.toml` configs can be overridden by `<proxy> +<toolchain>`.
1255+
/// See: <https://github.com/rust-lang/rustup/issues/3483>
1256+
#[test]
1257+
fn find_override_config_with_toolchain_override() {
1258+
let cwd = crate::test::test_dir().unwrap();
1259+
let toolchain_file = cwd.path().join("rust-toolchain.toml");
1260+
raw::write_file(
1261+
&toolchain_file,
1262+
r#"
1263+
[toolchain]
1264+
channel = "nightly"
1265+
components = [ "rls" ]
1266+
"#,
1267+
)
1268+
.unwrap();
1269+
1270+
let mut cfg = set_globals(true, false).unwrap();
1271+
cfg.toolchain_override = Some("beta".try_into().unwrap());
1272+
1273+
let found_override = cfg.find_override_config(cwd.path()).unwrap();
1274+
assert!(dbg!(found_override).is_none());
1275+
}
12511276
}

0 commit comments

Comments
 (0)