Patchwork [064,of,179,tests-refactor] run-tests: move results global into TestRunner

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:38 p.m.
Message ID <aa233a3973841c46e914.1399055901@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4559/
State Accepted
Commit 7982475da46ae90e8e6bf362f609b1c0cb68fe40
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397977412 25200
#      Sun Apr 20 00:03:32 2014 -0700
# Branch stable
# Node ID aa233a3973841c46e914fffdba3f21101f237d5f
# Parent  c1607865d400300adb74bfc4723b735c87b56671
run-tests: move results global into TestRunner

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -984,17 +984,16 @@  def _gethgpath():
     cmd = '%s -c "import mercurial; print (mercurial.__path__[0])"'
     pipe = os.popen(cmd % PYTHON)
     try:
         _hgpath = pipe.read().strip()
     finally:
         pipe.close()
     return _hgpath
 
-results = {'.':[], '!':[], '~': [], 's':[], 'i':[]}
 iolock = threading.Lock()
 abort = False
 
 def scheduletests(runner, tests):
     jobs = runner.options.jobs
     done = queue.Queue()
     running = 0
     count = 0
@@ -1011,17 +1010,17 @@  def scheduletests(runner, tests):
             done.put(('!', test, 'run-test raised an error, see traceback'))
             raise
 
     try:
         while tests or running:
             if not done.empty() or running == jobs or not tests:
                 try:
                     code, test, msg = done.get(True, 1)
-                    results[code].append((test, msg))
+                    runner.results[code].append((test, msg))
                     if runner.options.first and code not in '.si':
                         break
                 except queue.Empty:
                     continue
                 running -= 1
             if tests and not running == jobs:
                 test = tests.pop(0)
                 if runner.options.loop:
@@ -1048,34 +1047,34 @@  def runtests(runner, tests):
                     break
                 tests.pop(0)
             if not tests:
                 print "running all tests"
                 tests = orig
 
         scheduletests(runner, tests)
 
-        failed = len(results['!'])
-        warned = len(results['~'])
-        tested = len(results['.']) + failed + warned
-        skipped = len(results['s'])
-        ignored = len(results['i'])
+        failed = len(runner.results['!'])
+        warned = len(runner.results['~'])
+        tested = len(runner.results['.']) + failed + warned
+        skipped = len(runner.results['s'])
+        ignored = len(runner.results['i'])
 
         print
         if not runner.options.noskips:
-            for s in results['s']:
+            for s in runner.results['s']:
                 print "Skipped %s: %s" % s
-        for s in results['~']:
+        for s in runner.results['~']:
             print "Warned %s: %s" % s
-        for s in results['!']:
+        for s in runner.results['!']:
             print "Failed %s: %s" % s
         runner.checkhglib("Tested")
         print "# Ran %d tests, %d skipped, %d warned, %d failed." % (
             tested, skipped + ignored, warned, failed)
-        if results['!']:
+        if runner.results['!']:
             print 'python hash seed:', os.environ['PYTHONHASHSEED']
         if runner.options.time:
             runner.outputtimes()
 
         if runner.options.anycoverage:
             runner.outputcoverage()
     except KeyboardInterrupt:
         failed = True
@@ -1102,16 +1101,23 @@  class TestRunner(object):
         self.testdir = None
         self.hgtmp = None
         self.inst = None
         self.bindir = None
         self.tmpbinddir = None
         self.pythondir = None
         self.coveragefile = None
         self.times = [] # Holds execution times of tests.
+        self.results = {
+            '.': [],
+            '!': [],
+            '~': [],
+            's': [],
+            'i': [],
+        }
         self._createdfiles = []
 
     def gettest(self, test, count):
         """Obtain a Test by looking at its filename.
 
         Returns a Test instance. The Test may not be runnable if it doesn't
         map to a known type.
         """