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)]
39 omit_progress: bool,
40 #[arg(long, alias = "no-fail-fast")]
42 keep_going: bool,
43}
44
45impl Cmd {
46 pub fn run(&self) -> Result<(), TestError> {
48 for path in &self.paths {
49 if !path.exists() {
50 return Err(TestError {
51 name: "Path validation".to_string(),
52 path: path.display().to_string(),
53 kind: TestErrorKind::InvalidPath,
54 });
55 }
56
57 println!("\nRunning tests in {}...", path.display());
58 let test_files = find_all_json_tests(path);
59
60 if test_files.is_empty() {
61 return Err(TestError {
62 name: "Path validation".to_string(),
63 path: path.display().to_string(),
64 kind: TestErrorKind::NoJsonFiles,
65 });
66 }
67
68 run(
69 test_files,
70 self.single_thread,
71 self.json,
72 self.json_outcome,
73 self.keep_going,
74 self.omit_progress,
75 )?
76 }
77 Ok(())
78 }
79}