From 5c86c1c7536054d5c156c81eccbbf3a7e0ab5e52 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Tue, 31 Jul 2018 00:43:18 +0800 Subject: [PATCH] Bump wabt's version to 0.4 and add two more test cases (#114) * bump wabt version to 0.4 It has some interface changes. * bump up testsuite and add two more test cases * use the same expect string --- Cargo.toml | 2 +- tests/spec/mod.rs | 2 ++ tests/spec/run.rs | 15 +++++++++++---- tests/spec/testsuite | 2 +- 4 files changed, 15 insertions(+), 6 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/mod.rs b/tests/spec/mod.rs index 33c68b5..856b26b 100644 --- a/tests/spec/mod.rs +++ b/tests/spec/mod.rs @@ -22,7 +22,9 @@ run_test!("call_indirect", wasm_call_indirect); run_test!("comments", wasm_comments); run_test!("const", wasm_const); run_test!("conversions", wasm_conversions); +run_test!("custom", wasm_custom); run_test!("custom_section", wasm_custom_section); +run_test!("data", wasm_data); run_test!("elem", wasm_elem); run_test!("endianness", wasm_endianness); run_test!("exports", wasm_exports); diff --git a/tests/spec/run.rs b/tests/spec/run.rs index 80d312f..3f69cd8 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 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) => {}, } diff --git a/tests/spec/testsuite b/tests/spec/testsuite index c538faa..c6a690f 160000 --- a/tests/spec/testsuite +++ b/tests/spec/testsuite @@ -1 +1 @@ -Subproject commit c538faa43217146f458b9bc2d4b704d0a4d80963 +Subproject commit c6a690f89a0dda3c79700aa6377d8b5d8a970eba