@@ -180,13 +180,26 @@ def find_tests(test_suite, suite_path):
180
180
181
181
tests = []
182
182
for test_name in glob .glob (os .path .join (suite_path , '*_test.lua' )):
183
- # If neither of the include patterns are substrings of
184
- # the given test name, skip the test.
185
- if not any (p in test_name for p in include_patterns ):
183
+ # Several include patterns may match the given
184
+ # test[^1].
185
+ #
186
+ # The primary usage of this behavior is to run a test
187
+ # many times in parallel to verify its stability or
188
+ # to debug an unstable behavior.
189
+ #
190
+ # Execute the test once for each of the matching
191
+ # patterns.
192
+ #
193
+ # [^1]: A pattern matches a test if the pattern is a
194
+ # substring of the test name.
195
+ repeat = sum (1 for p in include_patterns if p in test_name )
196
+ # If neither of the include patterns matches the given
197
+ # test, skip the test.
198
+ if repeat == 0 :
186
199
continue
187
200
188
- # If at least one of the exclude patterns is a
189
- # substring of the given test name , skip the test.
201
+ # If at least one of the exclude patterns matches the
202
+ # given test, skip the test.
190
203
if any (p in test_name for p in exclude_patterns ):
191
204
continue
192
205
@@ -211,13 +224,15 @@ def find_tests(test_suite, suite_path):
211
224
prefix_len = len (os .path .commonprefix (test_cases ))
212
225
213
226
for test_case in test_cases :
214
- tests .append (LuatestTest (test_name , test_suite .args , test_suite .ini ,
215
- params = {"test_case" : test_case },
216
- conf_name = test_case [prefix_len :]))
227
+ test_obj = LuatestTest (test_name , test_suite .args , test_suite .ini ,
228
+ params = {"test_case" : test_case },
229
+ conf_name = test_case [prefix_len :])
230
+ tests .extend ([test_obj ] * repeat )
217
231
else :
218
232
# If the test has no 'parallel' tag, run all the
219
233
# test cases as one task.
220
- tests .append (LuatestTest (test_name , test_suite .args , test_suite .ini ))
234
+ test_obj = LuatestTest (test_name , test_suite .args , test_suite .ini )
235
+ tests .extend ([test_obj ] * repeat )
221
236
222
237
tests .sort (key = lambda t : t .name )
223
238
0 commit comments