Skip to content

Commit 21e2a30

Browse files
committed
test: add tests for optional dependency resolution check
1 parent 0436f86 commit 21e2a30

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ mod registry_overlay;
164164
mod rename_deps;
165165
mod replace;
166166
mod required_features;
167+
mod resolve_optional_dependency;
167168
mod run;
168169
mod rust_version;
169170
mod rustc;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::prelude::*;
2+
use cargo_test_support::project;
3+
4+
#[cfg(target_os = "linux", target_arch = "x86_64")]
5+
#[cargo_test]
6+
fn cargo_test_should_not_demand_not_required_dep() {
7+
let p = project()
8+
.file(
9+
"Cargo.toml",
10+
r#"
11+
[package]
12+
name = "sample"
13+
version = "0.1.0"
14+
edition = "2024"
15+
16+
[features]
17+
default = ["feat"]
18+
feat = ["dep:ipconfig"]
19+
20+
[target.'cfg(windows)'.dependencies]
21+
ipconfig = { version = "0.3.2", optional = true }
22+
23+
[[example]]
24+
name = "demo"
25+
required-features = ["feat"]
26+
"#,
27+
)
28+
.file("src/main.rs", "fn main() {}")
29+
.file("examples/demo.rs", "fn main() {}")
30+
.build();
31+
32+
p.cargo("fetch --target=x86_64-unknown-linux-gnu").run();
33+
p.cargo("test --target=x86_64-unknown-linux-gnu --frozen")
34+
.run();
35+
}

0 commit comments

Comments
 (0)