4444doing memory analysis on the Python interpreter, which process tends to
4545consume too many resources to run the full regression test non-stop.
4646
47- -S is used to continue running tests after an aborted run. It will
48- maintain the order a standard run (ie, this assumes -r is not used).
47+ -S is used to resume running tests after an interrupted run. It will
48+ maintain the order a standard run (i.e. it assumes -r is not used).
4949This is useful after the tests have prematurely stopped for some external
50- reason and you want to start running from where you left off rather
51- than starting from the beginning.
50+ reason and you want to resume the run from where you left off rather
51+ than starting from the beginning. Note: this is different from --prioritize.
52+
53+ --prioritize is used to influence the order of selected tests, such that
54+ the tests listed as an argument are executed first. This is especially
55+ useful when combined with -j and -r to pin the longest-running tests
56+ to start at the beginning of a test run. Pass --prioritize=test_a,test_b
57+ to make test_a run first, followed by test_b, and then the other tests.
58+ If test_a wasn't selected for execution by regular means, --prioritize will
59+ not make it execute.
5260
5361-f reads the names of tests from the file given as f's argument, one
5462or more test names per line. Whitespace is ignored. Blank lines and
@@ -236,7 +244,7 @@ def _create_parser():
236244 help = 'wait for user input, e.g., allow a debugger '
237245 'to be attached' )
238246 group .add_argument ('-S' , '--start' , metavar = 'START' ,
239- help = 'the name of the test at which to start .' +
247+ help = 'resume an interrupted run at the following test .' +
240248 more_details )
241249 group .add_argument ('-p' , '--python' , metavar = 'PYTHON' ,
242250 help = 'Command to run Python test subprocesses with.' )
@@ -263,6 +271,10 @@ def _create_parser():
263271 group = parser .add_argument_group ('Selecting tests' )
264272 group .add_argument ('-r' , '--randomize' , action = 'store_true' ,
265273 help = 'randomize test execution order.' + more_details )
274+ group .add_argument ('--prioritize' , metavar = 'TEST1,TEST2,...' ,
275+ action = 'append' , type = priority_list ,
276+ help = 'select these tests first, even if the order is'
277+ ' randomized.' + more_details )
266278 group .add_argument ('-f' , '--fromfile' , metavar = 'FILE' ,
267279 help = 'read names of tests to run from a file.' +
268280 more_details )
@@ -406,6 +418,10 @@ def resources_list(string):
406418 return u
407419
408420
421+ def priority_list (string ):
422+ return string .split ("," )
423+
424+
409425def _parse_args (args , ** kwargs ):
410426 # Defaults
411427 ns = Namespace ()
@@ -551,4 +567,10 @@ def _parse_args(args, **kwargs):
551567 print (msg , file = sys .stderr , flush = True )
552568 sys .exit (2 )
553569
570+ ns .prioritize = [
571+ test
572+ for test_list in (ns .prioritize or ())
573+ for test in test_list
574+ ]
575+
554576 return ns
0 commit comments