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

login
register
mail settings
Submitter Sean Farley
Date Nov. 16, 2013, 4:09 a.m.
Message ID <8431e9b86bb35fa95e19.1384574957@hit-nxdomain.opendns.com>
Download mbox | patch
Permalink /patch/2976/
State Accepted
Commit edbf7f1fd2a29f8ab01ad912e641321cbf2692c3
Headers show

Comments

Sean Farley - Nov. 16, 2013, 4:09 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@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
Augie Fackler - Nov. 16, 2013, 5:35 p.m.
On Fri, Nov 15, 2013 at 11:09:17PM -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@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

queueing these, thanks

>
> 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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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: