Skip to content

Commit

Permalink
Make testsuite green
Browse files Browse the repository at this point in the history
Backdate the testsuite submodule to the most recent commit that passes
all tests. The failing tests are due to the comment.wast test, which is
not yet implemented in wasmparser crate.
  • Loading branch information
kateinoigakukun committed Nov 21, 2023
1 parent c2505f1 commit 731833b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 23 additions & 6 deletions crates/wast-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,30 @@ impl WastContext {
}

pub fn run_buffer(&mut self, filename: &str, wast: &[u8]) -> Result<()> {
use wast::WastDirective::*;

let wast = str::from_utf8(wast)?;

let adjust_wast = |mut err: wast::Error| {
err.set_path(filename.as_ref());
err.set_text(wast);
err
};

let mut lexer = wast::lexer::Lexer::new(wast);
lexer.allow_confusing_unicode(filename.ends_with("names.wast"));
let buf = wast::parser::ParseBuffer::new_with_lexer(lexer).map_err(adjust_wast)?;
let ast = wast::parser::parse::<wast::Wast>(&buf).map_err(adjust_wast)?;

self.run_directives(ast.directives, filename, wast)
}

fn run_directives(
&mut self,
directives: Vec<wast::WastDirective<'_>>,
filename: &str,
wast: &str,
) -> Result<()> {
use wast::WastDirective::*;

let adjust_wast = |mut err: wast::Error| {
err.set_path(filename.as_ref());
err.set_text(wast);
Expand All @@ -91,10 +111,7 @@ impl WastContext {
format!("for directive on {}:{}:{}", filename, line + 1, col)
};

let buf = wast::parser::ParseBuffer::new(wast).map_err(adjust_wast)?;
let wast = wast::parser::parse::<wast::Wast>(&buf).map_err(adjust_wast)?;

for directive in wast.directives {
for directive in directives {
match directive {
Register {
span: _,
Expand Down

0 comments on commit 731833b

Please sign in to comment.