From eae7fc786f88b24843cad92216386176c2354fcb Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Mon, 30 Jul 2018 08:34:58 +0000 Subject: [PATCH] bump wabt version to 0.4 It has some interface changes. --- Cargo.toml | 2 +- tests/spec/run.rs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d16c28f..6e2391f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,4 +18,4 @@ nan-preserving-float = "0.1.0" [dev-dependencies] assert_matches = "1.1" -wabt = "0.3" +wabt = "0.4" diff --git a/tests/spec/run.rs b/tests/spec/run.rs index 80d312f..a45d72b 100644 --- a/tests/spec/run.rs +++ b/tests/spec/run.rs @@ -1,5 +1,6 @@ #![cfg(test)] +use std::fs::File; use std::collections::HashMap; use wabt::script::{self, Action, Command, CommandKind, ScriptParser, Value}; @@ -340,7 +341,13 @@ pub fn spec(name: &str) { fn try_spec(name: &str) -> Result<(), Error> { let mut spec_driver = SpecDriver::new(); let spec_script_path = format!("tests/spec/testsuite/{}.wast", name); - let mut parser = ScriptParser::from_file(spec_script_path).expect("Can't read spec script"); + + use std::io::Read; + let mut spec_source = Vec::new(); + let mut spec_file = File::open(&spec_script_path).expect("Can't open the file"); + spec_file.read_to_end(&mut spec_source).expect("Can't read file"); + + let mut parser = ScriptParser::from_source_and_name(&spec_source, &format!("{}.wast", name)).expect("Can't read spec script"); let mut errors = vec![]; while let Some(Command { kind, line }) = parser.next()? { @@ -364,7 +371,7 @@ fn try_spec(name: &str) -> Result<(), Error> { match kind { CommandKind::Module { name, module, .. } => { - load_module(&module.into_vec()?, &name, &mut spec_driver) + load_module(&module.into_vec(), &name, &mut spec_driver) .expect("Failed to load module"); } CommandKind::AssertReturn { action, expected } => { @@ -446,14 +453,14 @@ fn try_spec(name: &str) -> Result<(), Error> { CommandKind::AssertInvalid { module, .. } | CommandKind::AssertMalformed { module, .. } | CommandKind::AssertUnlinkable { module, .. } => { - let module_load = try_load(&module.into_vec()?, &mut spec_driver); + let module_load = try_load(&module.into_vec(), &mut spec_driver); match module_load { Ok(_) => panic!("Expected invalid module definition, got some module!"), Err(_e) => {}, } } CommandKind::AssertUninstantiable { module, .. } => { - match try_load(&module.into_vec()?, &mut spec_driver) { + match try_load(&module.into_vec(), &mut spec_driver) { Ok(_) => panic!("Expected error running start function at line {}", line), Err(_e) => {}, }