Skip to content

Commit f4e329f

Browse files
committed
Make compiletest set cwd before running js tests
1 parent 5803f99 commit f4e329f

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/librustc_back/target/wasm32_unknown_emscripten.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub fn target() -> Result<Target, String> {
1818
vec!["-s".to_string(),
1919
"BINARYEN=1".to_string(),
2020
"-s".to_string(),
21+
"BINARYEN_METHOD='native-wasm,interpret-binary'".to_string(),
22+
"-s".to_string(),
2123
"ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]);
2224

2325
let opts = TargetOptions {

src/tools/compiletest/src/procsrv.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ pub fn run(lib_path: &str,
5353
aux_path: Option<&str>,
5454
args: &[String],
5555
env: Vec<(String, String)>,
56-
input: Option<String>)
56+
input: Option<String>,
57+
current_dir: Option<String>)
5758
-> io::Result<Result> {
5859

5960
let mut cmd = Command::new(prog);
@@ -66,6 +67,9 @@ pub fn run(lib_path: &str,
6667
for (key, val) in env {
6768
cmd.env(&key, &val);
6869
}
70+
if let Some(cwd) = current_dir {
71+
cmd.current_dir(cwd);
72+
}
6973

7074
let mut process = cmd.spawn()?;
7175
if let Some(input) = input {
@@ -85,7 +89,8 @@ pub fn run_background(lib_path: &str,
8589
aux_path: Option<&str>,
8690
args: &[String],
8791
env: Vec<(String, String)>,
88-
input: Option<String>)
92+
input: Option<String>,
93+
current_dir: Option<String>)
8994
-> io::Result<Child> {
9095

9196
let mut cmd = Command::new(prog);
@@ -96,6 +101,9 @@ pub fn run_background(lib_path: &str,
96101
for (key, val) in env {
97102
cmd.env(&key, &val);
98103
}
104+
if let Some(cwd) = current_dir {
105+
cmd.current_dir(cwd);
106+
}
99107

100108
let mut process = cmd.spawn()?;
101109
if let Some(input) = input {

src/tools/compiletest/src/runtest.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ actual:\n\
509509
self.config.adb_test_dir.clone()
510510
],
511511
Vec::new(),
512+
None,
512513
None)
513514
.expect(&format!("failed to exec `{:?}`", self.config.adb_path));
514515

@@ -521,6 +522,7 @@ actual:\n\
521522
"tcp:5039".to_owned()
522523
],
523524
Vec::new(),
525+
None,
524526
None)
525527
.expect(&format!("failed to exec `{:?}`", self.config.adb_path));
526528

@@ -543,6 +545,7 @@ actual:\n\
543545
adb_arg.clone()
544546
],
545547
Vec::new(),
548+
None,
546549
None)
547550
.expect(&format!("failed to exec `{:?}`", self.config.adb_path));
548551

@@ -579,6 +582,7 @@ actual:\n\
579582
None,
580583
&debugger_opts,
581584
Vec::new(),
585+
None,
582586
None)
583587
.expect(&format!("failed to exec `{:?}`", gdb_path));
584588
let cmdline = {
@@ -1542,6 +1546,12 @@ actual:\n\
15421546
logv(self.config, format!("executing {}", cmdline));
15431547
cmdline
15441548
};
1549+
let working_dir = if self.config.target.contains("emscripten") {
1550+
Some(self.output_base_name().parent().unwrap().to_str().unwrap().to_owned())
1551+
} else {
1552+
None
1553+
};
1554+
15451555
let procsrv::Result {
15461556
out,
15471557
err,
@@ -1551,7 +1561,8 @@ actual:\n\
15511561
aux_path,
15521562
&args,
15531563
env,
1554-
input).expect(&format!("failed to exec `{}`", prog));
1564+
input,
1565+
working_dir).expect(&format!("failed to exec `{}`", prog));
15551566
self.dump_output(&out, &err);
15561567
ProcRes {
15571568
status: status,

0 commit comments

Comments
 (0)