use crate::store::StoreOptions;
use anyhow::{Context, Result};
use clap::Parser;
use std::path::PathBuf;
use wasmer_wast::Wast as WastSpectest;
#[derive(Debug, Parser)]
pub struct Wast {
#[clap(name = "FILE")]
path: PathBuf,
#[clap(flatten)]
store: StoreOptions,
#[clap(short, long)]
fail_fast: bool,
}
impl Wast {
pub fn execute(&self) -> Result<()> {
self.inner_execute()
.context(format!("failed to test the wast `{}`", self.path.display()))
}
fn inner_execute(&self) -> Result<()> {
let (store, _compiler_name) = self.store.get_store()?;
let mut wast = WastSpectest::new_with_spectest(store);
wast.fail_fast = self.fail_fast;
wast.run_file(&self.path).with_context(|| "tests failed")?;
eprintln!("Wast tests succeeded for `{}`.", self.path.display());
Ok(())
}
}