Skip to content

Commit

Permalink
Update skipping of tests from spec test suite
Browse files Browse the repository at this point in the history
* Enable the `obsolete-keywords.wast` test by removing parsing of
  `anyfunc`.
* Move all tests out of `skip_test` now that everything in the spec
  testsuite submodule can be parsed with `wast`.
* Update the logic in `skip_validation` slightly.
  • Loading branch information
alexcrichton committed Dec 12, 2023
1 parent 64174bb commit 5b96d67
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 55 deletions.
4 changes: 0 additions & 4 deletions crates/wast/src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ impl<'a> Parse<'a> for RefType<'a> {
if l.peek::<kw::funcref>()? {
parser.parse::<kw::funcref>()?;
Ok(RefType::func())
} else if l.peek::<kw::anyfunc>()? {
parser.parse::<kw::anyfunc>()?;
Ok(RefType::func())
} else if l.peek::<kw::externref>()? {
parser.parse::<kw::externref>()?;
Ok(RefType::r#extern())
Expand Down Expand Up @@ -321,7 +318,6 @@ impl<'a> Parse<'a> for RefType<'a> {
impl<'a> Peek for RefType<'a> {
fn peek(cursor: Cursor<'_>) -> Result<bool> {
Ok(kw::funcref::peek(cursor)?
|| /* legacy */ kw::anyfunc::peek(cursor)?
|| kw::externref::peek(cursor)?
|| kw::exnref::peek(cursor)?
|| kw::anyref::peek(cursor)?
Expand Down
1 change: 0 additions & 1 deletion crates/wast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ pub mod kw {
custom_keyword!(after);
custom_keyword!(alias);
custom_keyword!(any);
custom_keyword!(anyfunc);
custom_keyword!(anyref);
custom_keyword!(arg);
custom_keyword!(array);
Expand Down
79 changes: 29 additions & 50 deletions tests/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,64 +136,39 @@ fn find_tests() -> Vec<PathBuf> {
/// Note that this is used to skip tests for all crates, not just one at a
/// time. There's further filters applied while testing.
fn skip_test(test: &Path, contents: &[u8]) -> bool {
let broken = &[
// I don't really have any idea what's going on with the expected syntax
// errors and expected error messages in these tests. They seem like
// they're from left field considering other conventions, so let's just
// ignore these until the proposal is further along.
"exception-handling/try_delegate.wast",
"exception-handling/try_catch.wast",
"exception-handling/throw.wast",
// This is an empty file which currently doesn't parse
"multi-memory/memory_copy1.wast",
];
let test_path = test.to_str().unwrap().replace("\\", "/"); // for windows paths
if broken.iter().any(|x| test_path.contains(x)) {
return true;
}

if let Ok(contents) = str::from_utf8(contents) {
// Skip tests that are supposed to fail
if contents.contains(";; ERROR") {
return true;
}
// These tests are acually ones that run with the `*.wast` files from the
// official test suite, and we slurp those up elsewhere anyway.
if contents.contains("STDIN_FILE") {
return true;
}
}

// currently no tests are skipped
let _ = (test, contents);
false
}

fn skip_validation(test: &Path) -> bool {
let broken = &[
"gc/gc-array.wat",
"gc/gc-struct.wat",
"/proposals/gc/array.wast",
"/proposals/gc/array_copy.wast",
"/proposals/gc/array_fill.wast",
"/proposals/gc/array_init_data.wast",
"/proposals/gc/array_init_elem.wast",
"/proposals/gc/br_on_cast.wast",
"/proposals/gc/br_on_cast_fail.wast",
"/proposals/gc/extern.wast",
"/proposals/gc/ref_cast.wast",
"/proposals/gc/ref_eq.wast",
"/proposals/gc/ref_test.wast",
"/proposals/gc/struct.wast",
"/proposals/gc/type-subtyping.wast",
"/proposals/exception-handling/try_table.wast",
"/proposals/exception-handling/throw_ref.wast",
"/proposals/exception-handling/ref_null.wast",
"/exnref/exnref.wast",
"/exnref/throw_ref.wast",
"/exnref/try_table.wast",
"obsolete-keywords.wast",
"proposals/gc/array.wast",
"proposals/gc/array_copy.wast",
"proposals/gc/array_fill.wast",
"proposals/gc/array_init_data.wast",
"proposals/gc/array_init_elem.wast",
"proposals/gc/br_on_cast.wast",
"proposals/gc/br_on_cast_fail.wast",
"proposals/gc/extern.wast",
"proposals/gc/ref_cast.wast",
"proposals/gc/ref_eq.wast",
"proposals/gc/ref_test.wast",
"proposals/gc/struct.wast",
"proposals/gc/type-subtyping.wast",
"exnref/exnref.wast",
"exnref/throw_ref.wast",
"exnref/try_table.wast",
"exception-handling/ref_null.wast",
"exception-handling/throw.wast",
"exception-handling/throw_ref.wast",
"exception-handling/try_catch.wast",
"exception-handling/try_delegate.wast",
"exception-handling/try_table.wast",
];
let test_path = test.to_str().unwrap().replace("\\", "/"); // for windows paths
if broken.iter().any(|x| test_path.contains(x)) {
if broken.iter().any(|x| test.ends_with(x)) {
return true;
}

Expand Down Expand Up @@ -854,5 +829,9 @@ fn error_matches(error: &str, message: &str) -> bool {
return error.contains("subtype");
}

if message.starts_with("unknown operator") {
return error.starts_with("unknown operator") || error.starts_with("unexpected token");
}

return false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(module
(type (;0;) (func (param i32 i32 i32)))
(type (;1;) (func (param i32) (result i32)))
(func (;0;) (type 0) (param i32 i32 i32)
local.get 0
local.get 1
local.get 2
memory.copy $mem0 $mem3
)
(func (;1;) (type 1) (param i32) (result i32)
local.get 0
i32.load8_u
)
(memory $mem0 (;0;) 1 1)
(memory $mem1 (;1;) 1 1)
(memory $mem2 (;2;) 1 1)
(memory $mem3 (;3;) 1 1)
(export "copy" (func 0))
(export "load8_u" (func 1))
(data (;0;) (i32.const 0) "\ff\11D\ee")
(data (;1;) (memory $mem1) (i32.const 0) "\ee\22U\ff")
(data (;2;) (memory $mem2) (i32.const 0) "\dd3f\00")
(data (;3;) (memory $mem3) (i32.const 0) "\aa\bb\cc\dd")
)

0 comments on commit 5b96d67

Please sign in to comment.