@@ -21,11 +21,25 @@ fn main() {
21
21
}
22
22
}
23
23
24
+ use structopt:: StructOpt ;
25
+ #[ derive( StructOpt , Debug ) ]
26
+ struct Options {
27
+ /// Space-separated list of features to activate
28
+ #[ structopt( long, name = "FEATURES" ) ]
29
+ features : Option < String > ,
30
+
31
+ /// Activate all available features
32
+ #[ structopt( long) ]
33
+ all_features : bool ,
34
+ }
35
+
24
36
fn run ( ) -> Fallible < ( ) > {
25
37
let mutagen_start = Instant :: now ( ) ;
26
38
39
+ let opt = Options :: from_args ( ) ;
40
+
27
41
// build the testsuites and collect mutations
28
- let test_bins = compile_tests ( ) ?;
42
+ let test_bins = compile_tests ( & opt ) ?;
29
43
if test_bins. is_empty ( ) {
30
44
bail ! ( "no test executable(s) found" ) ;
31
45
}
@@ -102,12 +116,21 @@ fn run_mutations(
102
116
}
103
117
104
118
/// build all tests and collect test-suite executables
105
- fn compile_tests ( ) -> Fallible < Vec < PathBuf > > {
119
+ fn compile_tests ( opt : & Options ) -> Fallible < Vec < PathBuf > > {
106
120
let mut tests: Vec < PathBuf > = Vec :: new ( ) ;
107
121
122
+ let mut feature_args: Vec < & str > = vec ! [ ] ;
123
+ if let Some ( f) = & opt. features {
124
+ feature_args. extend ( & [ "--features" , f] ) ;
125
+ }
126
+ if opt. all_features {
127
+ feature_args. push ( "--all-features" ) ;
128
+ }
129
+
108
130
// execute `cargo test --no-run --message-format=json` and collect output
109
131
let compile_out = Command :: new ( "cargo" )
110
132
. args ( & [ "test" , "--no-run" , "--message-format=json" ] )
133
+ . args ( & feature_args)
111
134
. stderr ( Stdio :: inherit ( ) )
112
135
. output ( ) ?;
113
136
if !compile_out. status . success ( ) {
0 commit comments