[PATCH 2 of 2] run-tests: remove files that we potentially create outside of $TMPDIR

Sean Farley sean.michael.farley at gmail.com
Fri Nov 15 22:09:17 CST 2013


# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1384574231 18000
#      Fri Nov 15 22:57:11 2013 -0500
# Node ID 8431e9b86bb35fa95e19e5566a77bfc0e12cb1de
# Parent  32b6b92916e9c4f0c5a0b9e40efcbecdb0b7afac
run-tests: remove files that we potentially create outside of $TMPDIR

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -101,10 +101,11 @@
 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),
@@ -418,10 +419,15 @@
 
 def cleanup(options):
     if not options.keep_tmpdir:
         vlog("# Cleaning up HGTMP", HGTMP)
         shutil.rmtree(HGTMP, True)
+        for f in createdfiles:
+            try:
+                os.remove(f)
+            except OSError:
+                pass
 
 def usecorrectpython():
     # some tests run python interpreter. they must use same
     # interpreter we use or bad things will happen.
     pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
@@ -437,10 +443,11 @@
             if err.errno != errno.ENOENT:
                 raise
         if findprogram(pyexename) != sys.executable:
             try:
                 os.symlink(sys.executable, mypython)
+                createdfiles.append(mypython)
             except OSError, err:
                 # child processes may race, which is harmless
                 if err.errno != errno.EEXIST:
                     raise
     else:


More information about the Mercurial-devel mailing list