2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for public/private dependencies.
|
|
|
|
|
2021-09-09 06:10:33 +00:00
|
|
|
use cargo_test_support::project;
|
2024-01-02 19:34:13 +00:00
|
|
|
use cargo_test_support::registry::{Dependency, Package};
|
2019-03-20 23:25:59 +00:00
|
|
|
|
2021-09-09 06:10:33 +00:00
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
2019-03-20 23:25:59 +00:00
|
|
|
fn exported_priv_warning() {
|
|
|
|
Package::new("priv_dep", "0.1.0")
|
2019-04-23 04:47:31 +00:00
|
|
|
.file("src/lib.rs", "pub struct FromPriv;")
|
2019-03-20 23:25:59 +00:00
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
cargo-features = ["public-dependency"]
|
2019-03-20 23:25:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2019-03-20 23:25:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
priv_dep = "0.1.0"
|
|
|
|
"#,
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate priv_dep;
|
|
|
|
pub fn use_priv(_: priv_dep::FromPriv) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:41:59 +00:00
|
|
|
p.cargo("check --message-format=short")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2020-04-13 04:09:39 +00:00
|
|
|
.with_stderr_contains(
|
2019-03-20 23:25:59 +00:00
|
|
|
"\
|
2020-09-05 17:31:04 +00:00
|
|
|
src/lib.rs:3:13: warning: type `[..]FromPriv` from private dependency 'priv_dep' in public interface
|
|
|
|
",
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
|
|
|
|
2021-09-09 06:10:33 +00:00
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
2019-03-20 23:25:59 +00:00
|
|
|
fn exported_pub_dep() {
|
|
|
|
Package::new("pub_dep", "0.1.0")
|
2019-04-23 04:47:31 +00:00
|
|
|
.file("src/lib.rs", "pub struct FromPub;")
|
2019-03-20 23:25:59 +00:00
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
cargo-features = ["public-dependency"]
|
2019-03-20 23:25:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2019-03-20 23:25:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
pub_dep = {version = "0.1.0", public = true}
|
|
|
|
"#,
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate pub_dep;
|
|
|
|
pub fn use_pub(_: pub_dep::FromPub) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:41:59 +00:00
|
|
|
p.cargo("check --message-format=short")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2019-03-20 23:25:59 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] pub_dep v0.1.0 ([..])
|
2023-02-16 02:41:59 +00:00
|
|
|
[CHECKING] pub_dep v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
2019-03-20 23:25:59 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2019-04-23 04:47:31 +00:00
|
|
|
",
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-03-20 23:25:59 +00:00
|
|
|
pub fn requires_nightly_cargo() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
"#,
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
2019-04-23 04:47:31 +00:00
|
|
|
.file("src/lib.rs", "")
|
2019-03-20 23:25:59 +00:00
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:41:59 +00:00
|
|
|
p.cargo("check --message-format=short")
|
2019-03-20 23:25:59 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
the cargo feature `public-dependency` requires a nightly version of Cargo, but this is the `stable` channel
|
2020-06-25 15:25:52 +00:00
|
|
|
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
|
2021-01-21 04:08:52 +00:00
|
|
|
See https://doc.rust-lang.org/[..]cargo/reference/unstable.html#public-dependency for more information about using this feature.
|
2019-03-20 23:25:59 +00:00
|
|
|
"
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-03-20 23:25:59 +00:00
|
|
|
fn requires_feature() {
|
|
|
|
Package::new("pub_dep", "0.1.0")
|
2019-04-23 04:47:31 +00:00
|
|
|
.file("src/lib.rs", "")
|
2019-03-20 23:25:59 +00:00
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2019-03-20 23:25:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
pub_dep = { version = "0.1.0", public = true }
|
|
|
|
"#,
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
2019-04-23 04:47:31 +00:00
|
|
|
.file("src/lib.rs", "")
|
2019-03-20 23:25:59 +00:00
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:41:59 +00:00
|
|
|
p.cargo("check --message-format=short")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2019-03-20 23:25:59 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
feature `public-dependency` is required
|
|
|
|
|
2021-07-05 23:08:36 +00:00
|
|
|
The package requires the Cargo feature called `public-dependency`, \
|
|
|
|
but that feature is not stabilized in this version of Cargo (1.[..]).
|
|
|
|
Consider adding `cargo-features = [\"public-dependency\"]` to the top of Cargo.toml \
|
|
|
|
(above the [package] table) to tell Cargo you are opting in to use this unstable feature.
|
|
|
|
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#public-dependency \
|
|
|
|
for more information about the status of this feature.
|
2019-04-23 04:47:31 +00:00
|
|
|
",
|
2019-03-20 23:25:59 +00:00
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
2019-04-26 02:34:18 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-04-26 02:34:18 +00:00
|
|
|
fn pub_dev_dependency() {
|
|
|
|
Package::new("pub_dep", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPub;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
cargo-features = ["public-dependency"]
|
2019-04-26 02:34:18 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2019-04-26 02:34:18 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dev-dependencies]
|
|
|
|
pub_dep = {version = "0.1.0", public = true}
|
|
|
|
"#,
|
2019-04-26 02:34:18 +00:00
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate pub_dep;
|
|
|
|
pub fn use_pub(_: pub_dep::FromPub) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
2023-02-16 02:41:59 +00:00
|
|
|
p.cargo("check --message-format=short")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2019-04-26 02:34:18 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `[..]`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
'public' specifier can only be used on regular dependencies, not Development dependencies
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
2023-10-13 07:32:05 +00:00
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
2023-11-27 16:23:29 +00:00
|
|
|
fn workspace_pub_disallowed() {
|
2023-10-13 07:32:05 +00:00
|
|
|
Package::new("foo1", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromFoo;")
|
|
|
|
.publish();
|
|
|
|
Package::new("foo2", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromFoo;")
|
|
|
|
.publish();
|
|
|
|
Package::new("foo3", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromFoo;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[workspace.dependencies]
|
|
|
|
foo1 = "0.1.0"
|
|
|
|
foo2 = { version = "0.1.0", public = true }
|
|
|
|
foo3 = { version = "0.1.0", public = false }
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
foo1 = { workspace = true, public = true }
|
|
|
|
foo2 = { workspace = true }
|
|
|
|
foo3 = { workspace = true, public = true }
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
#![deny(exported_private_dependencies)]
|
|
|
|
pub fn use_priv1(_: foo1::FromFoo) {}
|
|
|
|
pub fn use_priv2(_: foo2::FromFoo) {}
|
|
|
|
pub fn use_priv3(_: foo3::FromFoo) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2023-11-27 16:23:29 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `[CWD]/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
foo2 is public, but workspace dependencies cannot be public
|
|
|
|
",
|
|
|
|
)
|
2023-10-13 07:32:05 +00:00
|
|
|
.run()
|
|
|
|
}
|
2023-12-08 03:55:57 +00:00
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
|
|
|
fn allow_priv_in_tests() {
|
|
|
|
Package::new("priv_dep", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPriv;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
priv_dep = {version = "0.1.0", public = false}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"tests/mod.rs",
|
|
|
|
"
|
|
|
|
extern crate priv_dep;
|
|
|
|
pub fn use_priv(_: priv_dep::FromPriv) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check --tests --message-format=short")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2023-12-08 04:10:10 +00:00
|
|
|
.with_stderr(
|
2023-12-08 03:55:57 +00:00
|
|
|
"\
|
2023-12-08 04:10:10 +00:00
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] priv_dep v0.1.0 ([..])
|
|
|
|
[CHECKING] priv_dep v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2023-12-08 03:55:57 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
|
|
|
fn allow_priv_in_benchs() {
|
|
|
|
Package::new("priv_dep", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPriv;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
priv_dep = {version = "0.1.0", public = false}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"benches/mod.rs",
|
|
|
|
"
|
|
|
|
extern crate priv_dep;
|
|
|
|
pub fn use_priv(_: priv_dep::FromPriv) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check --benches --message-format=short")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2023-12-08 04:10:10 +00:00
|
|
|
.with_stderr(
|
2023-12-08 03:55:57 +00:00
|
|
|
"\
|
2023-12-08 04:10:10 +00:00
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] priv_dep v0.1.0 ([..])
|
|
|
|
[CHECKING] priv_dep v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2023-12-08 03:55:57 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
|
|
|
fn allow_priv_in_bins() {
|
|
|
|
Package::new("priv_dep", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPriv;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
priv_dep = {version = "0.1.0", public = false}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
"
|
|
|
|
extern crate priv_dep;
|
|
|
|
pub fn use_priv(_: priv_dep::FromPriv) {}
|
|
|
|
fn main() {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check --bins --message-format=short")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2023-12-08 04:10:10 +00:00
|
|
|
.with_stderr(
|
2023-12-08 03:55:57 +00:00
|
|
|
"\
|
2023-12-08 04:10:10 +00:00
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] priv_dep v0.1.0 ([..])
|
|
|
|
[CHECKING] priv_dep v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2023-12-08 03:55:57 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
|
|
|
fn allow_priv_in_examples() {
|
|
|
|
Package::new("priv_dep", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPriv;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
priv_dep = {version = "0.1.0", public = false}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"examples/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate priv_dep;
|
|
|
|
pub fn use_priv(_: priv_dep::FromPriv) {}
|
|
|
|
fn main() {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check --examples --message-format=short")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
2023-12-08 04:10:10 +00:00
|
|
|
.with_stderr(
|
2023-12-08 03:55:57 +00:00
|
|
|
"\
|
2023-12-08 04:10:10 +00:00
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] priv_dep v0.1.0 ([..])
|
|
|
|
[CHECKING] priv_dep v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2023-12-08 03:55:57 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
2023-12-09 09:14:10 +00:00
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
|
|
|
fn allow_priv_in_custom_build() {
|
|
|
|
Package::new("priv_dep", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPriv;")
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[build-dependencies]
|
|
|
|
priv_dep = "0.1.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"build.rs",
|
|
|
|
"
|
|
|
|
extern crate priv_dep;
|
|
|
|
pub fn use_priv(_: priv_dep::FromPriv) {}
|
|
|
|
fn main() {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check --all-targets --message-format=short")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] priv_dep v0.1.0 ([..])
|
|
|
|
[COMPILING] priv_dep v0.1.0
|
|
|
|
[COMPILING] foo v0.0.1 ([CWD])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|
2024-01-02 19:34:13 +00:00
|
|
|
|
|
|
|
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
|
|
|
|
fn publish_package_with_public_dependency() {
|
|
|
|
Package::new("pub_bar", "0.1.0")
|
|
|
|
.file("src/lib.rs", "pub struct FromPub;")
|
|
|
|
.publish();
|
|
|
|
Package::new("bar", "0.1.0")
|
|
|
|
.cargo_feature("public-dependency")
|
|
|
|
.add_dep(Dependency::new("pub_bar", "0.1.0").public(true))
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate pub_bar;
|
|
|
|
pub use pub_bar::FromPub as BarFromPub;
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.publish();
|
|
|
|
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
[dependencies]
|
|
|
|
bar = {version = "0.1.0", public = true}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
"
|
|
|
|
extern crate bar;
|
|
|
|
pub fn use_pub(_: bar::BarFromPub) {}
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("check --message-format=short")
|
|
|
|
.masquerade_as_nightly_cargo(&["public-dependency"])
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[UPDATING] `[..]` index
|
|
|
|
[DOWNLOADING] crates ...
|
|
|
|
[DOWNLOADED] pub_bar v0.1.0 ([..])
|
|
|
|
[DOWNLOADED] bar v0.1.0 ([..])
|
|
|
|
[CHECKING] pub_bar v0.1.0
|
|
|
|
[CHECKING] bar v0.1.0
|
|
|
|
[CHECKING] foo v0.0.1 ([..])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
}
|