run-tests: pass Test instances into TestRunner._executetests()
Test instances (not paths) are passed into _executetests(). This means
the logic for instantiating Test instances has been moved outside of
_executetests(). This was done because an upcoming patch will reuse the
logic in _executetests().
As part of this change, test counts are no longer managed by
_executetests().
--- a/tests/run-tests.py Sat May 17 12:35:44 2014 -0700
+++ b/tests/run-tests.py Sun Apr 20 12:49:43 2014 -0700
@@ -1240,11 +1240,11 @@
print "running all tests"
tests = orig
+ tests = [self._gettest(t, i, asunit=self.options.unittest)
+ for i, t in enumerate(tests)]
+
if self.options.unittest:
- suite = unittest.TestSuite()
- for count, testpath in enumerate(tests):
- suite.addTest(self._gettest(testpath, count, asunit=True))
-
+ suite = unittest.TestSuite(tests=tests)
verbosity = 1
if self.options.verbose:
verbosity = 2
@@ -1538,13 +1538,11 @@
jobs = self.options.jobs
done = queue.Queue()
running = 0
- count = 0
- def job(test, count):
+ def job(test):
try:
- t = self._gettest(test, count)
- done.put(t.run())
- t.cleanup()
+ done.put(test.run())
+ test.cleanup()
except KeyboardInterrupt:
pass
except: # re-raises
@@ -1566,11 +1564,10 @@
test = tests.pop(0)
if self.options.loop:
tests.append(test)
- t = threading.Thread(target=job, name=test,
- args=(test, count))
+ t = threading.Thread(target=job, name=test.name,
+ args=[test])
t.start()
running += 1
- count += 1
except KeyboardInterrupt:
self.abort[0] = True