Patchwork [011,of,179,tests-refactor] run-tests: pass TestResult into run()

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:37 p.m.
Message ID <3533e57a0390713ae8b0.1399055848@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4506/
State Accepted
Commit cbf5475827da3d2ca5a3aa775d6d4dba1c408501
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397957482 25200
#      Sat Apr 19 18:31:22 2014 -0700
# Branch stable
# Node ID 3533e57a0390713ae8b0ab201d4bb3c20d8f6c65
# Parent  22f12dcef025b280eb1b8f22280167f562ebc46d
run-tests: pass TestResult into run()

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -552,21 +552,20 @@  class Test(object):
         self.threadtmp = os.path.join(HGTMP, 'child%d' % count)
         os.mkdir(self.threadtmp)
 
         self._testtmp = os.path.join(self.threadtmp, os.path.basename(path))
         os.mkdir(self._testtmp)
 
         self._setreplacements(count)
 
-    def run(self):
+    def run(self, result):
         env = self._getenv()
         createhgrc(env['HGRCPATH'], self._options)
 
-        result = TestResult()
         starttime = time.time()
 
         def updateduration():
             result.duration = time.time() - starttime
 
         try:
             ret, out = self._run(self._replacements, env)
             updateduration()
@@ -576,18 +575,16 @@  class Test(object):
             updateduration()
             result.interrupted = True
         except Exception, e:
             updateduration()
             result.exception = e
 
         killdaemons(env['DAEMON_PIDS'])
 
-        return result
-
     def _run(self, replacements, env):
         raise NotImplemented('Subclasses must implement Test.run()')
 
     def _setreplacements(self, count):
         port = self._options.port + count * 3
         r = [
             (r':%s\b' % port, ':$HGPORT'),
             (r':%s\b' % (port + 1), ':$HGPORT1'),
@@ -1045,17 +1042,18 @@  def runone(options, test, count):
         return skip("unknown test type")
 
     vlog("# Test", test)
 
     if os.path.exists(err):
         os.remove(err)       # Remove any previous output files
 
     t = runner(testpath, options, count)
-    res = t.run()
+    res = TestResult()
+    t.run(res)
 
     if res.interrupted:
         log('INTERRUPTED: %s (after %d seconds)' % (test, res.duration))
         raise KeyboardInterrupt()
 
     if res.exception:
         return fail('Exception during execution: %s' % res.exception, 255)