File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33use crate :: prelude:: * ;
44use cargo_test_support:: registry:: { Dependency , Package } ;
5- use cargo_test_support:: str;
65use cargo_test_support:: { basic_manifest, project} ;
6+ use cargo_test_support:: { rustc_host, str} ;
77
88#[ cargo_test]
99fn feature_activates_missing_feature ( ) {
@@ -2368,3 +2368,38 @@ fn invalid_feature_name_slash_error() {
23682368"# ] ] )
23692369 . run ( ) ;
23702370}
2371+
2372+ #[ cargo_test( ignore_windows = "test windows only dependency on unix systems" ) ]
2373+ fn dont_demand_not_required_dep ( ) {
2374+ Package :: new ( "win-only" , "1.0.0" ) . publish ( ) ;
2375+
2376+ let p = project ( )
2377+ . file (
2378+ "Cargo.toml" ,
2379+ r#"
2380+ [package]
2381+ name = "sample"
2382+ version = "0.1.0"
2383+ edition = "2024"
2384+
2385+ [features]
2386+ default = ["feat"]
2387+ feat = ["dep:win-only"]
2388+
2389+ [target.'cfg(windows)'.dependencies]
2390+ win-only = { version = "1.0", optional = true }
2391+
2392+ [[example]]
2393+ name = "demo"
2394+ required-features = ["feat"]
2395+ "# ,
2396+ )
2397+ . file ( "src/main.rs" , "fn main() {}" )
2398+ . file ( "examples/demo.rs" , "fn main() {}" )
2399+ . build ( ) ;
2400+
2401+ let host = rustc_host ( ) ;
2402+ p. cargo ( & format ! ( "fetch --target={host}" ) ) . run ( ) ;
2403+ p. cargo ( & format ! ( "check --target={host} --examples --frozen" ) )
2404+ . run ( ) ;
2405+ }
You can’t perform that action at this time.
0 commit comments