Skip to content

Commit 58c673d

Browse files
committed
test(pub_priv): covering build.rs test
1 parent ab13b10 commit 58c673d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/testsuite/pub_priv.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,49 @@ fn allow_priv_in_examples() {
424424
)
425425
.run()
426426
}
427+
428+
#[cargo_test(nightly, reason = "exported_private_dependencies lint is unstable")]
429+
fn allow_priv_in_custom_build() {
430+
Package::new("priv_dep", "0.1.0")
431+
.file("src/lib.rs", "pub struct FromPriv;")
432+
.publish();
433+
434+
let p = project()
435+
.file(
436+
"Cargo.toml",
437+
r#"
438+
cargo-features = ["public-dependency"]
439+
440+
[package]
441+
name = "foo"
442+
version = "0.0.1"
443+
444+
[build-dependencies]
445+
priv_dep = "0.1.0"
446+
"#,
447+
)
448+
.file("src/main.rs", "fn main() {}")
449+
.file(
450+
"build.rs",
451+
"
452+
extern crate priv_dep;
453+
pub fn use_priv(_: priv_dep::FromPriv) {}
454+
fn main() {}
455+
",
456+
)
457+
.build();
458+
459+
p.cargo("check --all-targets --message-format=short")
460+
.masquerade_as_nightly_cargo(&["public-dependency"])
461+
.with_stderr(
462+
"\
463+
[UPDATING] `[..]` index
464+
[DOWNLOADING] crates ...
465+
[DOWNLOADED] priv_dep v0.1.0 ([..])
466+
[COMPILING] priv_dep v0.1.0
467+
[COMPILING] foo v0.0.1 ([CWD])
468+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
469+
",
470+
)
471+
.run()
472+
}

0 commit comments

Comments
 (0)