wasmer_cli/commands/
wast.rs1use std::path::PathBuf;
3
4use anyhow::{Context, Result};
5use clap::Parser;
6use wasmer::{Store, sys::Target};
7use wasmer_wast::Wast as WastSpectest;
8
9use crate::backend::RuntimeOptions;
10
11#[derive(Debug, Parser)]
12pub struct Wast {
14 #[clap(name = "FILE")]
16 path: PathBuf,
17
18 #[clap(flatten)]
19 rt: RuntimeOptions,
20
21 #[clap(short, long)]
22 fail_fast: bool,
24}
25
26impl Wast {
27 pub fn execute(&self) -> Result<()> {
29 self.inner_execute()
30 .context(format!("failed to test the wast `{}`", self.path.display()))
31 }
32 fn inner_execute(&self) -> Result<()> {
33 let engine = self.rt.get_engine(&Target::default())?;
34
35 let store: Store = Store::new(engine);
36 let mut wast = WastSpectest::new_with_spectest(store);
37 wast.fail_fast = self.fail_fast;
38 wast.run_file(&self.path).with_context(|| "tests failed")?;
39 eprintln!("Wast tests succeeded for `{}`.", self.path.display());
40 Ok(())
41 }
42}