[PATCH 083 of 179 tests-refactor] run-tests: make some methods of TestRunner internal

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


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1398013906 25200
#      Sun Apr 20 10:11:46 2014 -0700
# Branch stable
# Node ID c943a9f897eeabbc08d82c80fdc134c8e8bc8930
# Parent  37bec1483bd54a4f5ada00494ca2f462559a34dc
run-tests: make some methods of TestRunner internal

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1157,20 +1157,20 @@ class TestRunner(object):
 
         return [t for t in args
                 if os.path.basename(t).startswith('test-')
                     and (t.endswith('.py') or t.endswith('.t'))]
 
     def _runtests(self, tests):
         try:
             if self.inst:
-                self.installhg()
-                self.checkhglib("Testing")
+                self._installhg()
+                self._checkhglib("Testing")
             else:
-                self.usecorrectpython()
+                self._usecorrectpython()
 
             if self.options.restart:
                 orig = list(tests)
                 while tests:
                     if os.path.exists(tests[0] + ".err"):
                         break
                     tests.pop(0)
                 if not tests:
@@ -1188,36 +1188,36 @@ class TestRunner(object):
             print
             if not self.options.noskips:
                 for s in self.results['s']:
                     print "Skipped %s: %s" % s
             for s in self.results['~']:
                 print "Warned %s: %s" % s
             for s in self.results['!']:
                 print "Failed %s: %s" % s
-            self.checkhglib("Tested")
+            self._checkhglib("Tested")
             print "# Ran %d tests, %d skipped, %d warned, %d failed." % (
                 tested, skipped + ignored, warned, failed)
             if self.results['!']:
                 print 'python hash seed:', os.environ['PYTHONHASHSEED']
             if self.options.time:
-                self.outputtimes()
+                self._outputtimes()
 
             if self.options.anycoverage:
-                self.outputcoverage()
+                self._outputcoverage()
         except KeyboardInterrupt:
             failed = True
             print "\ninterrupted!"
 
         if failed:
             return 1
         if warned:
             return 80
 
-    def gettest(self, test, count):
+    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.
         """
         lctest = test.lower()
         refpath = os.path.join(self.testdir, test)
 
@@ -1240,17 +1240,17 @@ class TestRunner(object):
         vlog("# Cleaning up HGTMP", self.hgtmp)
         shutil.rmtree(self.hgtmp, True)
         for f in self._createdfiles:
             try:
                 os.remove(f)
             except OSError:
                 pass
 
-    def usecorrectpython(self):
+    def _usecorrectpython(self):
         # Some tests run the Python interpreter. They must use the
         # same interpreter or bad things will happen.
         pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
         if getattr(os, 'symlink', None):
             vlog("# Making python executable in test path a symlink to '%s'" %
                  sys.executable)
             mypython = os.path.join(self.tmpbindir, pyexename)
             try:
@@ -1274,17 +1274,17 @@ class TestRunner(object):
                  (exename, pyexename, exedir))
             path = os.environ['PATH'].split(os.pathsep)
             while exedir in path:
                 path.remove(exedir)
             os.environ['PATH'] = os.pathsep.join([exedir] + path)
             if not self._findprogram(pyexename):
                 print "WARNING: Cannot find %s in search path" % pyexename
 
-    def installhg(self):
+    def _installhg(self):
         vlog("# Performing temporary installation of HG")
         installerrs = os.path.join("tests", "install.err")
         compiler = ''
         if self.options.compiler:
             compiler = '--compiler ' + self.options.compiler
         pure = self.options.pure and "--pure" or ""
         py3 = ''
         if sys.version_info[0] == 3:
@@ -1319,17 +1319,17 @@ class TestRunner(object):
         else:
             f = open(installerrs)
             for line in f:
                 print line,
             f.close()
             sys.exit(1)
         os.chdir(self.testdir)
 
-        self.usecorrectpython()
+        self._usecorrectpython()
 
         if self.options.py3k_warnings and not self.options.anycoverage:
             vlog("# Updating hg command to enable Py3k Warnings switch")
             f = open(os.path.join(self.bindir, 'hg'), 'r')
             lines = [line.rstrip() for line in f]
             lines[0] += ' -3'
             f.close()
             f = open(os.path.join(self.bindir, 'hg'), 'w')
@@ -1359,35 +1359,35 @@ class TestRunner(object):
             vlog('# Installing coverage trigger to %s' % target)
             shutil.copyfile(custom, target)
             rc = os.path.join(self.testdir, '.coveragerc')
             vlog('# Installing coverage rc to %s' % rc)
             os.environ['COVERAGE_PROCESS_START'] = rc
             fn = os.path.join(self.inst, '..', '.coverage')
             os.environ['COVERAGE_FILE'] = fn
 
-    def checkhglib(self, verb):
+    def _checkhglib(self, verb):
         """Ensure that the 'mercurial' package imported by python is
         the one we expect it to be.  If not, print a warning to stderr."""
         expecthg = os.path.join(self.pythondir, 'mercurial')
         actualhg = _gethgpath()
         if os.path.abspath(actualhg) != os.path.abspath(expecthg):
             sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n'
                              '         (expected %s)\n'
                              % (verb, actualhg, expecthg))
 
-    def outputtimes(self):
+    def _outputtimes(self):
         vlog('# Producing time report')
         self.times.sort(key=lambda t: (t[1], t[0]), reverse=True)
         cols = '%7.3f   %s'
         print '\n%-7s   %s' % ('Time', 'Test')
         for test, timetaken in self.times:
             print cols % (timetaken, test)
 
-    def outputcoverage(self):
+    def _outputcoverage(self):
         vlog('# Producing coverage report')
         os.chdir(self.pythondir)
 
         def covrun(*args):
             cmd = 'coverage %s' % ' '.join(args)
             vlog('# Running: %s' % cmd)
             os.system(cmd)
 
@@ -1408,17 +1408,17 @@ class TestRunner(object):
     def _executetests(self, tests):
         jobs = self.options.jobs
         done = queue.Queue()
         running = 0
         count = 0
 
         def job(test, count):
             try:
-                t = self.gettest(test, count)
+                t = self._gettest(test, count)
                 done.put(t.run())
                 del t # For side-effects.
             except KeyboardInterrupt:
                 pass
             except: # re-raises
                 done.put(('!', test, 'run-test raised an error, see traceback'))
                 raise
 


More information about the Mercurial-devel mailing list