12
12
from test .libregrtest .cmdline import _parse_args
13
13
from test .libregrtest .runtest import (
14
14
findtests , runtest , get_abs_module , is_failed ,
15
- STDTESTS , NOTTESTS , PROGRESS_MIN_TIME ,
15
+ PROGRESS_MIN_TIME ,
16
16
Passed , Failed , EnvChanged , Skipped , ResourceDenied , Interrupted ,
17
17
ChildError , DidNotRun )
18
18
from test .libregrtest .setup import setup_tests
42
42
EXITCODE_ENV_CHANGED = 3
43
43
EXITCODE_NO_TESTS_RAN = 4
44
44
45
+ # Coarse heuristic: tests taking at least 1 minute on a modern
46
+ # developer laptop. The list should have less than 20 tests.
47
+ SLOWEST_TESTS = frozenset ((
48
+ # more or less sorted from the slowest to the fastest
49
+ "test_concurrent_futures" ,
50
+ "test_multiprocessing_spawn" ,
51
+ "test_multiprocessing_forkserver" ,
52
+ "test_multiprocessing_fork" ,
53
+ "test_multiprocessing_main_handling" ,
54
+ "test_pickle" ,
55
+ "test_compileall" ,
56
+ "test_cppext" ,
57
+ "test_venv" ,
58
+ "test_gdb" ,
59
+ "test_tools" ,
60
+ "test_peg_generator" ,
61
+ "test_perf_profiler" ,
62
+ "test_buffer" ,
63
+ "test_subprocess" ,
64
+ "test_signal" ,
65
+ "test_tarfile" ,
66
+ "test_regrtest" ,
67
+ "test_socket" ,
68
+ "test_io" ,
69
+ ))
70
+
45
71
46
72
class Regrtest :
47
73
"""Execute a test suite.
@@ -246,21 +272,18 @@ def find_tests(self, tests):
246
272
# add default PGO tests if no tests are specified
247
273
setup_pgo_tests (self .ns )
248
274
249
- stdtests = STDTESTS [:]
250
- nottests = NOTTESTS .copy ()
275
+ exclude_tests = set ()
251
276
if self .ns .exclude :
252
277
for arg in self .ns .args :
253
- if arg in stdtests :
254
- stdtests .remove (arg )
255
- nottests .add (arg )
278
+ exclude_tests .add (arg )
256
279
self .ns .args = []
257
280
258
281
# if testdir is set, then we are not running the python tests suite, so
259
282
# don't add default tests to be executed or skipped (pass empty values)
260
283
if self .ns .testdir :
261
- alltests = findtests (self .ns .testdir , list (), set () )
284
+ alltests = findtests (self .ns .testdir )
262
285
else :
263
- alltests = findtests (self .ns .testdir , stdtests , nottests )
286
+ alltests = findtests (self .ns .testdir , exclude = exclude_tests )
264
287
265
288
if not self .ns .fromfile :
266
289
self .selected = self .tests or self .ns .args or alltests
@@ -282,11 +305,31 @@ def find_tests(self, tests):
282
305
print ("Couldn't find starting test (%s), using all tests"
283
306
% self .ns .start , file = sys .stderr )
284
307
308
+ self .group_randomize_tests ()
309
+
310
+ def group_randomize_tests (self ):
285
311
if self .ns .randomize :
286
312
if self .ns .random_seed is None :
287
313
self .ns .random_seed = random .randrange (10000000 )
288
314
random .seed (self .ns .random_seed )
289
- random .shuffle (self .selected )
315
+
316
+ # group slow tests
317
+ slow = []
318
+ other = []
319
+ for name in self .selected :
320
+ if name in SLOWEST_TESTS :
321
+ slow .append (name )
322
+ else :
323
+ other .append (name )
324
+
325
+ if self .ns .randomize :
326
+ if slow :
327
+ random .shuffle (slow )
328
+ if other :
329
+ random .shuffle (other )
330
+
331
+ # gh-108388: Run the slowest first, and then other tests
332
+ self .selected = slow + other
290
333
291
334
def list_tests (self ):
292
335
for name in self .selected :
0 commit comments