wasmtime_fuzzing/generators/
wast_test.rs

1//! Arbitrarily choose a spec test from the list of known spec tests.
2
3use arbitrary::{Arbitrary, Unstructured};
4
5// See `build.rs` for how the `FILES` array is generated.
6include!(concat!(env!("OUT_DIR"), "/wasttests.rs"));
7
8/// A wast test from this repository.
9#[derive(Debug)]
10pub struct WastTest {
11    #[expect(missing_docs, reason = "self-describing field")]
12    pub test: wasmtime_wast_util::WastTest,
13}
14
15impl<'a> Arbitrary<'a> for WastTest {
16    fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
17        log::debug!("{}", u.is_empty());
18        Ok(WastTest {
19            test: u.choose(FILES)?(),
20        })
21    }
22
23    fn size_hint(_depth: usize) -> (usize, Option<usize>) {
24        (1, Some(std::mem::size_of::<usize>()))
25    }
26}