about summary refs log tree commit diff
path: root/src/test/run-make
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-02-28 19:15:40 +0800
committerGitHub <noreply@github.com>2018-02-28 19:15:40 +0800
commit59ab146ec317917d7c71e8947a7ff90d40ee8694 (patch)
tree5a53ef9158a52ce6f317d5d9154cea40ee0f81d8 /src/test/run-make
parent62f4fe5132b4dd06e1b208ee7138ffc050d247e7 (diff)
parent5db73fc6dbf9e4ee1a498655cb609efdf5fa93ed (diff)
downloadrust-59ab146ec317917d7c71e8947a7ff90d40ee8694.tar.gz
rust-59ab146ec317917d7c71e8947a7ff90d40ee8694.zip
Rollup merge of #48548 - alexcrichton:msvc-linker-utf16, r=alexcrichton
Encode linker arguments as UTF-16 on MSVC platforms

This is a forward-port of #48455 to the master branch
Diffstat (limited to 'src/test/run-make')
-rw-r--r--src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs25
-rw-r--r--src/test/run-make/long-linker-command-lines/foo.rs21
2 files changed, 37 insertions, 9 deletions
diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs
index f9168a82e22..67d8ad0b672 100644
--- a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs
+++ b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs
@@ -36,8 +36,11 @@ fn main() {
     let ok = tmpdir.join("ok");
     let not_ok = tmpdir.join("not_ok");
     if env::var("YOU_ARE_A_LINKER").is_ok() {
-        match env::args().find(|a| a.contains("@")) {
-            Some(file) => { fs::copy(&file[1..], &ok).unwrap(); }
+        match env::args_os().find(|a| a.to_string_lossy().contains("@")) {
+            Some(file) => {
+                let file = file.to_str().unwrap();
+                fs::copy(&file[1..], &ok).unwrap();
+            }
             None => { File::create(&not_ok).unwrap(); }
         }
         return
@@ -84,11 +87,23 @@ fn main() {
             continue
         }
 
-        let mut contents = String::new();
-        File::open(&ok).unwrap().read_to_string(&mut contents).unwrap();
+        let mut contents = Vec::new();
+        File::open(&ok).unwrap().read_to_end(&mut contents).unwrap();
 
         for j in 0..i {
-            assert!(contents.contains(&format!("{}{}", lib_name, j)));
+            let exp = format!("{}{}", lib_name, j);
+            let exp = if cfg!(target_env = "msvc") {
+                let mut out = Vec::with_capacity(exp.len() * 2);
+                for c in exp.encode_utf16() {
+                    // encode in little endian
+                    out.push(c as u8);
+                    out.push((c >> 8) as u8);
+                }
+                out
+            } else {
+                exp.into_bytes()
+            };
+            assert!(contents.windows(exp.len()).any(|w| w == &exp[..]));
         }
 
         break
diff --git a/src/test/run-make/long-linker-command-lines/foo.rs b/src/test/run-make/long-linker-command-lines/foo.rs
index e6fd6b65366..2ac240982af 100644
--- a/src/test/run-make/long-linker-command-lines/foo.rs
+++ b/src/test/run-make/long-linker-command-lines/foo.rs
@@ -27,7 +27,8 @@ fn main() {
     let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap());
     let ok = tmpdir.join("ok");
     if env::var("YOU_ARE_A_LINKER").is_ok() {
-        if let Some(file) = env::args().find(|a| a.contains("@")) {
+        if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) {
+            let file = file.to_str().expect("non-utf8 file argument");
             fs::copy(&file[1..], &ok).unwrap();
         }
         return
@@ -76,11 +77,23 @@ fn main() {
             continue
         }
 
-        let mut contents = String::new();
-        File::open(&ok).unwrap().read_to_string(&mut contents).unwrap();
+        let mut contents = Vec::new();
+        File::open(&ok).unwrap().read_to_end(&mut contents).unwrap();
 
         for j in 0..i {
-            assert!(contents.contains(&format!("{}{}", lib_name, j)));
+            let exp = format!("{}{}", lib_name, j);
+            let exp = if cfg!(target_env = "msvc") {
+                let mut out = Vec::with_capacity(exp.len() * 2);
+                for c in exp.encode_utf16() {
+                    // encode in little endian
+                    out.push(c as u8);
+                    out.push((c >> 8) as u8);
+                }
+                out
+            } else {
+                exp.into_bytes()
+            };
+            assert!(contents.windows(exp.len()).any(|w| w == &exp[..]));
         }
 
         break