diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..f9cf57cd97 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/wast/spec_testsuite"] + path = lib/wast/spec_testsuite + url = https://github.com/WebAssembly/testsuite diff --git a/lib/wast/build.rs b/lib/wast/build.rs index b3116440af..ba2a39e18f 100644 --- a/lib/wast/build.rs +++ b/lib/wast/build.rs @@ -9,44 +9,63 @@ fn main() { let mut out = File::create(out_dir.join("run_wast_files.rs")).expect("error creating run_wast_files.rs"); - let mut paths: Vec<_> = read_dir("spec_testsuite") + test_directory(&mut out, "misc_testsuite"); + test_directory(&mut out, "spec_testsuite"); +} + +fn test_directory(out: &mut File, testsuite: &str) { + let mut dir_entries: Vec<_> = read_dir(testsuite) .unwrap() .map(|r| r.unwrap()) - .filter(|p| { - // Ignore files starting with `.`, which could be editor temporary files - if let Some(stem) = p.path().file_stem() { - if let Some(stemstr) = stem.to_str() { - return !stemstr.starts_with('.'); + .filter(|dir_entry| { + let p = dir_entry.path(); + if let Some(ext) = p.extension() { + // Only look at wast files. + if ext == "wast" { + // Ignore files starting with `.`, which could be editor temporary files + if let Some(stem) = p.file_stem() { + if let Some(stemstr) = stem.to_str() { + if !stemstr.starts_with('.') { + return true; + } + } + } } } false }).collect(); - paths.sort_by_key(|dir| dir.path()); - for path in paths { - let path = path.path(); - writeln!(out, "#[test]"); + dir_entries.sort_by_key(|dir| dir.path()); + + writeln!(out, "mod {} {{", testsuite); + writeln!(out, " use super::{{native_isa, wast_file, Path}};"); + for dir_entry in dir_entries { + let path = dir_entry.path(); + let stemstr = path + .file_stem() + .expect("file_stem") + .to_str() + .expect("to_str"); + + writeln!(out, " #[test]"); + if ignore(testsuite, stemstr) { + writeln!(out, " #[ignore]"); + } writeln!( out, - "fn {}() {{", - avoid_keywords( - &path - .file_stem() - .expect("file_stem") - .to_str() - .expect("to_str") - .replace("-", "_") - ) + " fn {}() {{", + avoid_keywords(&stemstr.replace("-", "_")) ); writeln!( out, - " wast_file(Path::new(\"{}\"), &*native_isa()).expect(\"error loading wast file {}\");", + " wast_file(Path::new(\"{}\"), &*native_isa()).expect(\"error loading wast file {}\");", path.display(), path.display() ); - writeln!(out, "}}"); + writeln!(out, " }}"); writeln!(out); } + writeln!(out, "}}"); } fn avoid_keywords(name: &str) -> &str { @@ -59,3 +78,15 @@ fn avoid_keywords(name: &str) -> &str { other => other, } } + +fn ignore(testsuite: &str, name: &str) -> bool { + match testsuite { + "spec_testsuite" => match name { + // These are the remaining spec testsuite failures. + "call_indirect" | "data" | "elem" | "exports" | "func" | "func_ptrs" | "globals" + | "imports" | "linking" | "names" | "start" => true, + _ => false, + }, + _ => false, + } +} diff --git a/lib/wast/spec_testsuite b/lib/wast/spec_testsuite new file mode 160000 index 0000000000..b2800641d6 --- /dev/null +++ b/lib/wast/spec_testsuite @@ -0,0 +1 @@ +Subproject commit b2800641d6c6b6a0c462f83e620843c414bea579