@@ -12,7 +12,7 @@ use std::{
12
12
time:: { Duration , Instant } ,
13
13
} ;
14
14
15
- use clap:: Args ;
15
+ use clap:: { ArgAction , Args } ;
16
16
use log:: info;
17
17
18
18
use crate :: Result ;
@@ -39,8 +39,8 @@ pub struct RunTestsArgs {
39
39
pub timeout : u64 ,
40
40
41
41
/// Whether to build espflash before running tests, true by default
42
- #[ arg( long, value_parser = clap :: value_parser! ( bool ) ) ]
43
- pub local_espflash : Option < bool > ,
42
+ #[ arg( long = "no-build" , action = ArgAction :: SetFalse , default_value_t = true ) ]
43
+ pub build_espflash : bool ,
44
44
}
45
45
46
46
/// A struct to manage and run tests for the espflash
@@ -54,7 +54,7 @@ pub struct TestRunner {
54
54
/// Optional chip target for tests
55
55
pub chip : Option < String > ,
56
56
/// Build espflash before running tests
57
- pub local_espflash : Option < bool > ,
57
+ pub build_espflash : bool ,
58
58
}
59
59
60
60
impl TestRunner {
@@ -63,14 +63,14 @@ impl TestRunner {
63
63
workspace : & Path ,
64
64
tests_dir : PathBuf ,
65
65
timeout_secs : u64 ,
66
- local_espflash : bool ,
66
+ build_espflash : bool ,
67
67
) -> Self {
68
68
Self {
69
69
workspace : workspace. to_path_buf ( ) ,
70
70
tests_dir,
71
71
timeout : Duration :: from_secs ( timeout_secs) ,
72
72
chip : None ,
73
- local_espflash : Some ( local_espflash ) ,
73
+ build_espflash ,
74
74
}
75
75
}
76
76
@@ -223,12 +223,12 @@ impl TestRunner {
223
223
224
224
// we need to distinguish between local and CI runs, on CI we are building
225
225
// espflash and then copying the binary, so we can use just `espflash`
226
- match self . local_espflash {
227
- None | Some ( true ) => {
226
+ match self . build_espflash {
227
+ true => {
228
228
log:: info!( "Running cargo run..." ) ;
229
229
cmd. args ( [ "run" , "-p" , "espflash" , "--release" , "--quiet" , "--" ] ) ;
230
230
}
231
- Some ( false ) => {
231
+ false => {
232
232
log:: info!( "Using system espflash" ) ;
233
233
let mut cmd = Command :: new ( "espflash" ) ;
234
234
cmd. args ( args) ;
@@ -926,16 +926,11 @@ pub fn run_tests(workspace: &Path, args: RunTestsArgs) -> Result<()> {
926
926
log:: info!( "Running espflash tests" ) ;
927
927
928
928
let tests_dir = workspace. join ( "espflash" ) . join ( "tests" ) ;
929
- let test_runner = TestRunner :: new (
930
- workspace,
931
- tests_dir,
932
- args. timeout ,
933
- args. local_espflash . unwrap_or ( true ) ,
934
- ) ;
929
+ let test_runner = TestRunner :: new ( workspace, tests_dir, args. timeout , args. build_espflash ) ;
935
930
936
931
// Build espflash before running test(s) so we are not "waisting" test's
937
932
// duration or timeout
938
- if args. local_espflash . unwrap_or ( true ) {
933
+ if args. build_espflash {
939
934
test_runner. build_espflash ( ) ;
940
935
}
941
936
0 commit comments