Skip to content

Commit

Permalink
Add unit test for Unix fallback settings file
Browse files Browse the repository at this point in the history
  • Loading branch information
frazar committed Nov 3, 2020
1 parent 699afcc commit fab530f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1940,3 +1940,41 @@ fn check_host_goes_away() {
);
})
}

#[cfg(unix)]
#[test]
fn check_unix_settings_fallback() {
setup(&|config| {
// No default toolchain specified yet
expect_err(
config,
&["rustup", "default"],
r"no default toolchain configured",
);

// Default toolchain specified in fallback settings file
let mock_settings_file = config.current_dir().join("mock_fallback_settings.toml");
raw::write_file(
&mock_settings_file,
for_host!(r"default_toolchain = 'nightly-{0}'"),
)
.unwrap();

let mut cmd = clitools::cmd(config, "rustup", &["default"]);
clitools::env(config, &mut cmd);

// Override the path to the fallback settings file to be the mock file
cmd.env("RUSTUP_OVERRIDE_UNIX_FALLBACK_SETTINGS", mock_settings_file);

let out = cmd.output().unwrap();
assert!(out.status.success());
let stdout = String::from_utf8(out.stdout).unwrap();
assert_eq!(
&stdout,
for_host!(
r"nightly-{0} (default)
"
)
);
});
}

0 comments on commit fab530f

Please sign in to comment.