pub mod merkle_trie;
mod runner;
pub mod utils;
pub use runner::{TestError as Error, TestErrorKind};
use crate::dir_utils::find_all_json_tests;
use clap::Parser;
use runner::{run, TestError};
use std::path::PathBuf;
#[derive(Parser, Debug)]
pub struct Cmd {
#[arg(required = true, num_args = 1..)]
paths: Vec<PathBuf>,
#[arg(short = 's', long)]
single_thread: bool,
#[arg(long)]
json: bool,
#[arg(short = 'o', long)]
json_outcome: bool,
#[arg(long)]
omit_progress: bool,
#[arg(long, alias = "no-fail-fast")]
keep_going: bool,
}
impl Cmd {
pub fn run(&self) -> Result<(), TestError> {
for path in &self.paths {
if !path.exists() {
return Err(TestError {
name: "Path validation".to_string(),
path: path.display().to_string(),
kind: TestErrorKind::InvalidPath,
});
}
println!("\nRunning tests in {}...", path.display());
let test_files = find_all_json_tests(path);
if test_files.is_empty() {
return Err(TestError {
name: "Path validation".to_string(),
path: path.display().to_string(),
kind: TestErrorKind::NoJsonFiles,
});
}
run(
test_files,
self.single_thread,
self.json,
self.json_outcome,
self.keep_going,
self.omit_progress,
)?
}
Ok(())
}
}