Skip to content

Commit dca8c28

Browse files
committed
refactor: simplify #10525 test case
Signed-off-by: Roman Volosatovs <[email protected]>
1 parent 0c647a8 commit dca8c28

File tree

1 file changed

+49
-58
lines changed

1 file changed

+49
-58
lines changed

tests/testsuite/artifact_dep.rs

Lines changed: 49 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,147 +2672,138 @@ fn same_target_transitive_dependency_decouple_from_hostdep_lib() {
26722672
}
26732673

26742674
#[cargo_test]
2675-
fn issue_10525() {
2675+
fn same_target_transitive_dependency_decouple_from_hostdep_10525() {
2676+
// See https://github.com/rust-lang/cargo/issues/10525
26762677
let target = rustc_host();
26772678
let p = project()
26782679
.file(
26792680
"Cargo.toml",
26802681
&format!(
26812682
r#"
26822683
[package]
2683-
name = "mycrate"
2684+
name = "foo"
26842685
version = "0.0.0"
26852686
edition = "2021"
26862687
26872688
[dependencies]
2688-
structopt-derive = {{ path = "structopt-derive" }}
2689-
mybindep = {{ path = "mybindep", artifact = "bin", target = "{target}" }}
2689+
e = {{ path = "e" }}
2690+
bar = {{ path = "bar", artifact = "bin", target = "{target}" }}
26902691
"#
26912692
),
26922693
)
26932694
.file(
26942695
"src/main.rs",
26952696
r#"
2696-
fn main() {
2697-
env!("CARGO_BIN_FILE_MYBINDEP");
2698-
}
2697+
fn main() {}
26992698
"#,
27002699
)
27012700
.file(
2702-
"mybindep/Cargo.toml",
2701+
"bar/Cargo.toml",
27032702
r#"
27042703
[package]
2705-
name = "mybindep"
2704+
name = "bar"
27062705
version = "0.0.0"
2707-
edition = "2021"
27082706
27092707
[dependencies]
2710-
clap_derive = { path = "../clap_derive" }
2708+
b = { path = "../b" }
27112709
"#,
27122710
)
2713-
.file("mybindep/src/main.rs", "fn main() {}")
2711+
.file("bar/src/main.rs", "fn main() {}")
27142712
.file(
2715-
"clap_derive/Cargo.toml",
2713+
"b/Cargo.toml",
27162714
r#"
27172715
[package]
2718-
name = "clap_derive"
2716+
name = "b"
27192717
version = "0.0.0"
2720-
edition = "2021"
27212718
27222719
[dependencies]
2723-
proc-macro-error = { path = "../proc-macro-error" }
2724-
2725-
[lib]
2726-
proc-macro = true
2720+
c = { path = "../c" }
27272721
"#,
27282722
)
2729-
.file("clap_derive/src/lib.rs", "")
2723+
.file("b/src/lib.rs", "")
27302724
.file(
2731-
"structopt-derive/Cargo.toml",
2725+
// NOTE: Calling this package `a` does not trigger
2726+
// https://github.com/rust-lang/cargo/issues/10525
2727+
"e/Cargo.toml",
27322728
r#"
27332729
[package]
2734-
name = "structopt-derive"
2730+
name = "e"
27352731
version = "0.0.0"
27362732
edition = "2021"
27372733
27382734
[dependencies]
2739-
syn = { path = "../syn", features = ["parsing"] }
2740-
proc-macro-error = { path = "../proc-macro-error" }
2741-
2742-
[lib]
2743-
proc-macro = true
2735+
c = { path = "../c" }
2736+
d = { path = "../d", features = ["feature"] }
27442737
"#,
27452738
)
27462739
.file(
2747-
"structopt-derive/src/lib.rs",
2740+
"e/src/lib.rs",
27482741
r#"
2749-
use proc_macro_error::ResultExt;
2742+
use c::Trait;
27502743
2751-
fn _parse_structopt_attributes() {
2752-
Ok::<(), syn::Error>(()).unwrap_or_abort()
2744+
pub fn b() {
2745+
d::D.c();
27532746
}
27542747
"#,
27552748
)
27562749
.file(
2757-
"proc-macro-error/Cargo.toml",
2750+
"c/Cargo.toml",
27582751
r#"
27592752
[package]
2760-
name = "proc-macro-error"
2753+
name = "c"
27612754
version = "0.0.0"
2762-
edition = "2021"
27632755
27642756
[dependencies]
2765-
syn = { path = "../syn" }
2757+
d = { path = "../d" }
27662758
"#,
27672759
)
27682760
.file(
2769-
"proc-macro-error/src/lib.rs",
2761+
"c/src/lib.rs",
27702762
r#"
2771-
pub trait ResultExt<T> {
2772-
fn unwrap_or_abort(self) -> T;
2763+
pub trait Trait<T> {
2764+
fn c(self) -> T;
27732765
}
27742766
2775-
impl<T, E: Into<Diagnostic>> ResultExt<T> for Result<T, E> {
2776-
fn unwrap_or_abort(self) -> T {
2777-
panic!()
2767+
impl<T: Into<C>> Trait<T> for T {
2768+
fn c(self) -> T {
2769+
self
27782770
}
27792771
}
27802772
2781-
pub struct Diagnostic;
2773+
pub struct C;
27822774
2783-
impl From<syn::Error> for Diagnostic {
2784-
fn from(_: syn::Error) -> Self {
2785-
panic!()
2775+
impl From<d::D> for C {
2776+
fn from(_: d::D) -> Self {
2777+
Self
27862778
}
27872779
}
27882780
"#,
27892781
)
27902782
.file(
2791-
"syn/Cargo.toml",
2783+
"d/Cargo.toml",
27922784
r#"
27932785
[package]
2794-
name = "syn"
2786+
name = "d"
27952787
version = "0.0.0"
2796-
edition = "2021"
27972788
27982789
[features]
2799-
parsing = []
2790+
feature = []
28002791
"#,
28012792
)
2802-
.file("syn/src/lib.rs", "pub struct Error;")
2793+
.file("d/src/lib.rs", "pub struct D;")
28032794
.build();
28042795

28052796
p.cargo("build -Z bindeps")
28062797
.masquerade_as_nightly_cargo(&["bindeps"])
2807-
.with_stderr_unordered(
2798+
.with_stderr(
28082799
"\
2809-
[COMPILING] mycrate v0.0.0 ([CWD])
2810-
[COMPILING] mybindep v0.0.0 ([CWD]/mybindep)
2811-
[COMPILING] clap_derive v0.0.0 ([CWD]/clap_derive)
2812-
[COMPILING] structopt-derive v0.0.0 ([CWD]/structopt-derive)
2813-
[COMPILING] proc-macro-error v0.0.0 ([CWD]/proc-macro-error)
2814-
[COMPILING] syn v0.0.0 ([CWD]/syn)
2815-
[FINISHED] dev [..]
2800+
[COMPILING] d v0.0.0 ([CWD]/d)
2801+
[COMPILING] c v0.0.0 ([CWD]/c)
2802+
[COMPILING] b v0.0.0 ([CWD]/b)
2803+
[COMPILING] e v0.0.0 ([CWD]/e)
2804+
[COMPILING] bar v0.0.0 ([CWD]/bar)
2805+
[COMPILING] foo v0.0.0 ([CWD])
2806+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
28162807
",
28172808
)
28182809
.run();

0 commit comments

Comments
 (0)