@@ -7,6 +7,7 @@ pub struct Config {
7
7
pub manifest_path : PathBuf ,
8
8
pub default_target : Option < String > ,
9
9
pub run_command : Vec < String > ,
10
+ pub test_timeout : u64 ,
10
11
}
11
12
12
13
pub ( 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>
16
17
}
17
18
18
19
pub ( 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 } ;
20
21
let cargo_toml: Value = {
21
22
let mut content = String :: new ( ) ;
22
23
File :: open ( & manifest_path)
@@ -53,6 +54,11 @@ pub(crate) fn read_config_inner(manifest_path: PathBuf) -> Result<Config, ErrorS
53
54
for ( key, value) in metadata {
54
55
match ( key. as_str ( ) , value. clone ( ) ) {
55
56
( "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
+ }
56
62
( "run-command" , Value :: Array ( array) ) => {
57
63
let mut command = Vec :: new ( ) ;
58
64
for value in array {
@@ -78,6 +84,7 @@ struct ConfigBuilder {
78
84
manifest_path : Option < PathBuf > ,
79
85
default_target : Option < String > ,
80
86
run_command : Option < Vec < String > > ,
87
+ test_timeout : Option < u64 > ,
81
88
}
82
89
83
90
impl Into < Config > for ConfigBuilder {
@@ -90,6 +97,7 @@ impl Into<Config> for ConfigBuilder {
90
97
"-drive" . into( ) ,
91
98
"format=raw,file={}" . into( ) ,
92
99
] ) ,
100
+ test_timeout : self . test_timeout . unwrap_or ( 60 * 5 ) ,
93
101
}
94
102
}
95
103
}
0 commit comments