tests/run-tests.py
branchstable
changeset 1365 51476d2dcab1
parent 1364 772a53435e14
child 1366 987a80dec7db
equal deleted inserted replaced
1364:772a53435e14 1365:51476d2dcab1
   131                 entries[line] = filename
   131                 entries[line] = filename
   132 
   132 
   133         f.close()
   133         f.close()
   134     return entries
   134     return entries
   135 
   135 
   136 def parseargs(args):
   136 def getparser():
   137     parser = optparse.OptionParser("%prog [options] [tests]")
   137     parser = optparse.OptionParser("%prog [options] [tests]")
   138 
   138 
   139     # keep these sorted
   139     # keep these sorted
   140     parser.add_option("--blacklist", action="append",
   140     parser.add_option("--blacklist", action="append",
   141         help="skip tests listed in the specified blacklist file")
   141         help="skip tests listed in the specified blacklist file")
   208                       help='run tests in random order')
   208                       help='run tests in random order')
   209 
   209 
   210     for option, (envvar, default) in defaults.items():
   210     for option, (envvar, default) in defaults.items():
   211         defaults[option] = type(default)(os.environ.get(envvar, default))
   211         defaults[option] = type(default)(os.environ.get(envvar, default))
   212     parser.set_defaults(**defaults)
   212     parser.set_defaults(**defaults)
       
   213 
       
   214     return parser
       
   215 
       
   216 def parseargs(args, parser):
   213     (options, args) = parser.parse_args(args)
   217     (options, args) = parser.parse_args(args)
   214 
   218 
   215     # jython is always pure
   219     # jython is always pure
   216     if 'java' in sys.platform or '__pypy__' in sys.modules:
   220     if 'java' in sys.platform or '__pypy__' in sys.modules:
   217         options.pure = True
   221         options.pure = True
  1174         return 80
  1178         return 80
  1175 
  1179 
  1176 testtypes = [('.py', pytest, '.out'),
  1180 testtypes = [('.py', pytest, '.out'),
  1177              ('.t', tsttest, '')]
  1181              ('.t', tsttest, '')]
  1178 
  1182 
  1179 def main(args):
  1183 def main(args, parser=None):
  1180     (options, args) = parseargs(args)
  1184     parser = parser or getparser()
       
  1185     (options, args) = parseargs(args, parser)
  1181     os.umask(022)
  1186     os.umask(022)
  1182 
  1187 
  1183     checktools()
  1188     checktools()
  1184 
  1189 
  1185     if not args:
  1190     if not args: