Add a spec testsuite submodule.
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "lib/wast/spec_testsuite"]
|
||||
path = lib/wast/spec_testsuite
|
||||
url = https://github.com/WebAssembly/testsuite
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
1
lib/wast/spec_testsuite
Submodule
1
lib/wast/spec_testsuite
Submodule
Submodule lib/wast/spec_testsuite added at b2800641d6
Reference in New Issue
Block a user