Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PyPy2 Windows IntegrationTests #76

Merged
merged 1 commit into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
# To activate, change the Appveyor settings to use `.appveyor.yml`.
install:
- python -m pip install tox
- python -m pip install --upgrade virtualenv pip setuptools tox

# Fetch the three main PyPy releases
- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy-2.6.1-win32.zip', "$env:appveyor_build_folder\pypy-2.6.1-win32.zip")
- ps: 7z x pypy-2.6.1-win32.zip | Out-Null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.6 is ... well very old. Why are we supporting that on Windows? That seems wasteful to say the least.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite its very low number, 2.6.1 is not old. It was released only a year ago. That series is/was the stable release. PyPy 2.6.1 is sys.version_info 2.7.10, which is the same as the latest PyPy2 5.x release, and it gets those users past the Python SSL problems. PyPy 5.x appears to be gaining traction as a replacement for PyPy 2.x.

Also, it costs us almost nothing? The time to add it to the image is negligible. There are no Windows specific bugs related to PyPy 2.x series; the only Windows specific bug anywhere in pyflakes is https://bitbucket.org/pypy/pypy/issues/2350 , which also occurs on the latest PyPy2 5.x release, and it is only a problem with our test framework -- not the program end-users are faced with.

As we test against Travis python: pypy, which is PyPy2.5 (sys.version_info 2.7.8), IMO it makes sense to bring our Windows testing to roughly the same level.

Without evidence otherwise, Windows users have been able to use pyflakes on PyPy2.x , and by adding this to the test matrix we ensure that if/when we do break that, we do it intentionally.

I expect we'd break it when Travis stops providing a 2.5/2.6 by default, or the existing pypy 2.5/2.6 workarounds start to really hurt. (afaik, the only painful aspect is the different column offsets in their error messages, which we should raise a bug in pypy so that problem can whittle away over time.)
I expect PyPy3 2.4 will be the first to be killed. While it has been added to this test matrix, I would be only too happy to remove it entirely just as soon as they provide a -win release of PyPy3 5.x, as it is Python 3.2, and anybody using that in production a second longer than they need to has bigger problems than their syntax checker no longer working.

- move pypy-2.6.1-win32 C:\

- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.3.1-win32.zip', "$env:appveyor_build_folder\pypy2-v5.3.1-win32.zip")
- ps: 7z x pypy2-v5.3.1-win32.zip | Out-Null
- move pypy2-v5.3.1-win32 C:\

- ps: (New-Object Net.WebClient).DownloadFile('https://bitbucket.org/pypy/pypy/downloads/pypy3-2.4.0-win32.zip', "$env:appveyor_build_folder\pypy3-2.4.0-win32.zip")
- ps: 7z x pypy3-2.4.0-win32.zip | Out-Null
- move pypy3-2.4.0-win32 C:\

# pypy3 installer provides 'pypy.exe', not pypy3.exe.
- copy C:\pypy3-2.4.0-win32\pypy.exe C:\pypy3-2.4.0-win32\pypy3.exe

# workaround https://github.com/pypa/virtualenv/issues/93
- mkdir C:\python33\tcl\tcl8.6
- mkdir C:\python33\tcl\tk8.6
- mkdir C:\pypy3-2.4.0-win32\tcl\tcl8.6
- mkdir C:\pypy3-2.4.0-win32\tcl\tk8.6

# Only pypy2-5.3.1 is integrated into tox, as pypy3-2.4.0 fails and
# a Windows distribution of pypy3-5.2 isnt available yet.
- ps: $env:path = "$env:path;C:\pypy2-v5.3.1-win32"

# pypy3-2.4.0 and pypy-2.6.1 are manually bootstrapped and tested
- ps: (New-Object Net.WebClient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', "$env:appveyor_build_folder\get-pip.py")
- git clone https://github.com/pypa/setuptools/
- cd setuptools
- C:\pypy3-2.4.0-win32\pypy3 bootstrap.py
- C:\pypy3-2.4.0-win32\pypy3 setup.py install
- C:\pypy-2.6.1-win32\pypy bootstrap.py
- C:\pypy-2.6.1-win32\pypy setup.py install
- cd ..

build: off

test_script:
- python -m tox
- C:\pypy3-2.4.0-win32\pypy3 setup.py test -q
- C:\pypy-2.6.1-win32\pypy setup.py test -q
26 changes: 25 additions & 1 deletion pyflakes/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import subprocess
import tempfile

from pyflakes.checker import PY2
from pyflakes.messages import UnusedImport
from pyflakes.reporter import Reporter
from pyflakes.api import (
Expand All @@ -30,6 +31,12 @@
except AttributeError:
PYPY = False

try:
WindowsError
WIN = True
except NameError:
WIN = False

ERROR_HAS_COL_NUM = ERROR_HAS_LAST_LINE = sys.version_info >= (3, 2) or PYPY


Expand Down Expand Up @@ -661,6 +668,9 @@ def runPyflakes(self, paths, stdin=None):
if sys.version_info >= (3,):
stdout = stdout.decode('utf-8')
stderr = stderr.decode('utf-8')
# Workaround https://bitbucket.org/pypy/pypy/issues/2350
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like there will be a fix in the next release
https://bitbucket.org/pypy/pypy/commits/85ea4f3912ce

if PYPY and PY2 and WIN:
stderr = stderr.replace('\r\r\n', '\r\n')
return (stdout, stderr, rv)

def test_goodFile(self):
Expand All @@ -685,7 +695,7 @@ def test_fileWithFlakes(self):
expected = UnusedImport(self.tempfilepath, Node(1), 'contraband')
self.assertEqual(d, ("%s%s" % (expected, os.linesep), '', 1))

def test_errors(self):
def test_errors_io(self):
"""
When pyflakes finds errors with the files it's given, (if they don't
exist, say), then the return code is non-zero and the errors are
Expand All @@ -696,6 +706,20 @@ def test_errors(self):
os.linesep)
self.assertEqual(d, ('', error_msg, 1))

def test_errors_syntax(self):
"""
When pyflakes finds errors with the files it's given, (if they don't
exist, say), then the return code is non-zero and the errors are
printed to stderr.
"""
fd = open(self.tempfilepath, 'wb')
fd.write("import".encode('ascii'))
fd.close()
d = self.runPyflakes([self.tempfilepath])
error_msg = '{0}:1:{2}: invalid syntax{1}import{1} {3}^{1}'.format(
self.tempfilepath, os.linesep, 5 if PYPY else 7, '' if PYPY else ' ')
self.assertEqual(d, ('', error_msg, True))

def test_readFromStdin(self):
"""
If no arguments are passed to C{pyflakes} then it reads from stdin.
Expand Down