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,34 +9,52 @@ fn main() {
|
|||||||
let mut out =
|
let mut out =
|
||||||
File::create(out_dir.join("run_wast_files.rs")).expect("error creating run_wast_files.rs");
|
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()
|
.unwrap()
|
||||||
.map(|r| r.unwrap())
|
.map(|r| r.unwrap())
|
||||||
.filter(|p| {
|
.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
|
// Ignore files starting with `.`, which could be editor temporary files
|
||||||
if let Some(stem) = p.path().file_stem() {
|
if let Some(stem) = p.file_stem() {
|
||||||
if let Some(stemstr) = stem.to_str() {
|
if let Some(stemstr) = stem.to_str() {
|
||||||
return !stemstr.starts_with('.');
|
if !stemstr.starts_with('.') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
paths.sort_by_key(|dir| dir.path());
|
dir_entries.sort_by_key(|dir| dir.path());
|
||||||
for path in paths {
|
|
||||||
let path = path.path();
|
writeln!(out, "mod {} {{", testsuite);
|
||||||
writeln!(out, "#[test]");
|
writeln!(out, " use super::{{native_isa, wast_file, Path}};");
|
||||||
writeln!(
|
for dir_entry in dir_entries {
|
||||||
out,
|
let path = dir_entry.path();
|
||||||
"fn {}() {{",
|
let stemstr = path
|
||||||
avoid_keywords(
|
|
||||||
&path
|
|
||||||
.file_stem()
|
.file_stem()
|
||||||
.expect("file_stem")
|
.expect("file_stem")
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("to_str")
|
.expect("to_str");
|
||||||
.replace("-", "_")
|
|
||||||
)
|
writeln!(out, " #[test]");
|
||||||
|
if ignore(testsuite, stemstr) {
|
||||||
|
writeln!(out, " #[ignore]");
|
||||||
|
}
|
||||||
|
writeln!(
|
||||||
|
out,
|
||||||
|
" fn {}() {{",
|
||||||
|
avoid_keywords(&stemstr.replace("-", "_"))
|
||||||
);
|
);
|
||||||
writeln!(
|
writeln!(
|
||||||
out,
|
out,
|
||||||
@@ -47,6 +65,7 @@ fn main() {
|
|||||||
writeln!(out, " }}");
|
writeln!(out, " }}");
|
||||||
writeln!(out);
|
writeln!(out);
|
||||||
}
|
}
|
||||||
|
writeln!(out, "}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn avoid_keywords(name: &str) -> &str {
|
fn avoid_keywords(name: &str) -> &str {
|
||||||
@@ -59,3 +78,15 @@ fn avoid_keywords(name: &str) -> &str {
|
|||||||
other => other,
|
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