@@ -143,7 +143,13 @@ sub collect_test_cases ($$$$) {
143
143
144
144
if ( @$opt_cases )
145
145
{
146
- # A list of tests was specified on the command line
146
+ # A list of tests was specified on the command line.
147
+ # Among those, the tests which are not already collected will be
148
+ # collected and stored temporarily in an array of hashes pointed
149
+ # by the below reference. This array is eventually appeneded to
150
+ # the one having all collected test cases.
151
+ my $cmdline_cases ;
152
+
147
153
# Check that the tests specified was found
148
154
# in at least one suite
149
155
foreach my $test_name_spec ( @$opt_cases )
@@ -162,20 +168,56 @@ sub collect_test_cases ($$$$) {
162
168
}
163
169
if ( not $found )
164
170
{
165
- $sname = " main" if !$opt_reorder and !$sname ;
166
- mtr_error(" Could not find '$tname ' in '$suites ' suite(s)" ) unless $sname ;
167
- # If suite was part of name, find it there, may come with combinations
168
- my @this_case = collect_one_suite($sname , [ $tname ]);
169
- if (@this_case )
171
+ if ( $sname )
170
172
{
171
- push (@$cases , @this_case );
172
- }
173
- else
174
- {
175
- mtr_error(" Could not find '$tname ' in '$sname ' suite" );
173
+ # If suite was part of name, find it there, may come with combinations
174
+ my @this_case = collect_one_suite($sname , [ $tname ]);
175
+
176
+ # If a test is specified multiple times on the command line, all
177
+ # instances of the test need to be picked. Hence, such tests are
178
+ # stored in the temporary array instead of adding them to $cases
179
+ # directly so that repeated tests are not run only once
180
+ if (@this_case )
181
+ {
182
+ push (@$cmdline_cases , @this_case );
183
+ }
184
+ else
185
+ {
186
+ mtr_error(" Could not find '$tname ' in '$sname ' suite" );
187
+ }
188
+ }
189
+ else
190
+ {
191
+ if ( !$opt_reorder )
192
+ {
193
+ # If --no-reorder is passed and if suite was not part of name,
194
+ # search in all the suites
195
+ foreach my $suite (split (" ," , $suites ))
196
+ {
197
+ my @this_case = collect_one_suite($suite , [ $tname ]);
198
+ if ( @this_case )
199
+ {
200
+ push (@$cmdline_cases , @this_case );
201
+ $found = 1;
202
+ }
203
+ @this_case = collect_one_suite(" i_" .$suite , [ $tname ]);
204
+ if ( @this_case )
205
+ {
206
+ push (@$cmdline_cases , @this_case );
207
+ $found = 1;
208
+ }
209
+ }
210
+ }
211
+ if ( !$found )
212
+ {
213
+ mtr_error(" Could not find '$tname ' in '$suites ' suite(s)" );
214
+ }
176
215
}
177
216
}
178
217
}
218
+ # Add test cases collected in the temporary array to the one
219
+ # containing all previously collected test cases
220
+ push (@$cases , @$cmdline_cases ) if $cmdline_cases ;
179
221
}
180
222
181
223
if ( $opt_reorder && !$quick_collect )
0 commit comments