Skip to content

Commit 771b2bc

Browse files
ehussEh2406
authored andcommitted
Repro
1 parent 40d566d commit 771b2bc

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

crates/cargo-test-support/src/registry.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ pub struct Package {
145145
alternative: bool,
146146
invalid_json: bool,
147147
proc_macro: bool,
148+
links: Option<String>,
148149
}
149150

150151
#[derive(Clone)]
@@ -245,6 +246,7 @@ impl Package {
245246
alternative: false,
246247
invalid_json: false,
247248
proc_macro: false,
249+
links: None,
248250
}
249251
}
250252

@@ -368,6 +370,11 @@ impl Package {
368370
self
369371
}
370372

373+
pub fn links(&mut self, links: &str) -> &mut Package {
374+
self.links = Some(links.to_string());
375+
self
376+
}
377+
371378
/// Creates the package and place it in the registry.
372379
///
373380
/// This does not actually use Cargo's publishing system, but instead
@@ -420,6 +427,7 @@ impl Package {
420427
"cksum": cksum,
421428
"features": self.features,
422429
"yanked": self.yanked,
430+
"links": self.links,
423431
})
424432
.to_string();
425433

tests/testsuite/build.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4929,3 +4929,58 @@ hello stderr!
49294929
let stdout = spawn(true);
49304930
lines_match("hello_stdout!", &stdout);
49314931
}
4932+
4933+
use cargo_test_support::registry::Dependency;
4934+
4935+
#[cargo_test]
4936+
fn eric() {
4937+
Package::new("blas-src", "0.6.1")
4938+
.add_dep(Dependency::new("openblas-src", "0.9").optional(true))
4939+
.feature("openblas", &["openblas-src"])
4940+
.publish();
4941+
Package::new("openblas-src", "0.9.0")
4942+
.links("openblas")
4943+
.publish();
4944+
Package::new("openblas-src", "0.6.1")
4945+
.links("openblas")
4946+
.publish();
4947+
Package::new("ndarray-linalg", "0.12.0")
4948+
.add_dep(&Dependency::new("blas-src", "0.4")) // default-features=false
4949+
.add_dep(Dependency::new("ndarray", "0.13").enable_features(&["blas"]))
4950+
.publish();
4951+
Package::new("blas-src", "0.4.0").publish();
4952+
Package::new("blas-src", "0.2.1")
4953+
.feature("openblas", &["openblas-src"])
4954+
.add_dep(Dependency::new("openblas-src", "0.6").optional(true))
4955+
.publish();
4956+
Package::new("ndarray", "0.13.1")
4957+
.add_dep(Dependency::new("blas-src", "0.2.0").optional(true))
4958+
.feature("blas", &["blas-src"])
4959+
.publish();
4960+
4961+
let p = project()
4962+
.file(
4963+
"Cargo.toml",
4964+
r#"
4965+
[package]
4966+
name = "foo"
4967+
version = "0.1.0"
4968+
4969+
[dependencies]
4970+
blas-src = { version = "*", features = ["openblas"] }
4971+
openblas-src = { version = "*" }
4972+
"#,
4973+
)
4974+
.file("src/lib.rs", "")
4975+
.build();
4976+
4977+
p.cargo("generate-lockfile").run();
4978+
cargo::util::paths::append(&p.root().join("Cargo.toml"), b"ndarray-linalg = \"0.12\"\n")
4979+
.unwrap();
4980+
p.cargo("check")
4981+
.with_status(101)
4982+
.with_stderr_contains("[..]links to the native library `openblas`[..]")
4983+
.run();
4984+
// This passes, what!?
4985+
p.cargo("check").run();
4986+
}

0 commit comments

Comments
 (0)