2016-05-26 00:06:25 +00:00
|
|
|
extern crate cargotest;
|
|
|
|
extern crate hamcrest;
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-26 00:06:25 +00:00
|
|
|
use cargotest::support::git;
|
|
|
|
use cargotest::support::paths;
|
2016-02-03 18:54:07 +00:00
|
|
|
use cargotest::support::registry::Package;
|
2016-05-26 00:06:25 +00:00
|
|
|
use cargotest::support::{execs, project};
|
|
|
|
use hamcrest::assert_that;
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn override_simple() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
pub fn bar() {
|
|
|
|
foo::foo();
|
|
|
|
}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
|
|
|
[UPDATING] git repository `[..]`
|
|
|
|
[COMPILING] foo v0.1.0 (file://[..])
|
|
|
|
[COMPILING] local v0.0.1 (file://[..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn missing_version() {
|
2016-02-09 23:42:17 +00:00
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
foo = { git = 'https://example.com' }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2016-11-02 17:32:35 +00:00
|
|
|
replacements must specify a version to replace, but `[..]foo` does not
|
2016-02-09 23:42:17 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-09-30 11:27:10 +00:00
|
|
|
#[test]
|
|
|
|
fn invalid_semver_version() {
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "*"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:*" = { git = 'https://example.com' }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-10-03 08:55:05 +00:00
|
|
|
execs().with_status(101).with_stderr_contains("\
|
2016-09-30 11:27:10 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
replacements must specify a valid semver version to replace, but `foo:*` does not
|
|
|
|
"));
|
|
|
|
}
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn different_version() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.2.0").publish();
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = "0.2.0"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
replacements cannot specify a version requirement, but found one for [..]
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn transitive() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
Package::new("bar", "0.2.0")
|
|
|
|
.dep("foo", "0.1.0")
|
|
|
|
.file("src/lib.rs", "extern crate foo; fn bar() { foo::foo(); }")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.2.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
|
|
|
[UPDATING] git repository `[..]`
|
2016-05-12 15:23:53 +00:00
|
|
|
[DOWNLOADING] bar v0.2.0 (registry [..])
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.1.0 (file://[..])
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] bar v0.2.0
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] local v0.0.1 (file://[..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn persists_across_rebuilds() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
pub fn bar() {
|
|
|
|
foo::foo();
|
|
|
|
}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
|
|
|
[UPDATING] git repository `file://[..]`
|
|
|
|
[COMPILING] foo v0.1.0 (file://[..])
|
|
|
|
[COMPILING] local v0.0.1 (file://[..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
assert_that(p.cargo("build"),
|
|
|
|
execs().with_status(0).with_stdout(""));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn replace_registry_with_path() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = { path = "../foo" }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
pub fn bar() {
|
|
|
|
foo::foo();
|
|
|
|
}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
|
|
|
[COMPILING] foo v0.1.0 (file://[..])
|
|
|
|
[COMPILING] local v0.0.1 (file://[..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn use_a_spec_to_select() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.1")
|
|
|
|
.file("src/lib.rs", "pub fn foo1() {}")
|
|
|
|
.publish();
|
|
|
|
Package::new("foo", "0.2.0").publish();
|
|
|
|
Package::new("bar", "0.1.1")
|
|
|
|
.dep("foo", "0.2")
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
pub fn bar() { foo::foo3(); }
|
|
|
|
")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo3() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
|
|
|
foo = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.2.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate foo;
|
|
|
|
extern crate bar;
|
|
|
|
|
2016-05-20 11:47:39 +00:00
|
|
|
pub fn local() {
|
2016-02-09 23:42:17 +00:00
|
|
|
foo::foo1();
|
|
|
|
bar::bar();
|
|
|
|
}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
|
|
|
[UPDATING] git repository `[..]`
|
2016-05-12 15:23:53 +00:00
|
|
|
[DOWNLOADING] [..]
|
|
|
|
[DOWNLOADING] [..]
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] [..]
|
|
|
|
[COMPILING] [..]
|
|
|
|
[COMPILING] [..]
|
|
|
|
[COMPILING] local v0.0.1 (file://[..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn override_adds_some_deps() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.1").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
|
|
|
[UPDATING] git repository `[..]`
|
2016-05-12 15:23:53 +00:00
|
|
|
[DOWNLOADING] foo v0.1.1 (registry [..])
|
2016-02-03 18:54:07 +00:00
|
|
|
[COMPILING] foo v0.1.1
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] bar v0.1.0 ([..])
|
|
|
|
[COMPILING] local v0.0.1 (file://[..])
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
|
|
|
|
|
|
|
|
Package::new("foo", "0.1.2").publish();
|
|
|
|
assert_that(p.cargo("update").arg("-p").arg(&format!("{}#bar", foo.url())),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] git repository `file://[..]`
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-02-03 18:54:07 +00:00
|
|
|
assert_that(p.cargo("update")
|
|
|
|
.arg("-p")
|
|
|
|
.arg("https://github.com/rust-lang/crates.io-index#bar"),
|
2016-05-14 21:15:22 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] registry `file://[..]`
|
2016-05-12 17:06:36 +00:00
|
|
|
"));
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn locked_means_locked_yes_no_seriously_i_mean_locked() {
|
2016-02-09 23:42:17 +00:00
|
|
|
// this in theory exercises #2041
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
Package::new("foo", "0.2.0").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "*"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1"
|
|
|
|
bar = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn override_wrong_name() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-20 11:47:39 +00:00
|
|
|
[UPDATING] registry [..]
|
|
|
|
[UPDATING] git repository [..]
|
2016-11-02 17:32:35 +00:00
|
|
|
error: no matching package for override `[..]foo:0.1.0` found
|
2016-02-09 23:42:17 +00:00
|
|
|
location searched: file://[..]
|
|
|
|
version required: = 0.1.0
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn override_with_nothing() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-20 11:47:39 +00:00
|
|
|
[UPDATING] registry [..]
|
|
|
|
[UPDATING] git repository [..]
|
2016-06-28 17:39:46 +00:00
|
|
|
[ERROR] failed to load source for a dependency on `foo`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Unable to update file://[..]
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Could not find Cargo.toml in `[..]`
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn override_wrong_version() {
|
2016-02-09 23:42:17 +00:00
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = { git = 'https://example.com', version = '0.2.0' }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2016-11-02 17:32:35 +00:00
|
|
|
replacements cannot specify a version requirement, but found one for `[..]foo:0.1.0`
|
2016-02-09 23:42:17 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn multiple_specs() {
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{0}' }}
|
2016-02-03 18:54:07 +00:00
|
|
|
|
|
|
|
[replace."https://github.com/rust-lang/crates.io-index#foo:0.1.0"]
|
|
|
|
git = '{0}'
|
|
|
|
"#, foo.url()))
|
2016-02-09 23:42:17 +00:00
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(101).with_stderr("\
|
2016-05-20 11:47:39 +00:00
|
|
|
[UPDATING] registry [..]
|
|
|
|
[UPDATING] git repository [..]
|
2016-02-09 23:42:17 +00:00
|
|
|
error: overlapping replacement specifications found:
|
|
|
|
|
|
|
|
* [..]
|
|
|
|
* [..]
|
|
|
|
|
2016-02-03 18:54:07 +00:00
|
|
|
both specifications match: foo v0.1.0
|
2016-02-09 23:42:17 +00:00
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn test_override_dep() {
|
2016-05-20 21:25:43 +00:00
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{0}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("test").arg("-p").arg("foo"),
|
|
|
|
execs().with_status(101)
|
|
|
|
.with_stderr_contains("\
|
|
|
|
error: There are multiple `foo` packages in your project, and the [..]
|
|
|
|
Please re-run this command with [..]
|
|
|
|
[..]#foo:0.1.0
|
|
|
|
[..]#foo:0.1.0
|
|
|
|
"));
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-06-05 07:19:55 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn update() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{0}' }}
|
|
|
|
"#, foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("generate-lockfile"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(p.cargo("update"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stderr("\
|
|
|
|
[UPDATING] registry `[..]`
|
|
|
|
[UPDATING] git repository `[..]`
|
|
|
|
"));
|
|
|
|
}
|
2016-07-14 08:44:31 +00:00
|
|
|
|
|
|
|
// local -> near -> far
|
|
|
|
// near is overridden with itself
|
|
|
|
#[test]
|
|
|
|
fn no_override_self() {
|
|
|
|
let deps = git::repo(&paths::root().join("override"))
|
|
|
|
|
|
|
|
.file("far/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "far"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("far/src/lib.rs", "")
|
|
|
|
|
|
|
|
.file("near/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "near"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
far = { path = "../far" }
|
|
|
|
"#)
|
|
|
|
.file("near/src/lib.rs", r#"
|
|
|
|
#![no_std]
|
|
|
|
pub extern crate far;
|
|
|
|
"#);
|
|
|
|
|
|
|
|
deps.build();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
near = {{ git = '{0}' }}
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"near:0.1.0" = {{ git = '{0}' }}
|
|
|
|
"#, deps.url()))
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
#![no_std]
|
|
|
|
pub extern crate near;
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build").arg("--verbose"),
|
|
|
|
execs().with_status(0));
|
|
|
|
}
|
2016-09-29 23:35:22 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn broken_path_override_warns() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
Package::new("foo", "0.2.0").publish();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
a = { path = "a1" }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("a1/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1"
|
|
|
|
"#)
|
|
|
|
.file("a1/src/lib.rs", "")
|
|
|
|
.file("a2/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "a"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.2"
|
|
|
|
"#)
|
|
|
|
.file("a2/src/lib.rs", "")
|
|
|
|
.file(".cargo/config", r#"
|
|
|
|
paths = ["a2"]
|
|
|
|
"#);
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0)
|
|
|
|
.with_stderr("\
|
|
|
|
[UPDATING] [..]
|
|
|
|
warning: path override for crate `a` has altered the original list of
|
|
|
|
dependencies; the dependency on `foo` was either added or
|
|
|
|
modified to not match the previously resolved version
|
|
|
|
|
|
|
|
This is currently allowed but is known to produce buggy behavior with spurious
|
|
|
|
recompiles and changes to the crate graph. Path overrides unfortunately were
|
|
|
|
never intended to support this feature, so for now this message is just a
|
|
|
|
warning. In the future, however, this message will become a hard error.
|
|
|
|
|
|
|
|
To change the dependency graph via an override it's recommended to use the
|
|
|
|
`[replace]` feature of Cargo instead of the path override feature. This is
|
|
|
|
documented online at the url below for more information.
|
|
|
|
|
|
|
|
http://doc.crates.io/specifying-dependencies.html#overriding-dependencies
|
|
|
|
|
|
|
|
[DOWNLOADING] [..]
|
|
|
|
[COMPILING] [..]
|
|
|
|
[COMPILING] [..]
|
|
|
|
[COMPILING] [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
"));
|
|
|
|
}
|
2016-10-21 02:02:38 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn override_an_override() {
|
|
|
|
Package::new("chrono", "0.2.0").dep("serde", "< 0.9").publish();
|
|
|
|
Package::new("serde", "0.7.0")
|
|
|
|
.file("src/lib.rs", "pub fn serde07() {}")
|
|
|
|
.publish();
|
|
|
|
Package::new("serde", "0.8.0")
|
|
|
|
.file("src/lib.rs", "pub fn serde08() {}")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
chrono = "0.2"
|
|
|
|
serde = "0.8"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"chrono:0.2.0" = { path = "chrono" }
|
|
|
|
"serde:0.8.0" = { path = "serde" }
|
|
|
|
"#)
|
|
|
|
.file("Cargo.lock", r#"
|
|
|
|
[root]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
dependencies = [
|
|
|
|
"chrono 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
"serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
]
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "chrono"
|
|
|
|
version = "0.2.0"
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
replace = "chrono 0.2.0"
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "chrono"
|
|
|
|
version = "0.2.0"
|
|
|
|
dependencies = [
|
|
|
|
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
|
|
]
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "serde"
|
|
|
|
version = "0.7.0"
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "serde"
|
|
|
|
version = "0.8.0"
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
|
replace = "serde 0.8.0"
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
name = "serde"
|
|
|
|
version = "0.8.0"
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "
|
|
|
|
extern crate chrono;
|
|
|
|
extern crate serde;
|
|
|
|
|
|
|
|
pub fn local() {
|
|
|
|
chrono::chrono();
|
|
|
|
serde::serde08_override();
|
|
|
|
}
|
|
|
|
")
|
|
|
|
.file("chrono/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "chrono"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
serde = "< 0.9"
|
|
|
|
"#)
|
|
|
|
.file("chrono/src/lib.rs", "
|
|
|
|
extern crate serde;
|
|
|
|
pub fn chrono() {
|
|
|
|
serde::serde07();
|
|
|
|
}
|
|
|
|
")
|
|
|
|
.file("serde/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "serde"
|
|
|
|
version = "0.8.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("serde/src/lib.rs", "
|
|
|
|
pub fn serde08_override() {}
|
|
|
|
");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build").arg("-v"),
|
|
|
|
execs().with_status(0));
|
|
|
|
}
|
2016-11-02 17:32:35 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn overriding_nonexistent_no_spurious() {
|
|
|
|
Package::new("foo", "0.1.0").dep("bar", "0.1").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("bar/src/lib.rs", "pub fn foo() {}");
|
|
|
|
foo.build();
|
|
|
|
|
|
|
|
|
|
|
|
let p = project("local")
|
|
|
|
.file("Cargo.toml", &format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "local"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"foo:0.1.0" = {{ git = '{url}' }}
|
|
|
|
"bar:0.1.0" = {{ git = '{url}' }}
|
|
|
|
"#, url = foo.url()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("build"),
|
|
|
|
execs().with_status(0));
|
|
|
|
assert_that(p.cargo("build"),
|
|
|
|
execs().with_status(0).with_stderr("\
|
|
|
|
[FINISHED] [..]
|
|
|
|
").with_stdout(""));
|
|
|
|
}
|