Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion bins/revme/src/cmd/statetest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod merkle_trie;
mod runner;
pub mod utils;

pub use runner::TestError as Error;
pub use runner::{TestError as Error, TestErrorKind};

use clap::Parser;
use runner::{find_all_json_tests, run, TestError};
Expand Down Expand Up @@ -42,8 +42,25 @@ impl Cmd {
/// Runs `statetest` command.
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,
Expand Down
4 changes: 4 additions & 0 deletions bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ pub enum TestErrorKind {
SerdeDeserialize(#[from] serde_json::Error),
#[error("thread panicked")]
Panic,
#[error("path does not exist")]
InvalidPath,
#[error("no JSON test files found in path")]
NoJsonFiles,
}

pub fn find_all_json_tests(path: &Path) -> Vec<PathBuf> {
Expand Down
Loading