Patchwork tests: use pyflakes module instead of pyflakes executable

login
register
mail settings
Submitter Manuel Jacob
Date March 6, 2020, 10:05 p.m.
Message ID <186c13bbb49fd4de4fd2.1583532306@tmp>
Download mbox | patch
Permalink /patch/45577/
State Accepted
Headers show

Comments

Manuel Jacob - March 6, 2020, 10:05 p.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1583532298 -3600
#      Fri Mar 06 23:04:58 2020 +0100
# Node ID 186c13bbb49fd4de4fd2c9983c3daf8fede5b177
# Parent  4ce2330f2d0b9690cc852602a9e055491a408c03
tests: use pyflakes module instead of pyflakes executable

This results in that the pyflakes version specific to the configured Python
version is used.

This way, both the Python 2-specific and the Python 3-specific pyflakes are run
by the test suite (depending on the configured Python version).

For downstream projects which are using Mercurial’s test infrastructure and are
not yet ported to Python 3 (e.g. hg-git) it ensures that the correct pyflakes
version is run even when the system’s default pyflakes is the Python 3-specific
one.
Yuya Nishihara - March 8, 2020, 5:24 a.m.
On Fri, 06 Mar 2020 23:05:06 +0100, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1583532298 -3600
> #      Fri Mar 06 23:04:58 2020 +0100
> # Node ID 186c13bbb49fd4de4fd2c9983c3daf8fede5b177
> # Parent  4ce2330f2d0b9690cc852602a9e055491a408c03
> tests: use pyflakes module instead of pyflakes executable

Queued, thanks.

> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -553,7 +553,7 @@
>  @check("pyflakes", "Pyflakes python linter")
>  def has_pyflakes():
>      return matchoutput(
> -        "sh -c \"echo 'import re' 2>&1 | pyflakes\"",
> +        "sh -c \"echo 'import re' 2>&1 | $PYTHON -m pyflakes\"",
>          br"<stdin>:1: 're' imported but unused",
>          True,

Perhaps, this can be rewritten as "try: import pyflakes" since we no longer
use the pyflakes executable.
Manuel Jacob - March 8, 2020, 10:26 p.m.
On 2020-03-08 06:24, Yuya Nishihara wrote:
> On Fri, 06 Mar 2020 23:05:06 +0100, Manuel Jacob wrote:
>> # HG changeset patch
>> # User Manuel Jacob <me@manueljacob.de>
>> # Date 1583532298 -3600
>> #      Fri Mar 06 23:04:58 2020 +0100
>> # Node ID 186c13bbb49fd4de4fd2c9983c3daf8fede5b177
>> # Parent  4ce2330f2d0b9690cc852602a9e055491a408c03
>> tests: use pyflakes module instead of pyflakes executable
> 
> Queued, thanks.
> 
>> diff --git a/tests/hghave.py b/tests/hghave.py
>> --- a/tests/hghave.py
>> +++ b/tests/hghave.py
>> @@ -553,7 +553,7 @@
>>  @check("pyflakes", "Pyflakes python linter")
>>  def has_pyflakes():
>>      return matchoutput(
>> -        "sh -c \"echo 'import re' 2>&1 | pyflakes\"",
>> +        "sh -c \"echo 'import re' 2>&1 | $PYTHON -m pyflakes\"",
>>          br"<stdin>:1: 're' imported but unused",
>>          True,
> 
> Perhaps, this can be rewritten as "try: import pyflakes" since we no 
> longer
> use the pyflakes executable.

I’m not sure whether that would work.

On my machine,

hghave.py is run with /tmp/hgtests.ds59p4hc/install/bin/python
$PYTHON is /bin/python3
Yuya Nishihara - March 9, 2020, 1:44 p.m.
On Sun, 08 Mar 2020 23:26:44 +0100, Manuel Jacob wrote:
> On 2020-03-08 06:24, Yuya Nishihara wrote:
> > On Fri, 06 Mar 2020 23:05:06 +0100, Manuel Jacob wrote:
> >> # HG changeset patch
> >> # User Manuel Jacob <me@manueljacob.de>
> >> # Date 1583532298 -3600
> >> #      Fri Mar 06 23:04:58 2020 +0100
> >> # Node ID 186c13bbb49fd4de4fd2c9983c3daf8fede5b177
> >> # Parent  4ce2330f2d0b9690cc852602a9e055491a408c03
> >> tests: use pyflakes module instead of pyflakes executable
> > 
> > Queued, thanks.
> > 
> >> diff --git a/tests/hghave.py b/tests/hghave.py
> >> --- a/tests/hghave.py
> >> +++ b/tests/hghave.py
> >> @@ -553,7 +553,7 @@
> >>  @check("pyflakes", "Pyflakes python linter")
> >>  def has_pyflakes():
> >>      return matchoutput(
> >> -        "sh -c \"echo 'import re' 2>&1 | pyflakes\"",
> >> +        "sh -c \"echo 'import re' 2>&1 | $PYTHON -m pyflakes\"",
> >>          br"<stdin>:1: 're' imported but unused",
> >>          True,
> > 
> > Perhaps, this can be rewritten as "try: import pyflakes" since we no 
> > longer
> > use the pyflakes executable.
> 
> I’m not sure whether that would work.
> 
> On my machine,
> 
> hghave.py is run with /tmp/hgtests.ds59p4hc/install/bin/python
> $PYTHON is /bin/python3

/install/bin/python should be a symlink to python3 if run-tests.py was
run by python3. Otherwise some other hghave rules wouldn't work.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -553,7 +553,7 @@ 
 @check("pyflakes", "Pyflakes python linter")
 def has_pyflakes():
     return matchoutput(
-        "sh -c \"echo 'import re' 2>&1 | pyflakes\"",
+        "sh -c \"echo 'import re' 2>&1 | $PYTHON -m pyflakes\"",
         br"<stdin>:1: 're' imported but unused",
         True,
     )
diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t
--- a/tests/test-check-pyflakes.t
+++ b/tests/test-check-pyflakes.t
@@ -20,7 +20,7 @@ 
   > -X mercurial/thirdparty/concurrent \
   > -X mercurial/thirdparty/zope \
   > 2>/dev/null \
-  > | xargs pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
+  > | xargs $PYTHON -m pyflakes 2>/dev/null | "$TESTDIR/filterpyflakes.py"
   contrib/perf.py:*: undefined name 'xrange' (glob) (?)
   mercurial/hgweb/server.py:*: undefined name 'reload' (glob) (?)
   mercurial/util.py:*: undefined name 'file' (glob) (?)