diff --git a/.travis.yml b/.travis.yml index 67ef535..aa96a57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 @@ -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. diff --git a/pyrepl/unix_console.py b/pyrepl/unix_console.py index 3ec9a7b..8cd6939 100644 --- a/pyrepl/unix_console.py +++ b/pyrepl/unix_console.py @@ -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() diff --git a/testing/infrastructure.py b/testing/infrastructure.py index e90298b..ca8784e 100644 --- a/testing/infrastructure.py +++ b/testing/infrastructure.py @@ -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 @@ -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 '' @@ -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'] diff --git a/testing/test_bugs.py b/testing/test_bugs.py index bc7367c..33d8b54 100644 --- a/testing/test_bugs.py +++ b/testing/test_bugs.py @@ -18,7 +18,7 @@ # 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 @@ -26,7 +26,7 @@ import pytest -class HistoricalTestReader(HistoricalReader, TestReader): +class HistoricalTestReader(HistoricalReader, BaseTestReader): pass @@ -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)