File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ mod registry_overlay;
164164mod rename_deps;
165165mod replace;
166166mod required_features;
167+ mod resolve_optional_dependency;
167168mod run;
168169mod rust_version;
169170mod rustc;
Original file line number Diff line number Diff line change 1+ use crate :: prelude:: * ;
2+ use cargo_test_support:: project;
3+
4+ #[ cargo_test( ignore_windows = "test windows only dependency on unix systems" ) ]
5+ fn cargo_test_should_not_demand_not_required_dep ( ) {
6+ let p = project ( )
7+ . file (
8+ "Cargo.toml" ,
9+ r#"
10+ [package]
11+ name = "sample"
12+ version = "0.1.0"
13+ edition = "2024"
14+
15+ [features]
16+ default = ["feat"]
17+ feat = ["dep:ipconfig"]
18+
19+ [target.'cfg(windows)'.dependencies]
20+ ipconfig = { version = "0.3.2", optional = true }
21+
22+ [[example]]
23+ name = "demo"
24+ required-features = ["feat"]
25+ "# ,
26+ )
27+ . file ( "src/main.rs" , "fn main() {}" )
28+ . file ( "examples/demo.rs" , "fn main() {}" )
29+ . build ( ) ;
30+
31+ #[ cfg( all( target_os = "linux" , target_arch = "x86_64" ) ) ]
32+ {
33+ p. cargo ( "fetch --target=x86_64-unknown-linux-gnu" ) . run ( ) ;
34+ p. cargo ( "test --target=x86_64-unknown-linux-gnu --frozen" )
35+ . run ( ) ;
36+ }
37+
38+ #[ cfg( all( target_os = "linux" , target_arch = "aarch64" ) ) ]
39+ {
40+ p. cargo ( "fetch --target=aarch64-unknown-linux-gnu" ) . run ( ) ;
41+ p. cargo ( "test --target=aarch64-unknown-linux-gnu --frozen" )
42+ . run ( ) ;
43+ }
44+
45+ #[ cfg( all( target_os = "macos" , target_arch = "aarch64" ) ) ]
46+ {
47+ p. cargo ( "fetch --target=aarch64-apple-darwin" ) . run ( ) ;
48+ p. cargo ( "test --target=aarch64-apple-darwin --frozen" ) . run ( ) ;
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments