Skip to content

ci: Travis: add osx job #19

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

Closed
wants to merge 13 commits into from
30 changes: 13 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@ language: python

env:
global:
- PYTEST_ADDOPTS="--cov --cov-report=xml"
- PYTEST_ADDOPTS="-s -vv --cov --cov-report=xml --timeout=30"

jobs:
include:
- python: '2.7'
env: TOXENV=py27-coverage
- python: '3.4'
env: TOXENV=py34-coverage
- python: '3.5'
env: TOXENV=py35-coverage
- python: '3.6'
env: TOXENV=py36-coverage
- python: '3.7'
- os: osx
osx_image: xcode10.2
language: generic
env: TOXENV=py37-coverage
- python: '3.8-dev'
env: TOXENV=py38-coverage
- python: 'pypy'
env: TOXENV=pypy-coverage
- python: 'pypy3'
env: TOXENV=pypy3-coverage
before_install:
- ln -sfn "$(which python3)" /usr/local/bin/python
- python -V
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37
before_script:
- tox --notest
- .tox/py37-coverage/bin/python -m pip install pytest-timeout

# Fails currently badly.
# - python: '3.7'
# env: TOXENV=qa
Expand All @@ -36,7 +32,7 @@ script:
after_script:
- |
if [[ "${TOXENV%-coverage}" != "$TOXENV" ]]; then
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -n $TOXENV
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -n $TOXENV -F "${TRAVIS_OS_NAME}"
fi

# Only master and releases. PRs are used otherwise.
Expand Down
8 changes: 8 additions & 0 deletions pyrepl/unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,25 @@ def prepare(self):
pass

def restore(self):
print("restore: 1")
self.__maybe_write_code(self._rmkx)
print("restore: 2")
self.flushoutput()
print("restore: 3")
tcsetattr(self.input_fd, termios.TCSADRAIN, self.__svtermstate)
print("restore: 4")

if hasattr(self, 'old_sigwinch'):
try:
print("restore: 5")
signal.signal(signal.SIGWINCH, self.old_sigwinch)
print("restore: 6")
del self.old_sigwinch
except ValueError:
print("restore: 7")
# signal only works in main thread.
pass
print("restore: end")

def __sigwinch(self, signum, frame):
self.height, self.width = self.getheightwidth()
Expand Down
19 changes: 16 additions & 3 deletions testing/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from __future__ import print_function
from contextlib import contextmanager
import os

from pyrepl.reader import Reader
from pyrepl.console import Console, Event

Expand Down Expand Up @@ -60,8 +63,7 @@ def getpending(self):
return Event('key', '', b'')


class TestReader(Reader):
__test__ = False
class BaseTestReader(Reader):

def get_prompt(self, lineno, cursor_on_line):
return ''
Expand All @@ -71,8 +73,19 @@ def refresh(self):
self.dirty = True


def read_spec(test_spec, reader_class=TestReader):
def read_spec(test_spec, reader_class=BaseTestReader):
# remember to finish your test_spec with 'accept' or similar!
con = TestConsole(test_spec, verbose=True)
reader = reader_class(con)
reader.readline()


@contextmanager
def sane_term():
"""Ensure a TERM that supports clear"""
old_term, os.environ['TERM'] = os.environ.get('TERM'), 'xterm'
yield
if old_term is not None:
os.environ['TERM'] = old_term
else:
del os.environ['TERM']
26 changes: 17 additions & 9 deletions testing/test_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from pyrepl.historical_reader import HistoricalReader
from .infrastructure import EA, TestReader, read_spec
from .infrastructure import EA, BaseTestReader, sane_term, read_spec

# this test case should contain as-verbatim-as-possible versions of
# (applicable) bug reports

import pytest


class HistoricalTestReader(HistoricalReader, TestReader):
class HistoricalTestReader(HistoricalReader, BaseTestReader):
pass


Expand Down Expand Up @@ -59,14 +59,22 @@ def really_failing_signal(a, b):
raise AssertionError

mfd, sfd = pty.openpty()
print("openpty", mfd, sfd)
try:
c = UnixConsole(sfd, sfd)
c.prepare()
c.restore()
monkeypatch.setattr(signal, 'signal', failing_signal)
c.prepare()
monkeypatch.setattr(signal, 'signal', really_failing_signal)
c.restore()
with sane_term():
c = UnixConsole(sfd, sfd)
print("c", c)
c.prepare()
print("prepared")
c.restore()
print("restored")
monkeypatch.setattr(signal, 'signal', failing_signal)
c.prepare()
print("prepared 2")
monkeypatch.setattr(signal, 'signal', really_failing_signal)
c.restore()
print("restored 2")
finally:
print("finally")
os.close(mfd)
os.close(sfd)