Skip to content

Commit 7afb56f

Browse files
committed
Add emscripten support to compiletest
1 parent bd3fe49 commit 7afb56f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/compiletest/runtest.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,12 @@ fn make_lib_name(config: &Config, auxfile: &Path, testfile: &Path) -> PathBuf {
13571357

13581358
fn make_exe_name(config: &Config, testfile: &Path) -> PathBuf {
13591359
let mut f = output_base_name(config, testfile);
1360-
if !env::consts::EXE_SUFFIX.is_empty() {
1360+
// FIXME: This is using the host architecture exe suffix, not target!
1361+
if config.target == "asmjs-unknown-emscripten" {
1362+
let mut fname = f.file_name().unwrap().to_os_string();
1363+
fname.push(".js");
1364+
f.set_file_name(&fname);
1365+
} else if !env::consts::EXE_SUFFIX.is_empty() {
13611366
let mut fname = f.file_name().unwrap().to_os_string();
13621367
fname.push(env::consts::EXE_SUFFIX);
13631368
f.set_file_name(&fname);
@@ -1370,6 +1375,12 @@ fn make_run_args(config: &Config, props: &TestProps, testfile: &Path)
13701375
// If we've got another tool to run under (valgrind),
13711376
// then split apart its command
13721377
let mut args = split_maybe_args(&config.runtool);
1378+
1379+
// If this is emscripten, then run tests under nodejs
1380+
if config.target == "asmjs-unknown-emscripten" {
1381+
args.push("nodejs".to_owned());
1382+
}
1383+
13731384
let exe_file = make_exe_name(config, testfile);
13741385

13751386
// FIXME (#9639): This needs to handle non-utf8 paths

src/compiletest/util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const OS_TABLE: &'static [(&'static str, &'static str)] = &[
2626
("win32", "windows"),
2727
("windows", "windows"),
2828
("solaris", "solaris"),
29+
("emscripten", "emscripten"),
2930
];
3031

3132
const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
@@ -44,6 +45,7 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[
4445
("sparc", "sparc"),
4546
("x86_64", "x86_64"),
4647
("xcore", "xcore"),
48+
("asmjs", "asmjs"),
4749
];
4850

4951
pub fn get_os(triple: &str) -> &'static str {

0 commit comments

Comments
 (0)