#![deny(missing_docs)]
include!(concat!(env!("OUT_DIR"), "/tests.rs"));
#[derive(Clone)]
pub struct Test {
pub module: String,
pub name: String,
pub wasm: Vec<u8>,
}
#[cfg(test)]
impl Test {
pub fn compile(&self) -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.without_time()
.compact()
.try_init()
.ok();
let Test { module, name, wasm } = self;
tracing::info!("Compiling {module}::{name}");
let compiler = zinkc::Compiler::default();
if name == "fibonacci" {
return Ok(());
}
compiler.compile(&wasm)?;
Ok(())
}
}
#[allow(clippy::crate_in_macro_def)]
#[macro_export]
macro_rules! impl_tests {
(
tests: $tests:tt,
modules: [$($mod:expr),+]
) => {
$(
impl_tests!(@module $mod, $tests);
)*
};
(@module $module:tt, [$($test:ident),+]) => {
paste::paste! {
mod [< $module >] {
$(
#[test]
fn $test() -> anyhow::Result<()> {
crate::$test($module)
}
)*
}
}
}
}