Skip to content

Commit

Permalink
test: add tests for rust-lang#10525 and rust-lang#10837
Browse files Browse the repository at this point in the history
  • Loading branch information
bstrie committed Dec 15, 2022
1 parent d0b97ae commit 4673164
Showing 1 changed file with 256 additions and 0 deletions.
256 changes: 256 additions & 0 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2672,3 +2672,259 @@ fn same_target_transitive_dependency_deduplication_lib() {
)
.run();
}

#[cargo_test]
fn issue_10525() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "mycrate"
version = "0.0.0"
edition = "2021"
[dependencies]
structopt-derive = { path = "structopt-derive" }
mybindep = { path = "mybindep", artifact = "bin", target = "x86_64-unknown-linux-gnu" }
"#,
)
.file(
"src/main.rs",
r#"
fn main() {
env!("CARGO_BIN_FILE_MYBINDEP");
}
"#,
)
.file(
"mybindep/Cargo.toml",
r#"
[package]
name = "mybindep"
version = "0.0.0"
edition = "2021"
[dependencies]
clap_derive = { path = "../clap_derive" }
"#,
)
.file("mybindep/src/main.rs", "fn main() {}")
.file(
"clap_derive/Cargo.toml",
r#"
[package]
name = "clap_derive"
version = "0.0.0"
edition = "2021"
[dependencies]
proc-macro-error = { path = "../proc-macro-error" }
[lib]
proc-macro = true
"#,
)
.file("clap_derive/src/lib.rs", "")
.file(
"structopt-derive/Cargo.toml",
r#"
[package]
name = "structopt-derive"
version = "0.0.0"
edition = "2021"
[dependencies]
syn = { path = "../syn", features = ["parsing"] }
proc-macro-error = { path = "../proc-macro-error" }
[lib]
proc-macro = true
"#,
)
.file(
"structopt-derive/src/lib.rs",
r#"
use proc_macro_error::ResultExt;
fn _parse_structopt_attributes() {
Ok::<(), syn::Error>(()).unwrap_or_abort()
}
"#,
)
.file(
"proc-macro-error/Cargo.toml",
r#"
[package]
name = "proc-macro-error"
version = "0.0.0"
edition = "2021"
[dependencies]
syn = { path = "../syn" }
"#,
)
.file(
"proc-macro-error/src/lib.rs",
r#"
pub trait ResultExt<T> {
fn unwrap_or_abort(self) -> T;
}
impl<T, E: Into<Diagnostic>> ResultExt<T> for Result<T, E> {
fn unwrap_or_abort(self) -> T {
panic!()
}
}
pub struct Diagnostic;
impl From<syn::Error> for Diagnostic {
fn from(_: syn::Error) -> Self {
panic!()
}
}
"#,
)
.file(
"syn/Cargo.toml",
r#"
[package]
name = "syn"
version = "0.0.0"
edition = "2021"
[features]
parsing = []
"#,
)
.file("syn/src/lib.rs", "pub struct Error;")
.build();

p.cargo("build -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.with_stderr_unordered(
"\
[COMPILING] mycrate v0.0.0 ([CWD])
[COMPILING] mybindep v0.0.0 ([CWD]/mybindep)
[COMPILING] clap_derive v0.0.0 ([CWD]/clap_derive)
[COMPILING] structopt-derive v0.0.0 ([CWD]/structopt-derive)
[COMPILING] proc-macro-error v0.0.0 ([CWD]/proc-macro-error)
[COMPILING] syn v0.0.0 ([CWD]/syn)
[FINISHED] dev [..]
",
)
.run();
}

#[cargo_test]
fn issue_10837() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "mycrate"
version = "0.0.0"
edition = "2021"
[dependencies]
indexmap = { path = "indexmap" }
serde = { path = "serde", features = ["alloc"] }
wasmtime-environ = { path = "wasmtime-environ", lib = true, artifact = "bin", target = "x86_64-unknown-linux-gnu" }
"#,
)
.file("src/lib.rs", "")
.file(
"indexmap/Cargo.toml",
r#"
[package]
name = "indexmap"
version = "0.0.0"
edition = "2021"
[dependencies]
serde = { path = "../serde", optional = true }
"#,
)
.file(
"indexmap/src/lib.rs",
r#"
pub struct IndexMap;
#[cfg(feature = "serde")]
impl serde::Serialize for IndexMap {
fn serialize<T: serde::Serializer>(&self, _: T) {}
}
"#,
)
.file(
"serde/Cargo.toml",
r#"
[package]
name = "serde"
version = "0.0.0"
edition = "2021"
[features]
alloc = []
"#,
)
.file(
"serde/src/lib.rs",
r#"
pub trait Serialize {
fn serialize<S: Serializer>(&self, serializer: S);
}
pub trait Serializer {
fn serialize_field<T: Serialize>(&self, value: &T);
}
"#,
)
.file(
"wasmtime-environ/Cargo.toml",
r#"
[package]
name = "wasmtime-environ"
version = "0.0.0"
edition = "2021"
[dependencies]
indexmap = { path = "../indexmap", features = ["serde"] }
serde = { path = "../serde" }
"#,
)
.file(
"wasmtime-environ/src/lib.rs",
r#"
use indexmap::IndexMap;
use serde::{Serialize, Serializer};
struct Module {
exports: IndexMap,
}
impl Serialize for Module {
fn serialize<T: Serializer>(&self, serializer: T) {
serializer.serialize_field(&self.exports);
}
}
"#,
)
.file("wasmtime-environ/src/main.rs", "fn main() {}")
.build();

p.cargo("build -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.with_stderr_unordered(
"\
[COMPILING] mycrate v0.0.0 ([CWD])
[COMPILING] indexmap v0.0.0 ([CWD]/indexmap)
[COMPILING] serde v0.0.0 ([CWD]/serde)
[COMPILING] wasmtime-environ v0.0.0 ([CWD]/wasmtime-environ)
[FINISHED] dev [..]
",
)
.run();
}

0 comments on commit 4673164

Please sign in to comment.