2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for renaming dependencies.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::git;
|
|
|
|
use cargo_test_support::paths;
|
2021-01-28 19:54:27 +00:00
|
|
|
use cargo_test_support::registry::{self, Package};
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::{basic_manifest, project};
|
2018-01-17 19:33:25 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-01-17 19:33:25 +00:00
|
|
|
fn rename_dependency() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
Package::new("bar", "0.2.0").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1.0" }
|
|
|
|
baz = { version = "0.2.0", package = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate bar; extern crate baz;")
|
2018-01-17 19:33:25 +00:00
|
|
|
.build();
|
|
|
|
|
2018-11-13 19:37:49 +00:00
|
|
|
p.cargo("build").run();
|
2018-01-17 19:33:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-01-17 19:33:25 +00:00
|
|
|
fn rename_with_different_names() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-01-17 19:33:25 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = { path = "bar", package = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate baz;")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-01-17 19:33:25 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
name = "random_name"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/lib.rs", "")
|
2018-01-17 19:33:25 +00:00
|
|
|
.build();
|
|
|
|
|
2018-11-13 19:37:49 +00:00
|
|
|
p.cargo("build").run();
|
2018-01-17 19:33:25 +00:00
|
|
|
}
|
2018-04-25 17:41:33 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-25 17:41:33 +00:00
|
|
|
fn lots_of_names() {
|
2021-01-28 19:54:27 +00:00
|
|
|
registry::alt_init();
|
2018-04-25 17:41:33 +00:00
|
|
|
Package::new("foo", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub fn foo1() {}")
|
|
|
|
.publish();
|
|
|
|
Package::new("foo", "0.2.0")
|
|
|
|
.file("src/lib.rs", "pub fn foo() {}")
|
|
|
|
.publish();
|
|
|
|
Package::new("foo", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub fn foo2() {}")
|
|
|
|
.alternative(true)
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let g = git::repo(&paths::root().join("another"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2018-04-25 17:41:33 +00:00
|
|
|
.file("src/lib.rs", "pub fn foo3() {}")
|
|
|
|
.build();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-25 17:41:33 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
2018-08-28 09:20:03 +00:00
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = "0.2"
|
|
|
|
foo1 = {{ version = "0.1", package = "foo" }}
|
|
|
|
foo2 = {{ version = "0.1", registry = "alternative", package = "foo" }}
|
|
|
|
foo3 = {{ git = '{}', package = "foo" }}
|
|
|
|
foo4 = {{ path = "foo", package = "foo" }}
|
|
|
|
"#,
|
2018-08-28 09:20:03 +00:00
|
|
|
g.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-04-25 17:41:33 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate foo;
|
|
|
|
extern crate foo1;
|
|
|
|
extern crate foo2;
|
|
|
|
extern crate foo3;
|
|
|
|
extern crate foo4;
|
|
|
|
|
|
|
|
pub fn foo() {
|
|
|
|
foo::foo();
|
|
|
|
foo1::foo1();
|
|
|
|
foo2::foo2();
|
|
|
|
foo3::foo3();
|
|
|
|
foo4::foo4();
|
|
|
|
}
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2018-04-25 17:41:33 +00:00
|
|
|
.file("foo/src/lib.rs", "pub fn foo4() {}")
|
|
|
|
.build();
|
|
|
|
|
2019-05-09 17:58:18 +00:00
|
|
|
p.cargo("build -v").run();
|
2018-04-25 17:41:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-25 17:41:33 +00:00
|
|
|
fn rename_and_patch() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-25 17:41:33 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1", package = "foo" }
|
|
|
|
|
|
|
|
[patch.crates-io]
|
|
|
|
foo = { path = "foo" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::foo(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0"))
|
2018-04-25 17:41:33 +00:00
|
|
|
.file("foo/src/lib.rs", "pub fn foo() {}")
|
|
|
|
.build();
|
|
|
|
|
2018-11-13 19:37:49 +00:00
|
|
|
p.cargo("build -v").run();
|
2018-04-25 17:41:33 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-25 17:41:33 +00:00
|
|
|
fn rename_twice() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-25 17:41:33 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1", package = "foo" }
|
|
|
|
[build-dependencies]
|
|
|
|
foo = { version = "0.1" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-04-25 17:41:33 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` index
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] foo v0.1.0 (registry [..])
|
2019-01-27 17:53:13 +00:00
|
|
|
error: the crate `test v0.1.0 ([CWD])` depends on crate `foo v0.1.0` multiple times with different names
|
2018-08-28 09:20:03 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-25 17:41:33 +00:00
|
|
|
}
|
2018-04-28 10:35:49 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-28 10:35:49 +00:00
|
|
|
fn rename_affects_fingerprint() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-28 10:35:49 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = { version = "0.1", package = "foo" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate foo;")
|
2018-04-28 10:35:49 +00:00
|
|
|
.build();
|
|
|
|
|
2018-11-13 19:37:49 +00:00
|
|
|
p.cargo("build -v").run();
|
2018-04-28 10:35:49 +00:00
|
|
|
|
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1", package = "foo" }
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
2018-12-29 01:47:50 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains("[..]can't find crate for `foo`")
|
|
|
|
.run();
|
2018-04-28 10:35:49 +00:00
|
|
|
}
|
2018-07-25 16:58:28 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-07-25 16:58:28 +00:00
|
|
|
fn can_run_doc_tests() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
Package::new("bar", "0.2.0").publish();
|
|
|
|
|
|
|
|
let foo = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2018-07-25 16:58:28 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1.0" }
|
|
|
|
baz = { version = "0.2.0", package = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-07-25 16:58:28 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate bar;
|
|
|
|
extern crate baz;
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-07-25 16:58:28 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
foo.cargo("test -v")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr_contains(
|
2018-07-25 16:58:28 +00:00
|
|
|
"\
|
|
|
|
[DOCTEST] foo
|
2021-02-22 19:06:03 +00:00
|
|
|
[RUNNING] `rustdoc [..]--test [..]src/lib.rs \
|
2018-07-25 16:58:28 +00:00
|
|
|
[..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
--extern bar=[CWD]/target/debug/deps/libbar-[..].rlib \
|
2018-11-04 18:38:51 +00:00
|
|
|
--extern baz=[CWD]/target/debug/deps/libbar-[..].rlib \
|
2018-07-25 16:58:28 +00:00
|
|
|
[..]`
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-07-25 16:58:28 +00:00
|
|
|
}
|
2018-07-26 19:56:32 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-07-26 19:56:32 +00:00
|
|
|
fn features_still_work() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
p1 = { path = 'a', features = ['b'] }
|
|
|
|
p2 = { path = 'b' }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-26 19:56:32 +00:00
|
|
|
.file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "p1"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
b = { version = "0.1", package = "foo", optional = true }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("a/src/lib.rs", "extern crate b;")
|
2018-07-26 19:56:32 +00:00
|
|
|
.file(
|
|
|
|
"b/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "p2"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
b = { version = "0.1", package = "bar", optional = true }
|
|
|
|
|
|
|
|
[features]
|
|
|
|
default = ['b']
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("b/src/lib.rs", "extern crate b;")
|
2018-07-26 19:56:32 +00:00
|
|
|
.build();
|
|
|
|
|
2018-11-13 19:37:49 +00:00
|
|
|
p.cargo("build -v").run();
|
2018-07-26 19:56:32 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-07-26 19:56:32 +00:00
|
|
|
fn features_not_working() {
|
|
|
|
Package::new("foo", "0.1.0").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
a = { path = 'a', package = 'p1', optional = true }
|
|
|
|
|
|
|
|
[features]
|
|
|
|
default = ['p1']
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-07-26 19:56:32 +00:00
|
|
|
.file("a/Cargo.toml", &basic_manifest("p1", "0.1.0"))
|
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2018-07-26 19:56:32 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2020-10-20 18:15:48 +00:00
|
|
|
feature `default` includes `p1` which is neither a dependency nor another feature
|
2018-08-28 09:20:03 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-07-26 19:56:32 +00:00
|
|
|
}
|
2018-10-05 21:05:24 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-10-05 21:05:24 +00:00
|
|
|
fn rename_with_dash() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "qwerty"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo-bar = { path = 'a', package = 'a' }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate foo_bar;")
|
|
|
|
.file("a/Cargo.toml", &basic_manifest("a", "0.1.0"))
|
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2018-12-08 11:19:47 +00:00
|
|
|
p.cargo("build").run();
|
2018-10-05 21:05:24 +00:00
|
|
|
}
|