diff --git a/src/bin/install.rs b/src/bin/install.rs index 3f8d50baebe..37d39778468 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -17,7 +17,7 @@ pub struct Options { flag_list: bool, flag_force: bool, - arg_crate: Option, + arg_crate: Vec, flag_vers: Option, flag_git: Option, @@ -32,7 +32,7 @@ pub const USAGE: &'static str = " Install a Rust binary Usage: - cargo install [options] [] + cargo install [options] [...] cargo install [options] --list Specifying what crate to install: @@ -123,20 +123,20 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { SourceId::for_git(&url, gitref) } else if let Some(path) = options.flag_path { try!(SourceId::for_path(&config.cwd().join(path))) - } else if options.arg_crate == None { + } else if options.arg_crate.is_empty() { try!(SourceId::for_path(&config.cwd())) } else { try!(SourceId::for_central(config)) }; - let krate = options.arg_crate.as_ref().map(|s| &s[..]); + let krates = options.arg_crate.iter().map(|s| &s[..]).collect::>(); let vers = options.flag_vers.as_ref().map(|s| &s[..]); let root = options.flag_root.as_ref().map(|s| &s[..]); if options.flag_list { try!(ops::install_list(root, config)); } else { - try!(ops::install(root, krate, &source, vers, &compile_opts, options.flag_force)); + try!(ops::install(root, krates, &source, vers, &compile_opts, options.flag_force)); } Ok(None) } diff --git a/tests/install.rs b/tests/install.rs index 71b61b5e97f..acbe0923a62 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -53,7 +53,45 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina } #[test] -fn pick_max_version() { +test!(multiple_pkgs { + pkg("foo", "0.0.1"); + pkg("bar", "0.0.1"); + + assert_that(cargo_process("install").arg("foo").arg("bar"), + execs().with_status(0).with_stdout(&format!("\ +{updating} registry `[..]` +{downloading} foo v0.0.1 (registry file://[..]) +{compiling} foo v0.0.1 (registry file://[..]) +{installing} {home}[..]bin[..]foo[..] +{downloading} bar v0.0.1 (registry file://[..]) +{compiling} bar v0.0.1 (registry file://[..]) +{installing} {home}[..]bin[..]bar[..] +", + updating = UPDATING, + downloading = DOWNLOADING, + compiling = COMPILING, + installing = INSTALLING, + home = cargo_home().display()))); + assert_that(cargo_home(), has_installed_exe("foo")); + assert_that(cargo_home(), has_installed_exe("bar")); + + assert_that(cargo_process("uninstall").arg("foo"), + execs().with_status(0).with_stdout(&format!("\ +{removing} {home}[..]bin[..]foo[..] +", + removing = REMOVING, + home = cargo_home().display()))); + assert_that(cargo_process("uninstall").arg("bar"), + execs().with_status(0).with_stdout(&format!("\ +{removing} {home}[..]bin[..]bar[..] +", + removing = REMOVING, + home = cargo_home().display()))); + assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_that(cargo_home(), is_not(has_installed_exe("bar"))); +}); + +test!(pick_max_version { pkg("foo", "0.0.1"); pkg("foo", "0.0.2");