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