Skip to content

Commit ee0e366

Browse files
author
chansuke
committed
Add testing for damaged toolchain
1 parent 810019b commit ee0e366

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

tests/cli-rustup.rs

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use rustup::test::this_host_triple;
1111
use rustup::utils::raw;
1212

1313
use crate::mock::clitools::{
14-
self, expect_err, expect_not_stdout_ok, expect_ok, expect_ok_ex, expect_stderr_ok,
15-
expect_stdout_ok, run, set_current_dist_date, Config, Scenario,
14+
self, expect_err, expect_not_stderr_ok, expect_not_stdout_ok, expect_ok, expect_ok_ex,
15+
expect_stderr_ok, expect_stdout_ok, run, set_current_dist_date, Config, Scenario,
1616
};
1717

1818
macro_rules! for_host_and_home {
@@ -803,6 +803,42 @@ fn list_default_and_override_toolchain() {
803803
});
804804
}
805805

806+
#[test]
807+
fn heal_damaged_toolchain() {
808+
setup(&|config| {
809+
expect_ok(config, &["rustup", "default", "nightly"]);
810+
expect_not_stderr_ok(
811+
config,
812+
&["rustup", "show", "active-toolchain"],
813+
"syncing channel updates",
814+
);
815+
let path = format!(
816+
"toolchains/nightly-{}/lib/rustlib/multirust-channel-manifest.toml",
817+
this_host_triple()
818+
);
819+
fs::remove_file(config.rustupdir.join(path)).unwrap();
820+
expect_ok_ex(
821+
config,
822+
&["rustup", "show", "active-toolchain"],
823+
&format!(
824+
r"nightly-{0} (default)
825+
",
826+
this_host_triple()
827+
),
828+
for_host!(
829+
r"info: syncing channel updates for 'nightly-{0}'
830+
"
831+
),
832+
);
833+
expect_ok(config, &["rustup", "default", "nightly"]);
834+
expect_stderr_ok(
835+
config,
836+
&["rustup", "show", "active-toolchain"],
837+
"syncing channel updates",
838+
);
839+
});
840+
}
841+
806842
#[test]
807843
#[ignore = "FIXME: Windows shows UNC paths"]
808844
fn show_toolchain_override() {

0 commit comments

Comments
 (0)