Remove reliance on wat2wasm in interpreter tests (#1893)

Move usage to the `wat` crate instead.
This commit is contained in:
Alex Crichton 2019-12-03 14:09:33 -06:00 committed by GitHub
parent 31f7bd5d86
commit 9469c1641b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 32 deletions

View File

@ -100,6 +100,8 @@ jobs:
displayName: "wasm-bindgen-anyref-xform tests" displayName: "wasm-bindgen-anyref-xform tests"
- script: cargo test -p wasm-bindgen-multi-value-xform - script: cargo test -p wasm-bindgen-multi-value-xform
displayName: "wasm-bindgen-multi-value-xform tests" displayName: "wasm-bindgen-multi-value-xform tests"
- script: cargo test -p wasm-bindgen-wasm-interpreter
displayName: "wasm-bindgen-wasm-interpreter tests"
- job: test_web_sys - job: test_web_sys
displayName: "Run web-sys crate tests" displayName: "Run web-sys crate tests"
@ -158,23 +160,6 @@ jobs:
# - template: ci/azure-install-sccache.yml # - template: ci/azure-install-sccache.yml
- script: cargo test -p wasm-bindgen-macro - script: cargo test -p wasm-bindgen-macro
- job: test_wasm_interpreter
displayName: "Run wasm-bindgen-wasm-interpreter tests"
steps:
- template: ci/azure-install-rust.yml
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: |
git clone https://github.com/WebAssembly/wabt
mkdir -p wabt/build
cd wabt/build
# Temporarily disable sccache because it is failing on CI.
# cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=off -DCMAKE_CXX_COMPILER_LAUNCHER=$RUSTC_WRAPPER
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=off
cmake --build . -- -j$(nproc)
echo "##vso[task.prependpath]$PWD"
- script: cargo test -p wasm-bindgen-wasm-interpreter
- job: test_typescript_output - job: test_typescript_output
displayName: "Test TypeScript output of wasm-bindgen" displayName: "Test TypeScript output of wasm-bindgen"
steps: steps:

View File

@ -18,3 +18,4 @@ walrus = "0.14.0"
[dev-dependencies] [dev-dependencies]
tempfile = "3" tempfile = "3"
wat = "1.0"

View File

@ -1,21 +1,8 @@
use std::fs;
use std::process::Command;
use wasm_bindgen_wasm_interpreter::Interpreter; use wasm_bindgen_wasm_interpreter::Interpreter;
fn interpret(wat: &str, name: &str, result: Option<&[u32]>) { fn interpret(wat: &str, name: &str, result: Option<&[u32]>) {
let input = tempfile::NamedTempFile::new().unwrap(); let wasm = wat::parse_str(wat).unwrap();
let output = tempfile::NamedTempFile::new().unwrap(); let module = walrus::Module::from_buffer(&wasm).unwrap();
fs::write(input.path(), wat).unwrap();
let status = Command::new("wat2wasm")
.arg(input.path())
.arg("-o")
.arg(output.path())
.status()
.unwrap();
println!("status: {}", status);
assert!(status.success());
let module = walrus::Module::from_file(output.path()).unwrap();
let mut i = Interpreter::new(&module).unwrap(); let mut i = Interpreter::new(&module).unwrap();
let id = module let id = module
.exports .exports