1pub mod merkle_trie;
2mod runner;
3pub mod utils;
4
5pub use runner::{TestError as Error, TestErrorKind};
6
7use crate::dir_utils::find_all_json_tests;
8use clap::Parser;
9use runner::{run, TestError};
10use std::path::PathBuf;
11
12#[derive(Parser, Debug)]
14pub struct Cmd {
15 #[arg(required = true, num_args = 1..)]
21 paths: Vec<PathBuf>,
22 #[arg(short = 's', long)]
24 single_thread: bool,
25 #[arg(long)]
29 json: bool,
30 #[arg(short = 'o', long)]
36 json_outcome: bool,
37 #[arg(long, alias = "no-fail-fast")]
39 keep_going: bool,
40}
41
42impl Cmd {
43 pub fn run(&self) -> Result<(), TestError> {
45 for path in &self.paths {
46 if !path.exists() {
47 return Err(TestError {
48 name: "Path validation".to_string(),
49 path: path.display().to_string(),
50 kind: TestErrorKind::InvalidPath,
51 });
52 }
53
54 println!("\nRunning tests in {}...", path.display());
55 let test_files = find_all_json_tests(path);
56
57 if test_files.is_empty() {
58 return Err(TestError {
59 name: "Path validation".to_string(),
60 path: path.display().to_string(),
61 kind: TestErrorKind::NoJsonFiles,
62 });
63 }
64
65 run(
66 test_files,
67 self.single_thread,
68 self.json,
69 self.json_outcome,
70 self.keep_going,
71 )?
72 }
73 Ok(())
74 }
75}