From f4e329f178a9da9ae4cf844597bfd2261a365ad4 Mon Sep 17 00:00:00 2001 From: Richard Dodd Date: Wed, 17 May 2017 16:15:28 +0100 Subject: [PATCH] Make compiletest set cwd before running js tests --- .../target/wasm32_unknown_emscripten.rs | 2 ++ src/tools/compiletest/src/procsrv.rs | 12 ++++++++++-- src/tools/compiletest/src/runtest.rs | 13 ++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/librustc_back/target/wasm32_unknown_emscripten.rs b/src/librustc_back/target/wasm32_unknown_emscripten.rs index f5fb63038e91..c44095df4001 100644 --- a/src/librustc_back/target/wasm32_unknown_emscripten.rs +++ b/src/librustc_back/target/wasm32_unknown_emscripten.rs @@ -18,6 +18,8 @@ pub fn target() -> Result { vec!["-s".to_string(), "BINARYEN=1".to_string(), "-s".to_string(), + "BINARYEN_METHOD='native-wasm,interpret-binary'".to_string(), + "-s".to_string(), "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]); let opts = TargetOptions { diff --git a/src/tools/compiletest/src/procsrv.rs b/src/tools/compiletest/src/procsrv.rs index 35f6ed243fec..0ad52de6175a 100644 --- a/src/tools/compiletest/src/procsrv.rs +++ b/src/tools/compiletest/src/procsrv.rs @@ -53,7 +53,8 @@ pub fn run(lib_path: &str, aux_path: Option<&str>, args: &[String], env: Vec<(String, String)>, - input: Option) + input: Option, + current_dir: Option) -> io::Result { let mut cmd = Command::new(prog); @@ -66,6 +67,9 @@ pub fn run(lib_path: &str, for (key, val) in env { cmd.env(&key, &val); } + if let Some(cwd) = current_dir { + cmd.current_dir(cwd); + } let mut process = cmd.spawn()?; if let Some(input) = input { @@ -85,7 +89,8 @@ pub fn run_background(lib_path: &str, aux_path: Option<&str>, args: &[String], env: Vec<(String, String)>, - input: Option) + input: Option, + current_dir: Option) -> io::Result { let mut cmd = Command::new(prog); @@ -96,6 +101,9 @@ pub fn run_background(lib_path: &str, for (key, val) in env { cmd.env(&key, &val); } + if let Some(cwd) = current_dir { + cmd.current_dir(cwd); + } let mut process = cmd.spawn()?; if let Some(input) = input { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 45a733d411ab..0664525221fd 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -509,6 +509,7 @@ actual:\n\ self.config.adb_test_dir.clone() ], Vec::new(), + None, None) .expect(&format!("failed to exec `{:?}`", self.config.adb_path)); @@ -521,6 +522,7 @@ actual:\n\ "tcp:5039".to_owned() ], Vec::new(), + None, None) .expect(&format!("failed to exec `{:?}`", self.config.adb_path)); @@ -543,6 +545,7 @@ actual:\n\ adb_arg.clone() ], Vec::new(), + None, None) .expect(&format!("failed to exec `{:?}`", self.config.adb_path)); @@ -579,6 +582,7 @@ actual:\n\ None, &debugger_opts, Vec::new(), + None, None) .expect(&format!("failed to exec `{:?}`", gdb_path)); let cmdline = { @@ -1542,6 +1546,12 @@ actual:\n\ logv(self.config, format!("executing {}", cmdline)); cmdline }; + let working_dir = if self.config.target.contains("emscripten") { + Some(self.output_base_name().parent().unwrap().to_str().unwrap().to_owned()) + } else { + None + }; + let procsrv::Result { out, err, @@ -1551,7 +1561,8 @@ actual:\n\ aux_path, &args, env, - input).expect(&format!("failed to exec `{}`", prog)); + input, + working_dir).expect(&format!("failed to exec `{}`", prog)); self.dump_output(&out, &err); ProcRes { status: status,