2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for `[replace]` table source replacement.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::git;
|
|
|
|
use cargo_test_support::paths;
|
|
|
|
use cargo_test_support::registry::Package;
|
|
|
|
use cargo_test_support::{basic_manifest, project};
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn override_simple() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-07-20 17:41:44 +00:00
|
|
|
bar.url()
|
2018-03-14 15:17:44 +00:00
|
|
|
),
|
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::bar(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 (file://[..])
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2021-07-12 06:56:24 +00:00
|
|
|
fn override_with_features() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}', features = ["some_feature"] }}
|
|
|
|
"#,
|
|
|
|
bar.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2021-07-12 06:56:24 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..] index
|
2021-07-23 07:00:50 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
|
|
|
[WARNING] replacement for `bar` uses the features mechanism. default-features and features \
|
|
|
|
will not take effect because the replacement dependency does not support this mechanism
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 (file://[..])
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2021-07-23 07:00:50 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn override_with_setting_default_features() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}', default-features = false, features = ["none_default_feature"] }}
|
|
|
|
"#,
|
|
|
|
bar.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
|
|
|
)
|
|
|
|
.build();
|
2021-07-12 06:56:24 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2021-07-23 07:00:50 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] [..] index
|
|
|
|
[UPDATING] git repository `[..]`
|
|
|
|
[WARNING] replacement for `bar` uses the features mechanism. default-features and features \
|
|
|
|
will not take effect because the replacement dependency does not support this mechanism
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 (file://[..])
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2021-07-23 07:00:50 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn missing_version() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
bar = { git = 'https://example.com' }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-09 23:42:17 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2018-07-20 17:41:44 +00:00
|
|
|
replacements must specify a version to replace, but `[..]bar` does not
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-09-30 11:27:10 +00:00
|
|
|
fn invalid_semver_version() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-09-30 11:27:10 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "*"
|
2016-09-30 11:27:10 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:*" = { git = 'https://example.com' }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-09-30 11:27:10 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-09-30 11:27:10 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2018-07-20 17:41:44 +00:00
|
|
|
replacements must specify a valid semver version to replace, but `bar:*` does not
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-09-30 11:27:10 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn different_version() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.2.0").publish();
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = "0.2.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-09 23:42:17 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
replacements cannot specify a version requirement, but found one for [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn transitive() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
Package::new("baz", "0.2.0")
|
|
|
|
.dep("bar", "0.1.0")
|
|
|
|
.file("src/lib.rs", "extern crate bar; fn baz() { bar::bar(); }")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = "0.2.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] baz v0.2.0 (registry [..])
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 (file://[..])
|
|
|
|
[CHECKING] baz v0.2.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-11-15 22:33:27 +00:00
|
|
|
p.cargo("check").with_stderr("[FINISHED] [..]").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn persists_across_rebuilds() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
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::bar(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2018-09-09 23:59:48 +00:00
|
|
|
[UPDATING] git repository `file://[..]`
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 (file://[..])
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-11-15 22:33:27 +00:00
|
|
|
p.cargo("check").with_stderr("[FINISHED] [..]").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn replace_registry_with_path() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
let _ = project()
|
|
|
|
.at("bar")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2016-02-09 23:42:17 +00:00
|
|
|
.build();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = { path = "../bar" }
|
|
|
|
"#,
|
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::bar(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 ([ROOT][..]/bar)
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn use_a_spec_to_select() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.1")
|
|
|
|
.file("src/lib.rs", "pub fn baz1() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.publish();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.2.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("bar", "0.1.1")
|
2018-07-20 17:41:44 +00:00
|
|
|
.dep("baz", "0.2")
|
2018-08-28 09:20:03 +00:00
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate baz; pub fn bar() { baz::baz3(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("baz", "0.2.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn baz3() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
|
|
|
baz = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"baz:0.2.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"
|
2016-02-09 23:42:17 +00:00
|
|
|
extern crate bar;
|
2018-07-20 17:41:44 +00:00
|
|
|
extern crate baz;
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2016-05-20 11:47:39 +00:00
|
|
|
pub fn local() {
|
2018-07-20 17:41:44 +00:00
|
|
|
baz::baz1();
|
2016-02-09 23:42:17 +00:00
|
|
|
bar::bar();
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] [..]
|
|
|
|
[DOWNLOADED] [..]
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] [..]
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn override_adds_some_deps() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.1").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = "0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2016-05-11 16:55:43 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
2018-09-14 20:33:18 +00:00
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] baz v0.1.1 (registry [..])
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] baz v0.1.1
|
|
|
|
[CHECKING] bar v0.1.0 ([..])
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-11-15 22:33:27 +00:00
|
|
|
p.cargo("check").with_stderr("[FINISHED] [..]").run();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.2").publish();
|
2023-08-23 14:13:34 +00:00
|
|
|
p.cargo("update")
|
2018-08-28 09:20:03 +00:00
|
|
|
.arg(&format!("{}#bar", foo.url()))
|
|
|
|
.with_stderr(
|
2018-03-06 05:21:47 +00:00
|
|
|
"\
|
2018-09-09 23:59:48 +00:00
|
|
|
[UPDATING] git repository `file://[..]`
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2018-03-06 05:21:47 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2023-08-23 14:13:34 +00:00
|
|
|
p.cargo("update https://github.com/rust-lang/crates.io-index#bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-06 05:21:47 +00:00
|
|
|
"\
|
2021-06-27 19:18:36 +00:00
|
|
|
[UPDATING] `dummy-registry` index
|
2018-03-06 05:21:47 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-11-15 22:33:27 +00:00
|
|
|
p.cargo("check").with_stderr("[FINISHED] [..]").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn locked_means_locked_yes_no_seriously_i_mean_locked() {
|
2016-02-09 23:42:17 +00:00
|
|
|
// this in theory exercises #2041
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.0").publish();
|
|
|
|
Package::new("baz", "0.2.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = "*"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
|
|
|
baz = "0.1"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check").run();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-11-15 22:33:27 +00:00
|
|
|
p.cargo("check").with_stderr("[FINISHED] [..]").run();
|
|
|
|
p.cargo("check").with_stderr("[FINISHED] [..]").run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn override_wrong_name() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = "0.1"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"baz:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2016-05-20 11:47:39 +00:00
|
|
|
[UPDATING] git repository [..]
|
2020-02-27 16:17:18 +00:00
|
|
|
[ERROR] failed to get `baz` as a dependency of package `foo v0.0.1 ([..])`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
2022-04-19 21:00:15 +00:00
|
|
|
no matching package for override `[..]baz@0.1.0` found
|
2020-06-25 15:25:52 +00:00
|
|
|
location searched: file://[..]
|
|
|
|
version required: =0.1.0
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn override_with_nothing() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
let foo = git::repo(&paths::root().join("override"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
foo.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2016-05-20 11:47:39 +00:00
|
|
|
[UPDATING] git repository [..]
|
2020-02-27 16:17:18 +00:00
|
|
|
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..])`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
failed to load source for dependency `bar`
|
2016-06-28 17:39:46 +00:00
|
|
|
|
|
|
|
Caused by:
|
2018-09-09 23:59:48 +00:00
|
|
|
Unable to update file://[..]
|
2016-02-09 23:42:17 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Could not find Cargo.toml in `[..]`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn override_wrong_version() {
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = { git = 'https://example.com', version = '0.2.0' }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-02-09 23:42:17 +00:00
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
2022-04-19 21:00:15 +00:00
|
|
|
replacements cannot specify a version requirement, but found one for `[..]bar@0.1.0`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn multiple_specs() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{0}' }}
|
2016-02-03 18:54:07 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace."https://github.com/rust-lang/crates.io-index#bar:0.1.0"]
|
|
|
|
git = '{0}'
|
|
|
|
"#,
|
2018-07-20 17:41:44 +00:00
|
|
|
bar.url()
|
2018-03-14 15:17:44 +00:00
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] [..] index
|
2016-05-20 11:47:39 +00:00
|
|
|
[UPDATING] git repository [..]
|
2020-02-27 16:17:18 +00:00
|
|
|
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..])`
|
2020-02-25 18:17:11 +00:00
|
|
|
|
|
|
|
Caused by:
|
|
|
|
overlapping replacement specifications found:
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-06-25 15:25:52 +00:00
|
|
|
* [..]
|
|
|
|
* [..]
|
2016-02-09 23:42:17 +00:00
|
|
|
|
2020-06-25 15:25:52 +00:00
|
|
|
both specifications match: bar v0.1.0
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn test_override_dep() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{0}' }}
|
|
|
|
"#,
|
2018-07-20 17:41:44 +00:00
|
|
|
bar.url()
|
2018-03-14 15:17:44 +00:00
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-05-20 21:25:43 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("test -p bar")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-07-20 17:41:44 +00:00
|
|
|
error: There are multiple `bar` packages in your project, and the [..]
|
2016-05-20 21:25:43 +00:00
|
|
|
Please re-run this command with [..]
|
2022-04-19 21:00:15 +00:00
|
|
|
[..]#bar@0.1.0
|
|
|
|
[..]#bar@0.1.0
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-06-05 07:19:55 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-06-05 07:19:55 +00:00
|
|
|
fn update() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
2016-06-05 07:19:55 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-06-05 07:19:55 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-06-05 07:19:55 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-06-05 07:19:55 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{0}' }}
|
|
|
|
"#,
|
2018-07-20 17:41:44 +00:00
|
|
|
bar.url()
|
2018-03-14 15:17:44 +00:00
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-06-05 07:19:55 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("generate-lockfile").run();
|
|
|
|
p.cargo("update")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` index
|
2016-06-05 07:19:55 +00:00
|
|
|
[UPDATING] git repository `[..]`
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-06-05 07:19:55 +00:00
|
|
|
}
|
2016-07-14 08:44:31 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
// foo -> near -> far
|
2016-07-14 08:44:31 +00:00
|
|
|
// near is overridden with itself
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-14 08:44:31 +00:00
|
|
|
fn no_override_self() {
|
|
|
|
let deps = git::repo(&paths::root().join("override"))
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("far/Cargo.toml", &basic_manifest("far", "0.1.0"))
|
2016-07-14 08:44:31 +00:00
|
|
|
.file("far/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"near/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "near"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-07-14 08:44:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
far = { path = "../far" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("near/src/lib.rs", "#![no_std] pub extern crate far;")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-14 08:44:31 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-07-14 08:44:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
near = {{ git = '{0}' }}
|
2016-07-14 08:44:31 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"near:0.1.0" = {{ git = '{0}' }}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
deps.url()
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "#![no_std] pub extern crate near;")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-07-14 08:44:31 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check --verbose").run();
|
2016-07-14 08:44:31 +00:00
|
|
|
}
|
2016-09-29 23:35:22 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-10-21 02:02:38 +00:00
|
|
|
fn override_an_override() {
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("chrono", "0.2.0")
|
|
|
|
.dep("serde", "< 0.9")
|
|
|
|
.publish();
|
2016-10-21 02:02:38 +00:00
|
|
|
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();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-10-21 02:02:38 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
chrono = "0.2"
|
|
|
|
serde = "0.8"
|
2016-10-21 02:02:38 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"chrono:0.2.0" = { path = "chrono" }
|
|
|
|
"serde:0.8.0" = { path = "serde" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"Cargo.lock",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[[package]]
|
|
|
|
name = "foo"
|
|
|
|
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"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"src/lib.rs",
|
|
|
|
"
|
2016-10-21 02:02:38 +00:00
|
|
|
extern crate chrono;
|
|
|
|
extern crate serde;
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
pub fn foo() {
|
2016-10-21 02:02:38 +00:00
|
|
|
chrono::chrono();
|
|
|
|
serde::serde08_override();
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"chrono/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "chrono"
|
|
|
|
version = "0.2.0"
|
|
|
|
authors = []
|
2016-10-21 02:02:38 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
serde = "< 0.9"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"chrono/src/lib.rs",
|
|
|
|
"
|
2016-10-21 02:02:38 +00:00
|
|
|
extern crate serde;
|
|
|
|
pub fn chrono() {
|
|
|
|
serde::serde07();
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("serde/Cargo.toml", &basic_manifest("serde", "0.8.0"))
|
2018-07-25 00:30:32 +00:00
|
|
|
.file("serde/src/lib.rs", "pub fn serde08_override() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-10-21 02:02:38 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check -v").run();
|
2016-10-21 02:02:38 +00:00
|
|
|
}
|
2016-11-02 17:32:35 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-11-02 17:32:35 +00:00
|
|
|
fn overriding_nonexistent_no_spurious() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").dep("baz", "0.1").publish();
|
|
|
|
Package::new("baz", "0.1.0").publish();
|
2016-11-02 17:32:35 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-11-02 17:32:35 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = { path = "baz" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("baz/src/lib.rs", "pub fn baz() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-11-02 17:32:35 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{url}' }}
|
|
|
|
"baz:0.1.0" = {{ git = '{url}' }}
|
|
|
|
"#,
|
2018-07-20 17:41:44 +00:00
|
|
|
url = bar.url()
|
2018-03-14 15:17:44 +00:00
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-11-02 17:32:35 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check").run();
|
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
2022-04-19 21:00:15 +00:00
|
|
|
[WARNING] package replacement is not used: [..]baz@0.1.0
|
2016-11-02 17:32:35 +00:00
|
|
|
[FINISHED] [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.with_stdout("")
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2016-11-02 17:32:35 +00:00
|
|
|
}
|
2016-11-04 00:00:13 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-29 09:58:45 +00:00
|
|
|
fn no_warnings_when_replace_is_used_in_another_workspace_member() {
|
|
|
|
Package::new("bar", "0.1.0").publish();
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("baz", "0.1.0").publish();
|
2017-03-29 09:58:45 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2017-03-29 09:58:45 +00:00
|
|
|
[workspace]
|
|
|
|
members = [ "first_crate", "second_crate"]
|
|
|
|
|
|
|
|
[replace]
|
2020-09-27 00:59:58 +00:00
|
|
|
"bar:0.1.0" = { path = "local_bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"first_crate/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "first_crate"
|
|
|
|
version = "0.1.0"
|
2017-03-29 09:58:45 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("first_crate/src/lib.rs", "")
|
2018-08-28 09:20:03 +00:00
|
|
|
.file(
|
|
|
|
"second_crate/Cargo.toml",
|
|
|
|
&basic_manifest("second_crate", "0.1.0"),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("second_crate/src/lib.rs", "")
|
2018-07-24 22:35:01 +00:00
|
|
|
.file("local_bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("local_bar/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-29 09:58:45 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
.cwd("first_crate")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stdout("")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 09:23:57 +00:00
|
|
|
[UPDATING] `[..]` index
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] bar v0.1.0 ([..])
|
|
|
|
[CHECKING] first_crate v0.1.0 ([..])
|
2018-03-14 15:17:44 +00:00
|
|
|
[FINISHED] [..]",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2019-03-20 23:34:56 +00:00
|
|
|
.cwd("second_crate")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stdout("")
|
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2023-02-16 02:54:00 +00:00
|
|
|
[CHECKING] second_crate v0.1.0 ([..])
|
2018-03-14 15:17:44 +00:00
|
|
|
[FINISHED] [..]",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-03-29 09:58:45 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-11-04 00:00:13 +00:00
|
|
|
fn replace_to_path_dep() {
|
2018-07-20 17:41:44 +00:00
|
|
|
Package::new("bar", "0.1.0").dep("baz", "0.1").publish();
|
|
|
|
Package::new("baz", "0.1.0").publish();
|
2016-11-04 00:00:13 +00:00
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2016-11-04 00:00:13 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
2016-11-04 00:00:13 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = { path = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "extern crate bar;")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
2018-07-20 17:41:44 +00:00
|
|
|
"bar/Cargo.toml",
|
2018-03-14 15:17:44 +00:00
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-11-04 00:00:13 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
baz = { path = "baz" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-08-28 09:20:03 +00:00
|
|
|
"bar/src/lib.rs",
|
|
|
|
"extern crate baz; pub fn bar() { baz::baz(); }",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.1.0"))
|
2018-07-20 17:41:44 +00:00
|
|
|
.file("bar/baz/src/lib.rs", "pub fn baz() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-11-04 00:00:13 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check").run();
|
2016-11-04 00:00:13 +00:00
|
|
|
}
|
2016-11-28 16:51:36 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-17 23:12:11 +00:00
|
|
|
fn override_with_default_feature() {
|
|
|
|
Package::new("another", "0.1.0").publish();
|
2018-03-14 15:17:44 +00:00
|
|
|
Package::new("another", "0.1.1").dep("bar", "0.1").publish();
|
2017-03-17 23:12:11 +00:00
|
|
|
Package::new("bar", "0.1.0").publish();
|
|
|
|
|
2018-07-20 17:41:44 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2017-03-17 23:12:11 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar", default-features = false }
|
|
|
|
another = "0.1"
|
|
|
|
another2 = { path = "another2" }
|
2017-03-17 23:12:11 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
'bar:0.1.0' = { path = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2017-03-17 23:12:11 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[features]
|
|
|
|
default = []
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"bar/src/lib.rs",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
#[cfg(feature = "default")]
|
|
|
|
pub fn bar() {}
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file(
|
2018-03-14 15:17:44 +00:00
|
|
|
"another2/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "another2"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2017-03-17 23:12:11 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = { version = "0.1", default-features = false }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("another2/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-17 23:12:11 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("run").run();
|
2017-03-17 23:12:11 +00:00
|
|
|
}
|
2017-03-20 19:43:44 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-03-20 19:43:44 +00:00
|
|
|
fn override_plus_dep() {
|
|
|
|
Package::new("bar", "0.1.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#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2017-03-20 19:43:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
bar = "0.1"
|
2017-03-20 19:43:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[replace]
|
|
|
|
'bar:0.1.0' = { path = "bar" }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo = { path = ".." }
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2017-03-20 19:43:44 +00:00
|
|
|
|
2023-02-16 02:54:00 +00:00
|
|
|
p.cargo("check")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr_contains("error: cyclic package dependency: [..]")
|
|
|
|
.run();
|
2017-03-20 19:43:44 +00:00
|
|
|
}
|
2023-10-10 21:18:56 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
2023-10-11 02:31:31 +00:00
|
|
|
fn override_generic_matching_other_versions() {
|
2023-10-10 21:18:56 +00:00
|
|
|
Package::new("bar", "0.1.0+a").publish();
|
|
|
|
|
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
|
|
|
bar.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[UPDATING] git repository `[..]`
|
2023-10-11 02:31:31 +00:00
|
|
|
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..]/foo)`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
replacement specification `https://github.com/rust-lang/crates.io-index#bar@0.1.0` matched 0.1.0+a and tried to override it with 0.1.0
|
|
|
|
avoid matching unrelated packages by being more specific
|
2023-10-10 21:18:56 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
2023-10-10 21:39:46 +00:00
|
|
|
fn override_respects_spec_metadata() {
|
2023-10-10 21:18:56 +00:00
|
|
|
Package::new("bar", "0.1.0+a").publish();
|
|
|
|
|
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0+a"))
|
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0+notTheBuild" = {{ git = '{}' }}
|
|
|
|
"#,
|
|
|
|
bar.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
2023-10-10 21:39:46 +00:00
|
|
|
[WARNING] package replacement is not used: https://github.com/rust-lang/crates.io-index#bar@0.1.0+notTheBuild
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] bar v0.1.0+a (registry `dummy-registry`)
|
|
|
|
[CHECKING] bar v0.1.0+a
|
|
|
|
[CHECKING] foo v0.0.1 ([..]/foo)
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
|
|
|
[..]
|
2023-11-29 16:30:07 +00:00
|
|
|
error: could not compile `foo` (lib) due to 1 previous error
|
2023-10-10 21:18:56 +00:00
|
|
|
",
|
|
|
|
)
|
2023-10-10 21:39:46 +00:00
|
|
|
.with_status(101)
|
2023-10-10 21:18:56 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
2023-10-11 02:35:02 +00:00
|
|
|
fn override_spec_metadata_is_optional() {
|
2023-10-10 21:18:56 +00:00
|
|
|
Package::new("bar", "0.1.0+a").publish();
|
|
|
|
|
|
|
|
let bar = git::repo(&paths::root().join("override"))
|
|
|
|
.file("Cargo.toml", &basic_manifest("bar", "0.1.0+a"))
|
|
|
|
.file("src/lib.rs", "pub fn bar() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.1.0"
|
|
|
|
|
|
|
|
[replace]
|
|
|
|
"bar:0.1.0" = {{ git = '{}' }}
|
|
|
|
"#,
|
|
|
|
bar.url()
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"extern crate bar; pub fn foo() { bar::bar(); }",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `dummy-registry` index
|
|
|
|
[UPDATING] git repository `[..]`
|
|
|
|
[CHECKING] bar v0.1.0+a (file://[..])
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|