2020-h: help -- print this text and exit
2121-t: threshold -- call gc.set_threshold(N)
2222-T: coverage -- turn on code coverage using the trace module
23+ -L: runleaks -- run the leaks(1) command just before exit
2324
2425If non-option arguments are present, they are names for tests to run,
2526unless -x is given, in which case they are names for tests not to run.
4243lines beginning with '#' are ignored. This is especially useful for
4344whittling down failures involving interactions among tests.
4445
46+ -L causes the leaks(1) command to be run just before exit if it exists.
47+ leaks(1) is available on Mac OS X and presumably on some other
48+ FreeBSD-derived systems.
49+
4550-u is used to specify which special resource intensive tests to run,
4651such as those requiring large file support or network connectivity.
4752The argument is a comma-separated list of words indicating the
@@ -118,7 +123,7 @@ def usage(code, msg=''):
118123
119124def main (tests = None , testdir = None , verbose = 0 , quiet = False , generate = False ,
120125 exclude = False , single = False , randomize = False , fromfile = None ,
121- findleaks = False , use_resources = None , trace = False ):
126+ findleaks = False , use_resources = None , trace = False , runleaks = False ):
122127 """Execute a test suite.
123128
124129 This also parses command-line options and modifies its behavior
@@ -143,10 +148,11 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
143148
144149 test_support .record_original_stdout (sys .stdout )
145150 try :
146- opts , args = getopt .getopt (sys .argv [1 :], 'hvgqxsrf:lu:t:T ' ,
151+ opts , args = getopt .getopt (sys .argv [1 :], 'hvgqxsrf:lu:t:TL ' ,
147152 ['help' , 'verbose' , 'quiet' , 'generate' ,
148153 'exclude' , 'single' , 'random' , 'fromfile' ,
149154 'findleaks' , 'use=' , 'threshold=' , 'trace' ,
155+ 'runleaks'
150156 ])
151157 except getopt .error , msg :
152158 usage (2 , msg )
@@ -174,6 +180,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
174180 fromfile = a
175181 elif o in ('-l' , '--findleaks' ):
176182 findleaks = True
183+ elif o in ('-L' , '--runleaks' ):
184+ runleaks = True
177185 elif o in ('-t' , '--threshold' ):
178186 import gc
179187 gc .set_threshold (int (a ))
@@ -350,6 +358,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
350358 r = tracer .results ()
351359 r .write_results (show_missing = True , summary = True , coverdir = coverdir )
352360
361+ if runleaks :
362+ os .system ("leaks %d" % os .getpid ())
363+
353364 sys .exit (len (bad ) > 0 )
354365
355366
0 commit comments