#[macro_use]
extern crate serde;
mod set_up_toolchain;
mod util;
mod wasi_version;
mod wasitests;
pub use crate::set_up_toolchain::install_toolchains;
pub use crate::wasi_version::{
WasiVersion, ALL_WASI_VERSIONS, LATEST_WASI_VERSION, NIGHTLY_VERSION,
};
pub use crate::wasitests::{build, WasiOptions, WasiTest};
use gumdrop::Options;
#[derive(Debug, Options)]
pub struct TestGenOptions {
#[options(free)]
free: Vec<String>,
nightly: bool,
all_versions: bool,
generate_wasm: bool,
set_up_toolchain: bool,
help: bool,
}
fn main() {
let opts = TestGenOptions::parse_args_default_or_exit();
if opts.help {
println!("{}", TestGenOptions::usage());
std::process::exit(0);
}
let generate_all = opts.all_versions;
let set_up_toolchain = opts.set_up_toolchain;
let generate_wasm = opts.generate_wasm;
let nightly = opts.nightly;
let wasi_versions = if generate_all {
ALL_WASI_VERSIONS
} else if nightly {
NIGHTLY_VERSION
} else {
LATEST_WASI_VERSION
};
if set_up_toolchain {
install_toolchains(wasi_versions);
}
if generate_wasm {
let specific_tests: Vec<&str> = opts.free.iter().map(|st| st.as_str()).collect();
build(wasi_versions, &specific_tests);
}
}