Skip to content

Commit

Permalink
[ci skip] (wip) Add unit tests for Cfg overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Nov 2, 2023
1 parent 6f95958 commit 5d8a064
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ enum ParseMode {
mod tests {
use rustup_macros::unit_test as test;

use crate::{cli::common::set_globals, utils::raw};

use super::*;

#[test]
Expand Down Expand Up @@ -1248,4 +1250,27 @@ channel = nightly
Ok(OverrideFileConfigError::Parsing)
));
}

/// Checks that `rust-toolchain.toml` configs can be overridden by `<proxy> +<toolchain>`.
/// See: <https://github.com/rust-lang/rustup/issues/3483>
#[test]
fn find_override_config_with_toolchain_override() {
let cwd = crate::test::test_dir().unwrap();
let toolchain_file = cwd.path().join("rust-toolchain.toml");
raw::write_file(
&toolchain_file,
r#"
[toolchain]
channel = "nightly"
components = [ "rls" ]
"#,
)
.unwrap();

let mut cfg = set_globals(true, false).unwrap();
cfg.toolchain_override = Some("beta".try_into().unwrap());

let found_override = cfg.find_override_config(cwd.path()).unwrap();
assert!(dbg!(found_override).is_none());
}
}

0 comments on commit 5d8a064

Please sign in to comment.