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

Gregory Szorc gregory.szorc at gmail.com
Fri May 2 13:38:21 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at 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

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.
         """


More information about the Mercurial-devel mailing list