-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new
wit-smith
subcommand (#992)
* Add a new `wit-smith` subcommand This commit extracts the WIT document generation from the `roundtrip-wit` fuzzer into a dedicated crate and a dedicated subcommand, `wasm-tools wit-smith`. This is intended to behave similarly to the `wasm-tools smith` subcommand but it instead generates a WebAssembly binary-encoded WIT document. * Fix build of wit-smith in isolation
- Loading branch information
1 parent
f69b086
commit 95c6bf7
Showing
10 changed files
with
926 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
description = "A WIT test case generator" | ||
documentation = "https://docs.rs/wit-smith" | ||
edition.workspace = true | ||
license = "Apache-2.0 WITH LLVM-exception" | ||
name = "wit-smith" | ||
repository = "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-smith" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
arbitrary = { workspace = true, features = ["derive"] } | ||
wit-component = { workspace = true } | ||
wit-parser = { workspace = true } | ||
clap = { workspace = true, optional = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use arbitrary::{Arbitrary, Result, Unstructured}; | ||
|
||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "clap", derive(clap::Parser))] | ||
pub struct Config { | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_packages))] | ||
pub max_packages: usize, | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_type_size))] | ||
pub max_type_size: usize, | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_interface_items))] | ||
pub max_interface_items: usize, | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_world_items))] | ||
pub max_world_items: usize, | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_doc_items))] | ||
pub max_doc_items: usize, | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_documents))] | ||
pub max_documents: usize, | ||
#[cfg_attr(feature = "clap", clap(long, default_value_t = Config::default().max_type_parts))] | ||
pub max_type_parts: usize, | ||
} | ||
|
||
impl Default for Config { | ||
fn default() -> Config { | ||
Config { | ||
max_packages: 10, | ||
max_type_size: 100, | ||
max_interface_items: 10, | ||
max_world_items: 10, | ||
max_doc_items: 10, | ||
max_documents: 10, | ||
max_type_parts: 10, | ||
} | ||
} | ||
} | ||
|
||
impl Arbitrary<'_> for Config { | ||
fn arbitrary(u: &mut Unstructured<'_>) -> Result<Config> { | ||
Ok(Config { | ||
max_packages: u.int_in_range(1..=20)?, | ||
max_documents: u.int_in_range(1..=10)?, | ||
max_type_size: u.int_in_range(0..=1000)?, | ||
max_interface_items: u.int_in_range(0..=20)?, | ||
max_world_items: u.int_in_range(0..=10)?, | ||
max_doc_items: u.int_in_range(0..=10)?, | ||
max_type_parts: u.int_in_range(1..=10)?, | ||
}) | ||
} | ||
} |
Oops, something went wrong.