@@ -7,6 +7,7 @@ pub struct Config {
77 pub manifest_path : PathBuf ,
88 pub default_target : Option < String > ,
99 pub run_command : Vec < String > ,
10+ pub test_timeout : u64 ,
1011}
1112
1213pub ( crate ) fn read_config ( manifest_path : PathBuf ) -> Result < Config , ErrorString > {
@@ -16,7 +17,7 @@ pub(crate) fn read_config(manifest_path: PathBuf) -> Result<Config, ErrorString>
1617}
1718
1819pub ( crate ) fn read_config_inner ( manifest_path : PathBuf ) -> Result < Config , ErrorString > {
19- use std:: { fs:: File , io:: Read } ;
20+ use std:: { convert :: TryFrom , fs:: File , io:: Read } ;
2021 let cargo_toml: Value = {
2122 let mut content = String :: new ( ) ;
2223 File :: open ( & manifest_path)
@@ -53,6 +54,11 @@ pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorS
5354 for ( key, value) in metadata {
5455 match ( key. as_str ( ) , value. clone ( ) ) {
5556 ( "default-target" , Value :: String ( s) ) => config. default_target = From :: from ( s) ,
57+ ( "test-timeout" , Value :: Integer ( s) ) => {
58+ config. test_timeout = u64:: try_from ( s)
59+ . map_err ( |err| format ! ( "test-timeout is not valid: {}" , err) ) ?
60+ . into ( )
61+ }
5662 ( "run-command" , Value :: Array ( array) ) => {
5763 let mut command = Vec :: new ( ) ;
5864 for value in array {
@@ -78,6 +84,7 @@ struct ConfigBuilder {
7884 manifest_path : Option < PathBuf > ,
7985 default_target : Option < String > ,
8086 run_command : Option < Vec < String > > ,
87+ test_timeout : Option < u64 > ,
8188}
8289
8390impl Into < Config > for ConfigBuilder {
@@ -90,6 +97,7 @@ impl Into<Config> for ConfigBuilder {
9097 "-drive" . into( ) ,
9198 "format=raw,file={}" . into( ) ,
9299 ] ) ,
100+ test_timeout : self . test_timeout . unwrap_or ( 60 * 5 ) ,
93101 }
94102 }
95103}
0 commit comments