wasi_test_generator/
main.rs1#[macro_use]
2extern crate serde;
3
4mod set_up_toolchain;
5mod util;
6mod wasi_version;
7mod wasitests;
8
9pub use crate::set_up_toolchain::install_toolchains;
10pub use crate::wasi_version::{
11 ALL_WASI_VERSIONS, LATEST_WASI_VERSION, NIGHTLY_VERSION, WasiVersion,
12};
13pub use crate::wasitests::{WasiOptions, WasiTest, build};
14
15use gumdrop::Options;
16
17#[derive(Debug, Options)]
18pub struct TestGenOptions {
19 #[options(free)]
21 free: Vec<String>,
22 nightly: bool,
24 all_versions: bool,
26 generate_wasm: bool,
28 set_up_toolchain: bool,
30 help: bool,
32}
33
34fn main() {
35 let opts = TestGenOptions::parse_args_default_or_exit();
36
37 if opts.help {
38 println!("{}", TestGenOptions::usage());
39 std::process::exit(0);
40 }
41
42 let generate_all = opts.all_versions;
43 let set_up_toolchain = opts.set_up_toolchain;
44 let generate_wasm = opts.generate_wasm;
45 let nightly = opts.nightly;
46 let wasi_versions = if generate_all {
47 ALL_WASI_VERSIONS
48 } else if nightly {
49 NIGHTLY_VERSION
50 } else {
51 LATEST_WASI_VERSION
52 };
53
54 if set_up_toolchain {
56 install_toolchains(wasi_versions);
57 }
58
59 if generate_wasm {
61 let specific_tests: Vec<&str> = opts.free.iter().map(|st| st.as_str()).collect();
62 build(wasi_versions, &specific_tests);
63 }
64}