* Remove the need for `HostRef<Store>` This commit goes through the public API of the `wasmtime` crate and removes the need for `HostRef<Store>`, as discussed in #708. This commit is accompanied with a few changes: * The `Store` type now also implements `Default`, creating a new `Engine` with default settings and returning that. * The `Store` type now implements `Clone`, and is documented as being a "cheap clone" aka being reference counted. As before there is no supported way to create a deep clone of a `Store`. * All APIs take/return `&Store` or `Store` instead of `HostRef<Store>`, and `HostRef<T>` is left as purely a detail of the C API. * The `global_exports` function is tagged as `#[doc(hidden)]` for now while we await its removal. * The `Store` type is not yet `Send` nor `Sync` due to the usage of `global_exports`, but it is intended to become so eventually. * Touch up comments on some examples * Run rustfmt
24 lines
847 B
Rust
24 lines
847 B
Rust
use std::path::Path;
|
|
use wasmtime::{Config, Engine, Store, Strategy};
|
|
use wasmtime_wast::WastContext;
|
|
|
|
include!(concat!(env!("OUT_DIR"), "/wast_testsuite_tests.rs"));
|
|
|
|
// Each of the tests included from `wast_testsuite_tests` will call this
|
|
// function which actually executes the `wast` test suite given the `strategy`
|
|
// to compile it.
|
|
fn run_wast(wast: &str, strategy: Strategy) -> anyhow::Result<()> {
|
|
let wast = Path::new(wast);
|
|
|
|
let mut cfg = Config::new();
|
|
cfg.wasm_simd(wast.iter().any(|s| s == "simd"))
|
|
.wasm_multi_value(wast.iter().any(|s| s == "multi-value"))
|
|
.strategy(strategy)?
|
|
.cranelift_debug_verifier(true);
|
|
let store = Store::new(&Engine::new(&cfg));
|
|
let mut wast_context = WastContext::new(store);
|
|
wast_context.register_spectest()?;
|
|
wast_context.run_file(wast)?;
|
|
Ok(())
|
|
}
|