Skip to content

Commit 6d26dfa

Browse files
committed
Update force_update param in install_from_dist calls in config.rs
1 parent 8096e9a commit 6d26dfa

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl Cfg {
317317
ErrorKind::OverrideToolchainNotInstalled(name.to_string())
318318
})
319319
} else {
320-
toolchain.install_from_dist(false, &[], &[])?;
320+
toolchain.install_from_dist(true, &[], &[])?;
321321
Ok(Some((toolchain, reason)))
322322
}
323323
}
@@ -478,7 +478,7 @@ impl Cfg {
478478
) -> Result<Command> {
479479
let toolchain = self.get_toolchain(toolchain, false)?;
480480
if install_if_missing && !toolchain.exists() {
481-
toolchain.install_from_dist(false, &[], &[])?;
481+
toolchain.install_from_dist(true, &[], &[])?;
482482
}
483483

484484
if let Some(cmd) = self.maybe_do_cargo_fallback(&toolchain, binary)? {

tests/cli-misc.rs

+64
Original file line numberDiff line numberDiff line change
@@ -905,3 +905,67 @@ fn which() {
905905
);
906906
});
907907
}
908+
909+
#[test]
910+
fn install_toolchain_by_rustup_run_with_install_flag() {
911+
setup(&|config| {
912+
expect_ok(config, &["rustup", "toolchain", "remove", "nightly"]);
913+
expect_ok_ex(
914+
config,
915+
&[
916+
"rustup",
917+
"run",
918+
"--install",
919+
"nightly",
920+
"rustc",
921+
"--version",
922+
],
923+
"1.3.0 (hash-nightly-2)
924+
",
925+
for_host!(
926+
r"info: syncing channel updates for 'nightly-{0}'
927+
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
928+
info: downloading component 'cargo'
929+
info: downloading component 'rust-docs'
930+
info: downloading component 'rust-std'
931+
info: downloading component 'rustc'
932+
info: installing component 'cargo'
933+
info: installing component 'rust-docs'
934+
info: installing component 'rust-std'
935+
info: installing component 'rustc'
936+
"
937+
),
938+
);
939+
});
940+
}
941+
942+
#[test]
943+
fn install_toolchain_by_rustup_default_with_toolchain_arg() {
944+
setup(&|config| {
945+
expect_ok(config, &["rustup", "toolchain", "remove", "nightly"]);
946+
expect_ok_ex(
947+
config,
948+
&["rustup", "default", "nightly"],
949+
for_host!(
950+
r"
951+
nightly-{0} installed - 1.3.0 (hash-nightly-2)
952+
953+
"
954+
),
955+
for_host!(
956+
r"info: syncing channel updates for 'nightly-{0}'
957+
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
958+
info: downloading component 'cargo'
959+
info: downloading component 'rust-docs'
960+
info: downloading component 'rust-std'
961+
info: downloading component 'rustc'
962+
info: installing component 'cargo'
963+
info: installing component 'rust-docs'
964+
info: installing component 'rust-std'
965+
info: installing component 'rustc'
966+
info: default toolchain set to 'nightly-{0}'
967+
"
968+
),
969+
);
970+
});
971+
}

0 commit comments

Comments
 (0)