Patchwork tests: remove python link during cleanup

login
register
mail settings
Submitter Sean Farley
Date Nov. 16, 2013, 1:35 a.m.
Message ID <38c5f62b663a4e1f2d0a.1384565711@hit-nxdomain.opendns.com>
Download mbox | patch
Permalink /patch/2958/
State Deferred
Headers show

Comments

Sean Farley - Nov. 16, 2013, 1:35 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1384462134 18000
#      Thu Nov 14 15:48:54 2013 -0500
# Node ID 38c5f62b663a4e1f2d0a301fbfd8aa375caa218d
# Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
tests: remove python link during cleanup
Mads Kiilerich - Nov. 16, 2013, 2:06 a.m.
On 11/15/2013 08:35 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1384462134 18000
> #      Thu Nov 14 15:48:54 2013 -0500
> # Node ID 38c5f62b663a4e1f2d0a301fbfd8aa375caa218d
> # Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
> tests: remove python link during cleanup

Why? What problem do it solve?

Why should python be removed from BINDIR if the other things we do with 
BINDIR shouldn't?

And how secure will this be if run-tests is run with --with-hg pointing 
at a hg installed somewhere special?

(Run-tests is fragile and could use some major clean-ups. Apparently 
good changes like this can easily break other obscure use cases.)

/Mads

> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -415,10 +415,15 @@
>   def killdaemons(pidfile):
>       return killmod.killdaemons(pidfile, tryhard=False, remove=True,
>                                  logfn=vlog)
>   
>   def cleanup(options):
> +    pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
> +    mypython = os.path.join(BINDIR, pyexename)
> +    if os.path.isfile(mypython):
> +        os.remove(mypython)
> +
>       if not options.keep_tmpdir:
>           vlog("# Cleaning up HGTMP", HGTMP)
>           shutil.rmtree(HGTMP, True)
>   
>   def usecorrectpython():
>
Sean Farley - Nov. 16, 2013, 2:20 a.m.
mads@kiilerich.com writes:

> On 11/15/2013 08:35 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1384462134 18000
>> #      Thu Nov 14 15:48:54 2013 -0500
>> # Node ID 38c5f62b663a4e1f2d0a301fbfd8aa375caa218d
>> # Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
>> tests: remove python link during cleanup
>
> Why? What problem do it solve?

The problem is that a random link is created in the mercurial directory
that keeps showing up as "? python" in "hg status".

> Why should python be removed from BINDIR if the other things we do with 
> BINDIR shouldn't?
>
> And how secure will this be if run-tests is run with --with-hg pointing 
> at a hg installed somewhere special?

Hmm, that's a good question. Probably not a good thing.

> (Run-tests is fragile and could use some major clean-ups. Apparently 
> good changes like this can easily break other obscure use cases.)

I'd rather it not create the link in the first place but I don't know
the code that well to know.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -415,10 +415,15 @@ 
 def killdaemons(pidfile):
     return killmod.killdaemons(pidfile, tryhard=False, remove=True,
                                logfn=vlog)
 
 def cleanup(options):
+    pyexename = sys.platform == 'win32' and 'python.exe' or 'python'
+    mypython = os.path.join(BINDIR, pyexename)
+    if os.path.isfile(mypython):
+        os.remove(mypython)
+
     if not options.keep_tmpdir:
         vlog("# Cleaning up HGTMP", HGTMP)
         shutil.rmtree(HGTMP, True)
 
 def usecorrectpython():