File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ pub mod merkle_trie;
2
2
mod runner;
3
3
pub mod utils;
4
4
5
- pub use runner:: TestError as Error ;
5
+ pub use runner:: { TestError as Error , TestErrorKind } ;
6
6
7
7
use clap:: Parser ;
8
8
use runner:: { find_all_json_tests, run, TestError } ;
@@ -42,8 +42,25 @@ impl Cmd {
42
42
/// Runs `statetest` command.
43
43
pub fn run ( & self ) -> Result < ( ) , TestError > {
44
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
+
45
53
println ! ( "\n Running tests in {}..." , path. display( ) ) ;
46
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
+
47
64
run (
48
65
test_files,
49
66
self . single_thread ,
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ pub enum TestErrorKind {
66
66
SerdeDeserialize ( #[ from] serde_json:: Error ) ,
67
67
#[ error( "thread panicked" ) ]
68
68
Panic ,
69
+ #[ error( "path does not exist" ) ]
70
+ InvalidPath ,
71
+ #[ error( "no JSON test files found in path" ) ]
72
+ NoJsonFiles ,
69
73
}
70
74
71
75
pub fn find_all_json_tests ( path : & Path ) -> Vec < PathBuf > {
You can’t perform that action at this time.
0 commit comments