Skip to content

Commit cd0d201

Browse files
authored
Merge pull request #683 from rust-lang-nursery/fix-remove-component
Fix `component remove` command and add a test for it.
2 parents 2c38faa + 2097393 commit cd0d201

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,12 +638,13 @@ fn component_add(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
638638

639639
fn component_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
640640
let toolchain = try!(explicit_or_dir_toolchain(cfg, m));
641+
let component = m.value_of("component").expect("");
641642
let target = m.value_of("target").map(TargetTriple::from_str).or_else(|| {
642643
toolchain.desc().as_ref().ok().map(|desc| desc.target.clone())
643644
});
644645

645646
let new_component = Component {
646-
pkg: "rust-std".to_string(),
647+
pkg: component.to_string(),
647648
target: target,
648649
};
649650

tests/cli-rustup.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ fn proxy_toolchain_shorthand() {
520520
}
521521

522522
#[test]
523-
fn src_component_smoke_test() {
523+
fn add_component() {
524524
setup(&|config| {
525525
expect_ok(config, &["rustup", "default", "stable"]);
526526
expect_ok(config, &["rustup", "component", "add", "rust-src"]);
@@ -530,3 +530,17 @@ fn src_component_smoke_test() {
530530
assert!(path.exists());
531531
});
532532
}
533+
534+
#[test]
535+
fn remove_component() {
536+
setup(&|config| {
537+
expect_ok(config, &["rustup", "default", "stable"]);
538+
expect_ok(config, &["rustup", "component", "add", "rust-src"]);
539+
let path = format!("toolchains/stable-{}/lib/rustlib/src/rust-src/foo.rs",
540+
this_host_triple());
541+
let path = config.rustupdir.join(path);
542+
assert!(path.exists());
543+
expect_ok(config, &["rustup", "component", "remove", "rust-src"]);
544+
assert!(!path.parent().unwrap().exists());
545+
});
546+
}

0 commit comments

Comments
 (0)