2016-05-26 00:06:25 +00:00
|
|
|
extern crate cargo;
|
|
|
|
extern crate cargotest;
|
|
|
|
extern crate hamcrest;
|
|
|
|
|
2015-10-05 22:29:15 +00:00
|
|
|
use std::fs::{self, File};
|
|
|
|
use std::io::prelude::*;
|
|
|
|
|
2015-12-17 17:53:14 +00:00
|
|
|
use cargo::util::ProcessBuilder;
|
2016-05-26 00:06:25 +00:00
|
|
|
use cargotest::install::{cargo_home, has_installed_exe};
|
|
|
|
use cargotest::support::git;
|
|
|
|
use cargotest::support::paths;
|
|
|
|
use cargotest::support::registry::Package;
|
|
|
|
use cargotest::support::{project, execs};
|
|
|
|
use hamcrest::{assert_that, is_not};
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2015-12-17 17:53:14 +00:00
|
|
|
fn cargo_process(s: &str) -> ProcessBuilder {
|
2016-05-26 00:06:25 +00:00
|
|
|
let mut p = cargotest::cargo_process();
|
2015-12-17 17:53:14 +00:00
|
|
|
p.arg(s);
|
2017-02-18 12:01:10 +00:00
|
|
|
p
|
2015-12-17 17:53:14 +00:00
|
|
|
}
|
|
|
|
|
2015-11-11 02:08:06 +00:00
|
|
|
fn pkg(name: &str, vers: &str) {
|
|
|
|
Package::new(name, vers)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("src/main.rs", &format!("
|
|
|
|
extern crate {};
|
|
|
|
fn main() {{}}
|
|
|
|
", name))
|
2016-07-05 17:28:51 +00:00
|
|
|
.publish();
|
2015-10-05 22:29:15 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn simple() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo"),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2016-05-10 23:52:02 +00:00
|
|
|
[UPDATING] registry `[..]`
|
2016-02-03 18:54:07 +00:00
|
|
|
[DOWNLOADING] foo v0.0.1 (registry [..])
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.0.1
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] foo v0.0.1
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-10 23:52:02 +00:00
|
|
|
[INSTALLING] {home}[..]bin[..]foo[..]
|
2016-05-15 22:16:54 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2015-10-05 22:29:15 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
|
|
|
|
|
|
|
assert_that(cargo_process("uninstall").arg("foo"),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2016-05-10 23:52:02 +00:00
|
|
|
[REMOVING] {home}[..]bin[..]foo[..]
|
2015-10-05 22:29:15 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
assert_that(cargo_home(), is_not(has_installed_exe("foo")));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
2017-06-23 23:30:05 +00:00
|
|
|
fn multiple_pkgs() {
|
2016-04-21 16:23:33 +00:00
|
|
|
pkg("foo", "0.0.1");
|
|
|
|
pkg("bar", "0.0.1");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo").arg("bar"),
|
2017-06-23 23:30:05 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
|
|
|
[UPDATING] registry `[..]`
|
|
|
|
[DOWNLOADING] foo v0.0.1 (registry file://[..])
|
|
|
|
[INSTALLING] foo v0.0.1
|
|
|
|
[COMPILING] foo v0.0.1
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
|
|
|
[INSTALLING] {home}[..]bin[..]foo[..]
|
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
|
|
|
[DOWNLOADING] bar v0.0.1 (registry file://[..])
|
|
|
|
[INSTALLING] bar v0.0.1
|
|
|
|
[COMPILING] bar v0.0.1
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
|
|
|
[INSTALLING] {home}[..]bin[..]bar[..]
|
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
|
|
|
|
|
|
|
|
|
|
|
SUMMARY
|
|
|
|
|
|
|
|
Successfully installed: foo, bar
|
|
|
|
|
|
|
|
Errors:
|
|
|
|
<tab>
|
2016-04-21 16:23:33 +00:00
|
|
|
",
|
|
|
|
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"),
|
2017-06-23 23:30:05 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
|
|
|
[REMOVING] {home}[..]bin[..]foo[..]
|
2016-04-21 16:23:33 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
assert_that(cargo_process("uninstall").arg("bar"),
|
2017-06-23 23:30:05 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
|
|
|
[REMOVING] {home}[..]bin[..]bar[..]
|
2016-04-21 16:23:33 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
assert_that(cargo_home(), is_not(has_installed_exe("foo")));
|
|
|
|
assert_that(cargo_home(), is_not(has_installed_exe("bar")));
|
2017-06-23 23:30:05 +00:00
|
|
|
}
|
2016-04-21 16:23:33 +00:00
|
|
|
|
2017-06-23 23:30:05 +00:00
|
|
|
#[test]
|
|
|
|
fn pick_max_version() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
|
|
|
pkg("foo", "0.0.2");
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo"),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `[..]`
|
2016-02-03 18:54:07 +00:00
|
|
|
[DOWNLOADING] foo v0.0.2 (registry [..])
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.0.2
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] foo v0.0.2
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[INSTALLING] {home}[..]bin[..]foo[..]
|
2016-05-15 22:16:54 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2015-10-05 22:29:15 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn missing() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
2015-10-05 22:29:15 +00:00
|
|
|
assert_that(cargo_process("install").arg("bar"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-15 22:16:54 +00:00
|
|
|
[UPDATING] registry [..]
|
2016-02-03 18:54:07 +00:00
|
|
|
[ERROR] could not find `bar` in `registry [..]`
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn bad_version() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
2015-10-05 22:29:15 +00:00
|
|
|
assert_that(cargo_process("install").arg("foo").arg("--vers=0.2.0"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-15 22:16:54 +00:00
|
|
|
[UPDATING] registry [..]
|
2016-11-28 17:48:14 +00:00
|
|
|
[ERROR] could not find `foo` in `registry [..]` with version `=0.2.0`
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn no_crate() {
|
2015-10-05 22:29:15 +00:00
|
|
|
assert_that(cargo_process("install"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] `[..]` is not a crate root; specify a crate to install [..]
|
2016-01-25 18:41:44 +00:00
|
|
|
|
|
|
|
Caused by:
|
2016-03-01 16:24:43 +00:00
|
|
|
failed to read `[..]Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
2016-03-01 16:25:22 +00:00
|
|
|
[..] (os error [..])
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn install_location_precedence() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
let root = paths::root();
|
|
|
|
let t1 = root.join("t1");
|
|
|
|
let t2 = root.join("t2");
|
|
|
|
let t3 = root.join("t3");
|
|
|
|
let t4 = cargo_home();
|
|
|
|
|
|
|
|
fs::create_dir(root.join(".cargo")).unwrap();
|
|
|
|
File::create(root.join(".cargo/config")).unwrap().write_all(format!("\
|
|
|
|
[install]
|
|
|
|
root = '{}'
|
|
|
|
", t3.display()).as_bytes()).unwrap();
|
|
|
|
|
|
|
|
println!("install --root");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo")
|
|
|
|
.arg("--root").arg(&t1)
|
|
|
|
.env("CARGO_INSTALL_ROOT", &t2),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(&t1, has_installed_exe("foo"));
|
|
|
|
assert_that(&t2, is_not(has_installed_exe("foo")));
|
|
|
|
|
|
|
|
println!("install CARGO_INSTALL_ROOT");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo")
|
|
|
|
.env("CARGO_INSTALL_ROOT", &t2),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(&t2, has_installed_exe("foo"));
|
|
|
|
assert_that(&t3, is_not(has_installed_exe("foo")));
|
|
|
|
|
|
|
|
println!("install install.root");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(&t3, has_installed_exe("foo"));
|
|
|
|
assert_that(&t4, is_not(has_installed_exe("foo")));
|
|
|
|
|
|
|
|
fs::remove_file(root.join(".cargo/config")).unwrap();
|
|
|
|
|
|
|
|
println!("install cargo home");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(&t4, has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn install_path() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2015-11-04 21:20:53 +00:00
|
|
|
assert_that(cargo_process("install").arg("--path").arg(".").cwd(p.root()),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.1.0 [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] binary `foo[..]` already exists in destination as part of `foo v0.1.0 [..]`
|
2016-04-15 11:20:45 +00:00
|
|
|
Add --force to overwrite
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn multiple_crates_error() {
|
2016-03-01 16:24:43 +00:00
|
|
|
let p = git::repo(&paths::root().join("foo"))
|
2015-10-05 22:29:15 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("a/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("a/src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2016-03-01 16:24:43 +00:00
|
|
|
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-15 22:16:54 +00:00
|
|
|
[UPDATING] git repository [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] multiple packages with binaries found: bar, foo
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn multiple_crates_select() {
|
2016-03-01 16:24:43 +00:00
|
|
|
let p = git::repo(&paths::root().join("foo"))
|
2015-10-05 22:29:15 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("a/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("a/src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2016-03-01 16:24:43 +00:00
|
|
|
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string())
|
|
|
|
.arg("foo"),
|
2015-10-05 22:29:15 +00:00
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
|
|
|
assert_that(cargo_home(), is_not(has_installed_exe("bar")));
|
|
|
|
|
2016-03-01 16:24:43 +00:00
|
|
|
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string())
|
|
|
|
.arg("bar"),
|
2015-10-05 22:29:15 +00:00
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("bar"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn multiple_crates_auto_binaries() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "a" }
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "extern crate bar; fn main() {}")
|
|
|
|
.file("a/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("a/src/lib.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn multiple_crates_auto_examples() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "a" }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "extern crate bar;")
|
|
|
|
.file("examples/foo.rs", "
|
|
|
|
extern crate bar;
|
|
|
|
extern crate foo;
|
|
|
|
fn main() {}
|
|
|
|
")
|
|
|
|
.file("a/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("a/src/lib.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root())
|
|
|
|
.arg("--example=foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn no_binaries_or_examples() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "a" }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("a/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("a/src/lib.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] no packages found with binaries or examples
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn no_binaries() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/foo.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("foo"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] specified package has no binaries
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn examples() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("examples/foo.rs", "extern crate foo; fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root())
|
|
|
|
.arg("--example=foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn install_twice() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
2016-04-15 11:20:45 +00:00
|
|
|
.file("src/bin/foo-bin1.rs", "fn main() {}")
|
|
|
|
.file("src/bin/foo-bin2.rs", "fn main() {}");
|
2015-10-05 22:29:15 +00:00
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.1.0 [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] binary `foo-bin1[..]` already exists in destination as part of `foo v0.1.0 ([..])`
|
2016-04-15 11:20:45 +00:00
|
|
|
binary `foo-bin2[..]` already exists in destination as part of `foo v0.1.0 ([..])`
|
|
|
|
Add --force to overwrite
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn install_force() {
|
2016-04-15 11:20:45 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
|
|
|
let p = project("foo2")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--force").arg("--path").arg(p.root()),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.2.0 ([..])
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.2.0 ([..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[REPLACING] {home}[..]bin[..]foo[..]
|
2016-05-15 22:16:54 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2016-04-15 11:20:45 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--list"),
|
|
|
|
execs().with_status(0).with_stdout("\
|
|
|
|
foo v0.2.0 ([..]):
|
|
|
|
foo[..]
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-04-15 11:20:45 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn install_force_partial_overlap() {
|
2016-04-15 11:20:45 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/bin/foo-bin1.rs", "fn main() {}")
|
|
|
|
.file("src/bin/foo-bin2.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
|
|
|
let p = project("foo2")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/bin/foo-bin2.rs", "fn main() {}")
|
|
|
|
.file("src/bin/foo-bin3.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--force").arg("--path").arg(p.root()),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.2.0 ([..])
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.2.0 ([..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[INSTALLING] {home}[..]bin[..]foo-bin3[..]
|
|
|
|
[REPLACING] {home}[..]bin[..]foo-bin2[..]
|
2016-05-15 22:16:54 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2016-04-15 11:20:45 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--list"),
|
|
|
|
execs().with_status(0).with_stdout("\
|
|
|
|
foo v0.1.0 ([..]):
|
|
|
|
foo-bin1[..]
|
|
|
|
foo v0.2.0 ([..]):
|
|
|
|
foo-bin2[..]
|
|
|
|
foo-bin3[..]
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-04-15 11:20:45 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn install_force_bin() {
|
2016-04-15 11:20:45 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/bin/foo-bin1.rs", "fn main() {}")
|
|
|
|
.file("src/bin/foo-bin2.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
|
|
|
let p = project("foo2")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/bin/foo-bin1.rs", "fn main() {}")
|
|
|
|
.file("src/bin/foo-bin2.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--force")
|
|
|
|
.arg("--bin")
|
|
|
|
.arg("foo-bin2")
|
|
|
|
.arg("--path")
|
|
|
|
.arg(p.root()),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.2.0 ([..])
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.2.0 ([..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[REPLACING] {home}[..]bin[..]foo-bin2[..]
|
2016-05-15 22:16:54 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2016-04-15 11:20:45 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--list"),
|
|
|
|
execs().with_status(0).with_stdout("\
|
|
|
|
foo v0.1.0 ([..]):
|
|
|
|
foo-bin1[..]
|
|
|
|
foo v0.2.0 ([..]):
|
|
|
|
foo-bin2[..]
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-04-15 11:20:45 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn compile_failure() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
2016-05-25 17:04:39 +00:00
|
|
|
execs().with_status(101).with_stderr_contains("\
|
2016-02-03 18:54:07 +00:00
|
|
|
[ERROR] failed to compile `foo v0.1.0 ([..])`, intermediate artifacts can be \
|
2016-02-20 09:18:29 +00:00
|
|
|
found at `[..]target`
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Could not compile `foo`.
|
|
|
|
|
|
|
|
To learn more, run the command again with --verbose.
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn git_repo() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = git::repo(&paths::root().join("foo"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2016-08-19 18:00:21 +00:00
|
|
|
// use `--locked` to test that we don't even try to write a lockfile
|
|
|
|
assert_that(cargo_process("install").arg("--locked").arg("--git").arg(p.url().to_string()),
|
2016-05-14 21:44:18 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
2017-01-24 06:49:50 +00:00
|
|
|
[INSTALLING] foo v0.1.0 ([..])
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.1.0 ([..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[INSTALLING] {home}[..]bin[..]foo[..]
|
2016-05-15 22:16:54 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2015-10-05 22:29:15 +00:00
|
|
|
",
|
|
|
|
home = cargo_home().display())));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn list() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
|
|
|
pkg("bar", "0.2.1");
|
|
|
|
pkg("bar", "0.2.2");
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--list"),
|
|
|
|
execs().with_status(0).with_stdout(""));
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("bar").arg("--vers").arg("=0.2.1"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("install").arg("foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("install").arg("--list"),
|
|
|
|
execs().with_status(0).with_stdout("\
|
2016-02-03 18:54:07 +00:00
|
|
|
bar v0.2.1:
|
2015-10-05 22:29:15 +00:00
|
|
|
bar[..]
|
2016-02-03 18:54:07 +00:00
|
|
|
foo v0.0.1:
|
2015-10-05 22:29:15 +00:00
|
|
|
foo[..]
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn uninstall_pkg_does_not_exist() {
|
2015-10-05 22:29:15 +00:00
|
|
|
assert_that(cargo_process("uninstall").arg("foo"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] package id specification `foo` matched no packages
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn uninstall_bin_does_not_exist() {
|
2015-11-11 02:08:06 +00:00
|
|
|
pkg("foo", "0.0.1");
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("uninstall").arg("foo").arg("--bin=bar"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-02-03 18:54:07 +00:00
|
|
|
[ERROR] binary `bar[..]` not installed as part of `foo v0.0.1`
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-10-05 22:29:15 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn uninstall_piecemeal() {
|
2015-10-05 22:29:15 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/bin/foo.rs", "fn main() {}")
|
|
|
|
.file("src/bin/bar.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("bar"));
|
|
|
|
|
|
|
|
assert_that(cargo_process("uninstall").arg("foo").arg("--bin=bar"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-12 15:23:53 +00:00
|
|
|
[REMOVING] [..]bar[..]
|
|
|
|
"));
|
2015-10-05 22:29:15 +00:00
|
|
|
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
|
|
|
assert_that(cargo_home(), is_not(has_installed_exe("bar")));
|
|
|
|
|
|
|
|
assert_that(cargo_process("uninstall").arg("foo").arg("--bin=foo"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-12 15:23:53 +00:00
|
|
|
[REMOVING] [..]foo[..]
|
|
|
|
"));
|
2015-10-05 22:29:15 +00:00
|
|
|
assert_that(cargo_home(), is_not(has_installed_exe("foo")));
|
|
|
|
|
|
|
|
assert_that(cargo_process("uninstall").arg("foo"),
|
2016-05-12 17:06:36 +00:00
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[ERROR] package id specification `foo` matched no packages
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-12-03 23:32:30 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn subcommand_works_out_of_the_box() {
|
2015-12-03 23:32:30 +00:00
|
|
|
Package::new("cargo-foo", "1.0.0")
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {
|
|
|
|
println!("bar");
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.publish();
|
|
|
|
assert_that(cargo_process("install").arg("cargo-foo"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("foo"),
|
|
|
|
execs().with_status(0).with_stdout("bar\n"));
|
|
|
|
assert_that(cargo_process("--list"),
|
2016-03-03 18:18:02 +00:00
|
|
|
execs().with_status(0).with_stdout_contains(" foo\n"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-12-17 16:41:05 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn installs_from_cwd_by_default() {
|
2015-12-17 16:41:05 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
2016-03-01 16:24:43 +00:00
|
|
|
assert_that(cargo_process("install").cwd(p.root()),
|
|
|
|
execs().with_status(0));
|
2015-12-17 16:41:05 +00:00
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-20 09:18:29 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn do_not_rebuilds_on_local_install() {
|
2016-02-20 09:18:29 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build").arg("--release"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("install").arg("--path").arg(p.root()),
|
2017-01-24 06:49:50 +00:00
|
|
|
execs().with_status(0).with_stderr("[INSTALLING] [..]
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
2016-05-12 15:23:53 +00:00
|
|
|
[INSTALLING] [..]
|
2016-03-13 22:24:55 +00:00
|
|
|
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
|
2016-02-20 09:18:29 +00:00
|
|
|
"));
|
|
|
|
|
2016-05-26 00:06:25 +00:00
|
|
|
assert!(p.build_dir().exists());
|
|
|
|
assert!(p.release_bin("foo").exists());
|
2016-02-20 09:18:29 +00:00
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-23 17:44:54 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn reports_unsuccessful_subcommand_result() {
|
2016-02-23 17:44:54 +00:00
|
|
|
Package::new("cargo-fail", "1.0.0")
|
|
|
|
.file("src/main.rs", r#"
|
|
|
|
fn main() {
|
|
|
|
panic!();
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.publish();
|
|
|
|
assert_that(cargo_process("install").arg("cargo-fail"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_process("--list"),
|
2016-03-03 18:18:02 +00:00
|
|
|
execs().with_status(0).with_stdout_contains(" fail\n"));
|
2016-02-23 17:44:54 +00:00
|
|
|
assert_that(cargo_process("fail"),
|
|
|
|
execs().with_status(101).with_stderr_contains("\
|
2016-05-31 11:43:44 +00:00
|
|
|
thread '[..]' panicked at 'explicit panic', [..]
|
2016-05-11 23:27:47 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-03-11 20:18:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn git_with_lockfile() {
|
2016-03-11 20:18:17 +00:00
|
|
|
let p = git::repo(&paths::root().join("foo"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("bar/src/lib.rs", "fn main() {}")
|
|
|
|
.file("Cargo.lock", r#"
|
|
|
|
[root]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
2016-08-25 10:10:45 +00:00
|
|
|
dependencies = [ "bar 0.1.0" ]
|
2016-03-11 20:18:17 +00:00
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
"#);
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
|
|
|
|
execs().with_status(0));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-04-14 17:25:25 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn q_silences_warnings() {
|
2016-04-14 17:25:25 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("-q").arg("--path").arg(p.root()),
|
|
|
|
execs().with_status(0).with_stderr(""));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-04-23 03:33:58 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn readonly_dir() {
|
2016-04-23 03:33:58 +00:00
|
|
|
pkg("foo", "0.0.1");
|
|
|
|
|
|
|
|
let root = paths::root();
|
|
|
|
let dir = &root.join("readonly");
|
|
|
|
fs::create_dir(root.join("readonly")).unwrap();
|
|
|
|
let mut perms = fs::metadata(dir).unwrap().permissions();
|
|
|
|
perms.set_readonly(true);
|
|
|
|
fs::set_permissions(dir, perms).unwrap();
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo").cwd(dir),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(cargo_home(), has_installed_exe("foo"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-09-30 20:16:38 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn use_path_workspace() {
|
|
|
|
Package::new("foo", "1.0.0").publish();
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
members = ["baz"]
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("baz/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "baz"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "1"
|
|
|
|
"#)
|
|
|
|
.file("baz/src/lib.rs", "");
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
let lock = p.read_lockfile();
|
|
|
|
assert_that(p.cargo("install"), execs().with_status(0));
|
|
|
|
let lock2 = p.read_lockfile();
|
|
|
|
assert!(lock == lock2, "different lockfiles");
|
|
|
|
}
|
2016-11-28 17:48:14 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn vers_precise() {
|
|
|
|
pkg("foo", "0.1.1");
|
|
|
|
pkg("foo", "0.1.2");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo").arg("--vers").arg("0.1.1"),
|
|
|
|
execs().with_status(0).with_stderr_contains("\
|
|
|
|
[DOWNLOADING] foo v0.1.1 (registry [..])
|
|
|
|
"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn legacy_version_requirement() {
|
|
|
|
pkg("foo", "0.1.1");
|
|
|
|
|
|
|
|
assert_that(cargo_process("install").arg("foo").arg("--vers").arg("0.1"),
|
|
|
|
execs().with_status(0).with_stderr_contains("\
|
|
|
|
warning: the `--vers` provided, `0.1`, is not a valid semver version
|
|
|
|
|
|
|
|
historically Cargo treated this as a semver version requirement accidentally
|
|
|
|
and will continue to do so, but this behavior will be removed eventually
|
|
|
|
"));
|
|
|
|
}
|