##// END OF EJS Templates
testrunner: add option to sort tests by previous run time...
Martin von Zweigbergk -
r36683:6276cbc7 default
parent child Browse files
Show More
@@ -345,6 +345,8 b' def getparser():'
345 help="loop tests repeatedly")
345 help="loop tests repeatedly")
346 harness.add_argument('--random', action="store_true",
346 harness.add_argument('--random', action="store_true",
347 help='run tests in random order')
347 help='run tests in random order')
348 harness.add_argument('--order-by-runtime', action="store_true",
349 help='run slowest tests first, according to .testtimes')
348 harness.add_argument("-p", "--port", type=int,
350 harness.add_argument("-p", "--port", type=int,
349 help="port on which servers should listen"
351 help="port on which servers should listen"
350 " (default: $%s or %d)" % defaults['port'])
352 " (default: $%s or %d)" % defaults['port'])
@@ -2307,12 +2309,22 b' class TextTestRunner(unittest.TextTestRu'
2307 separators=(',', ': '))
2309 separators=(',', ': '))
2308 outf.writelines(("testreport =", jsonout))
2310 outf.writelines(("testreport =", jsonout))
2309
2311
2310 def sorttests(testdescs, shuffle=False):
2312 def sorttests(testdescs, previoustimes, shuffle=False):
2311 """Do an in-place sort of tests."""
2313 """Do an in-place sort of tests."""
2312 if shuffle:
2314 if shuffle:
2313 random.shuffle(testdescs)
2315 random.shuffle(testdescs)
2314 return
2316 return
2315
2317
2318 if previoustimes:
2319 def sortkey(f):
2320 f = f['path']
2321 if f in previoustimes:
2322 # Use most recent time as estimate
2323 return -previoustimes[f][-1]
2324 else:
2325 # Default to a rather arbitrary value of 1 second for new tests
2326 return -1.0
2327 else:
2316 # keywords for slow tests
2328 # keywords for slow tests
2317 slow = {b'svn': 10,
2329 slow = {b'svn': 10,
2318 b'cvs': 10,
2330 b'cvs': 10,
@@ -2418,8 +2430,6 b' class TestRunner(object):'
2418 os.umask(oldmask)
2430 os.umask(oldmask)
2419
2431
2420 def _run(self, testdescs):
2432 def _run(self, testdescs):
2421 sorttests(testdescs, shuffle=self.options.random)
2422
2423 self._testdir = osenvironb[b'TESTDIR'] = getattr(
2433 self._testdir = osenvironb[b'TESTDIR'] = getattr(
2424 os, 'getcwdb', os.getcwd)()
2434 os, 'getcwdb', os.getcwd)()
2425 # assume all tests in same folder for now
2435 # assume all tests in same folder for now
@@ -2434,6 +2444,10 b' class TestRunner(object):'
2434 self._outputdir = self._testdir
2444 self._outputdir = self._testdir
2435 if testdescs and pathname:
2445 if testdescs and pathname:
2436 self._outputdir = os.path.join(self._outputdir, pathname)
2446 self._outputdir = os.path.join(self._outputdir, pathname)
2447 previoustimes = {}
2448 if self.options.order_by_runtime:
2449 previoustimes = dict(loadtimes(self._outputdir))
2450 sorttests(testdescs, previoustimes, shuffle=self.options.random)
2437
2451
2438 if 'PYTHONHASHSEED' not in os.environ:
2452 if 'PYTHONHASHSEED' not in os.environ:
2439 # use a random python hash seed all the time
2453 # use a random python hash seed all the time
General Comments 0
You need to be logged in to leave comments. Login now