Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow bolero tests to run on wasm32-unknown-unknown #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/bolero/src/test/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use bolero_generator::{driver, TypeGenerator};
use rand::{rngs::StdRng, SeedableRng};
use std::{io::Read, path::PathBuf};

#[cfg_attr(target_os = "unknown", allow(dead_code))]
pub enum TestInput {
FileTest(FileTest),
RngTest(RngTest),
Expand All @@ -19,6 +20,7 @@ impl TestInput {
}
}

#[cfg_attr(target_os = "unknown", allow(dead_code))]
pub struct FileTest {
pub path: PathBuf,
}
Expand Down
14 changes: 10 additions & 4 deletions lib/bolero/src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use bolero_engine::{driver, rng, test_failure::TestFailure, Engine, TargetLocation, Test};
use core::iter::empty;
use std::path::PathBuf;

mod input;
use input::*;
Expand All @@ -14,6 +13,7 @@ mod report;
/// harness. By default, the test inputs will include any present
/// `corpus` and `crashes` files, as well as generating
#[derive(Debug)]
#[cfg_attr(target_os = "unknown", allow(dead_code))]
pub struct TestEngine {
location: TargetLocation,
rng_cfg: rng::Options,
Expand Down Expand Up @@ -43,7 +43,8 @@ impl TestEngine {
self
}

fn sub_dir<'a, D: Iterator<Item = &'a str>>(&self, dirs: D) -> PathBuf {
#[cfg(not(target_os = "unknown"))]
fn sub_dir<'a, D: Iterator<Item = &'a str>>(&self, dirs: D) -> std::path::PathBuf {
let mut fuzz_target_path = self
.location
.work_dir()
Expand All @@ -54,11 +55,13 @@ impl TestEngine {
fuzz_target_path
}

#[cfg_attr(target_os = "unknown", allow(unused_variables))]
fn file_tests<'a, D: Iterator<Item = &'a str> + std::panic::UnwindSafe>(
&self,
sub_dirs: D,
) -> impl Iterator<Item = NamedTest> {
std::fs::read_dir(self.sub_dir(sub_dirs))
#[cfg(not(target_os = "unknown"))]
let res = std::fs::read_dir(self.sub_dir(sub_dirs))
.ok()
.into_iter()
.flat_map(move |dir| {
Expand All @@ -70,7 +73,10 @@ impl TestEngine {
name: format!("{}", path.display()),
data: TestInput::FileTest(FileTest { path }),
})
})
});
#[cfg(target_os = "unknown")]
let res = std::iter::empty();
res
}

fn rng_tests(&self) -> impl Iterator<Item = RngTest> {
Expand Down
Loading