File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -2154,6 +2154,57 @@ fn crate_library_path_env_var() {
21542154 setenv_for_removing_empty_component ( p. cargo ( "run" ) ) . run ( ) ;
21552155}
21562156
2157+ // See https://github.com/rust-lang/cargo/issues/14194
2158+ #[ cargo_test]
2159+ fn issue_14194_deduplicate_library_path_env_var ( ) {
2160+ let p = project ( )
2161+ . file (
2162+ "src/main.rs" ,
2163+ & format ! (
2164+ r#"
2165+ use std::process::Command;
2166+ fn main() {{
2167+ let args: Vec<String> = std::env::args().collect();
2168+ if args.len() == 1 {{
2169+ return;
2170+ }}
2171+ let level: i32 = args[1].parse().unwrap();
2172+ if level == 0 {{
2173+ let lib_path = std::env::var("{}").unwrap();
2174+ let paths: Vec<_> = std::env::split_paths(&lib_path).collect();
2175+ if paths.len() > 1 {{
2176+ // The first path will be prepended to the search path in the next run
2177+ let first = &paths[0];
2178+ assert!(paths[1..].contains(&first));
2179+ }}
2180+ return;
2181+ }}
2182+
2183+ let _ = Command::new(std::env!("CARGO"))
2184+ .arg("run")
2185+ .arg("--")
2186+ .arg((level - 1).to_string())
2187+ .status()
2188+ .unwrap();
2189+ }}
2190+ "# ,
2191+ dylib_path_envvar( ) ,
2192+ ) ,
2193+ )
2194+ . build ( ) ;
2195+
2196+ setenv_for_removing_empty_component ( p. cargo ( "run -- 1" ) )
2197+ . with_stderr_data ( str![ [ r#"
2198+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2199+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2200+ [RUNNING] `target/debug/foo 1`
2201+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2202+ [RUNNING] `target/debug/foo 0`
2203+
2204+ "# ] ] )
2205+ . run ( ) ;
2206+ }
2207+
21572208// Regression test for #4277
21582209#[ cargo_test]
21592210fn build_with_fake_libc_not_loading ( ) {
You can’t perform that action at this time.
0 commit comments