@@ -2,7 +2,7 @@ use crate::{
2
2
logging:: { Logger , Panic , TestOutput , TestResult } ,
3
3
mullvad_daemon:: { self , MullvadClientArgument , RpcClientProvider } ,
4
4
summary:: SummaryLogger ,
5
- tests:: { self , config:: TEST_CONFIG , get_tests, TestContext } ,
5
+ tests:: { self , config:: TEST_CONFIG , get_tests, TestContext , TestMetadata } ,
6
6
vm,
7
7
} ;
8
8
use anyhow:: { Context , Result } ;
@@ -103,7 +103,7 @@ impl TestHandler<'_> {
103
103
pub async fn run (
104
104
config : tests:: config:: TestConfig ,
105
105
instance : & dyn vm:: VmInstance ,
106
- test_filters : & [ String ] ,
106
+ specified_tests : & [ String ] ,
107
107
skip_wait : bool ,
108
108
print_failed_tests_only : bool ,
109
109
summary_logger : Option < SummaryLogger > ,
@@ -141,21 +141,7 @@ pub async fn run(
141
141
logger : Logger :: get_or_init ( ) ,
142
142
} ;
143
143
144
- let mut tests = get_tests ( ) ;
145
-
146
- tests. retain ( |test| test. should_run_on_os ( TEST_CONFIG . os ) ) ;
147
-
148
- if !test_filters. is_empty ( ) {
149
- tests. retain ( |test| {
150
- for command in test_filters {
151
- let command = command. to_lowercase ( ) ;
152
- if test. command . to_lowercase ( ) . contains ( & command) {
153
- return true ;
154
- }
155
- }
156
- false
157
- } ) ;
158
- }
144
+ let tests = get_filtered_tests ( specified_tests) ?;
159
145
160
146
if TEST_CONFIG . app_package_to_upgrade_from_filename . is_some ( ) {
161
147
test_handler
@@ -192,6 +178,26 @@ pub async fn run(
192
178
Ok ( result)
193
179
}
194
180
181
+ fn get_filtered_tests ( specified_tests : & [ String ] ) -> Result < Vec < & TestMetadata > , anyhow:: Error > {
182
+ let mut tests = get_tests ( ) ;
183
+ tests. retain ( |test| test. should_run_on_os ( TEST_CONFIG . os ) ) ;
184
+ if !specified_tests. is_empty ( ) {
185
+ specified_tests
186
+ . iter ( )
187
+ . map ( |f| {
188
+ tests
189
+ . iter ( )
190
+ . find ( |t| t. command . eq_ignore_ascii_case ( f) )
191
+ . cloned ( )
192
+ . ok_or ( anyhow:: anyhow!( "Test '{f}' not found" ) )
193
+ } )
194
+ . collect ( )
195
+ } else {
196
+ // Keep all tests
197
+ Ok ( tests)
198
+ }
199
+ }
200
+
195
201
async fn register_test_result (
196
202
test_result : TestResult ,
197
203
failed_tests : & mut Vec < & str > ,
0 commit comments