revme/cmd/
statetest.rs

1pub mod merkle_trie;
2mod runner;
3pub mod utils;
4
5pub use runner::TestError as Error;
6
7use clap::Parser;
8use runner::{find_all_json_tests, run, TestError};
9use std::path::PathBuf;
10
11/// `statetest` subcommand
12#[derive(Parser, Debug)]
13pub struct Cmd {
14    /// Path to folder or file containing the tests
15    ///
16    /// If multiple paths are specified they will be run in sequence.
17    ///
18    /// Folders will be searched recursively for files with the extension `.json`.
19    #[clap(required = true, num_args = 1..)]
20    paths: Vec<PathBuf>,
21    /// Run tests in a single thread
22    #[clap(short = 's', long)]
23    single_thread: bool,
24    /// Output results in JSON format
25    ///
26    /// It will stop second run of evm on failure.
27    #[clap(long)]
28    json: bool,
29    /// Output outcome in JSON format
30    ///
31    /// If `--json` is true, this is implied.
32    ///
33    /// It will stop second run of EVM on failure.
34    #[clap(short = 'o', long)]
35    json_outcome: bool,
36    /// Keep going after a test failure
37    #[clap(long, alias = "no-fail-fast")]
38    keep_going: bool,
39}
40
41impl Cmd {
42    /// Runs `statetest` command.
43    pub fn run(&self) -> Result<(), TestError> {
44        for path in &self.paths {
45            println!("\nRunning tests in {}...", path.display());
46            let test_files = find_all_json_tests(path);
47            run(
48                test_files,
49                self.single_thread,
50                self.json,
51                self.json_outcome,
52                self.keep_going,
53            )?
54        }
55        Ok(())
56    }
57}