Patchwork [057,of,179,tests-refactor] run-tests: move createdfiles out of a global and into TestRunner

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

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397975978 25200
#      Sat Apr 19 23:39:38 2014 -0700
# Branch stable
# Node ID ac9e4c09d9cb02245f30325a1870bc255602a92e
# Parent  35dd393f44232598842b1e49662b6380de0ae444
run-tests: move createdfiles out of a global and 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
@@ -98,18 +98,16 @@  SKIPPED_PREFIX = 'skipped: '
 FAILED_PREFIX  = 'hghave check failed: '
 PYTHON = sys.executable.replace('\\', '/')
 IMPL_PATH = 'PYTHONPATH'
 if 'java' in sys.platform:
     IMPL_PATH = 'JYTHONPATH'
 
 requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip",
                  "gunzip", "bunzip2", "sed"]
-createdfiles = []
-
 defaults = {
     'jobs': ('HGTEST_JOBS', 1),
     'timeout': ('HGTEST_TIMEOUT', 180),
     'port': ('HGTEST_PORT', 20059),
     'shell': ('HGTEST_SHELL', 'sh'),
 }
 
 def parselistfiles(files, listtype, warn=True):
@@ -1244,26 +1242,27 @@  class TestRunner(object):
         self.options = None
         self.testdir = None
         self.hgtmp = None
         self.inst = None
         self.bindir = None
         self.tmpbinddir = None
         self.pythondir = None
         self.coveragefile = None
+        self._createdfiles = []
 
     def cleanup(self):
         """Clean up state from this test invocation."""
 
         if self.options.keep_tmpdir:
             return
 
         vlog("# Cleaning up HGTMP", self.hgtmp)
         shutil.rmtree(self.hgtmp, True)
-        for f in createdfiles:
+        for f in self._createdfiles:
             try:
                 os.remove(f)
             except OSError:
                 pass
 
     def usecorrectpython(self):
         # Some tests run the Python interpreter. They must use the
         # same interpreter or bad things will happen.
@@ -1277,17 +1276,17 @@  class TestRunner(object):
                     return
                 os.unlink(mypython)
             except OSError, err:
                 if err.errno != errno.ENOENT:
                     raise
             if findprogram(pyexename) != sys.executable:
                 try:
                     os.symlink(sys.executable, mypython)
-                    createdfiles.append(mypython)
+                    self._createdfiles.append(mypython)
                 except OSError, err:
                     # child processes may race, which is harmless
                     if err.errno != errno.EEXIST:
                         raise
         else:
             exedir, exename = os.path.split(sys.executable)
             vlog("# Modifying search path to find %s as %s in '%s'" %
                  (exename, pyexename, exedir))