Skip to content

Commit

Permalink
Attempt to fix the run_with_library_paths test for Windows.
Browse files Browse the repository at this point in the history
I was just pasting the build directories into Rust string literals, so Windows
paths with backslashes were being interpreted as having unknown string
escapes. Raw string guards should fix this for all but the most pathological
of build directories.
  • Loading branch information
pkgw committed Feb 7, 2017
1 parent 8913382 commit d545a9f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ fn run_with_library_paths() {
// Only link search directories within the target output directory are
// propagated through to dylib_path_envvar() (see #3366).
let mut dir1 = p.target_debug_dir();
dir1.push("foo");
dir1.push("foo\\backslash");

let mut dir2 = p.target_debug_dir();
dir2.push("dir=containing=equal=signs");
Expand All @@ -614,20 +614,20 @@ fn run_with_library_paths() {
authors = []
build = "build.rs"
"#)
.file("build.rs", &format!(r#"
.file("build.rs", &format!(r##"
fn main() {{
println!("cargo:rustc-link-search=native={}");
println!("cargo:rustc-link-search={}");
println!(r#"cargo:rustc-link-search=native={}"#);
println!(r#"cargo:rustc-link-search={}"#);
}}
"#, dir1.display(), dir2.display()))
.file("src/main.rs", &format!(r#"
"##, dir1.display(), dir2.display()))
.file("src/main.rs", &format!(r##"
fn main() {{
let search_path = std::env::var_os("{}").unwrap();
let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
assert!(paths.contains(&"{}".into()));
assert!(paths.contains(&"{}".into()));
assert!(paths.contains(&r#"{}"#.into()));
assert!(paths.contains(&r#"{}"#.into()));
}}
"#, dylib_path_envvar(), dir1.display(), dir2.display()));
"##, dylib_path_envvar(), dir1.display(), dir2.display()));

assert_that(p.cargo_process("run"), execs().with_status(0));
}
Expand Down

0 comments on commit d545a9f

Please sign in to comment.