From cd589b849e32a9df7bac85b47e8dd0d5f67b6283 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 17:22:30 +0200 Subject: [PATCH 01/13] ci: Travis: add osx and Windows jobs --- .travis.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.travis.yml b/.travis.yml index 67ef535..8aa7ce9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,23 @@ env: jobs: include: + - os: windows + language: shell + env: + - PATH=/c/Python37:/c/Python37/Scripts:$PATH + - TOXENV=py37-coverage + before_install: + - choco install --no-progress python + + - os: osx + osx_image: xcode10.2 + language: generic + env: TOXENV=py37-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 + - python: '2.7' env: TOXENV=py27-coverage - python: '3.4' From 72dcaa9de7b3351b4cae69db0d88dbdf31e8772b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 17:28:14 +0200 Subject: [PATCH 02/13] codecov: add TRAVIS_OS_NAME to flags --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8aa7ce9..44f4370 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,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. From a26879592718fee8506ac91eb333d55d2d5ff456 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 18:47:44 +0200 Subject: [PATCH 03/13] not supported on windows --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44f4370..7c2d912 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,6 @@ env: jobs: include: - - os: windows - language: shell - env: - - PATH=/c/Python37:/c/Python37/Scripts:$PATH - - TOXENV=py37-coverage - before_install: - - choco install --no-progress python - - os: osx osx_image: xcode10.2 language: generic From 81ba8abca1a12921af7368820831b34e1d587f8c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 18:50:21 +0200 Subject: [PATCH 04/13] skip test_signal_failure on osx Hangs. Ref: https://travis-ci.org/pypy/pyrepl/jobs/573154571#L146 --- testing/test_bugs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/test_bugs.py b/testing/test_bugs.py index bc7367c..e6ab5af 100644 --- a/testing/test_bugs.py +++ b/testing/test_bugs.py @@ -17,6 +17,8 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import sys + from pyrepl.historical_reader import HistoricalReader from .infrastructure import EA, TestReader, read_spec @@ -46,6 +48,7 @@ def test_cmd_instantiation_crash(): read_spec(spec, HistoricalTestReader) +@pytest.mark.skipif(sys.platform == "osx", reason="hangs on osx") def test_signal_failure(monkeypatch): import os import pty From 57b4aee8367ca945f3cc5ebe3a54ab7cc9334d4a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 19:04:32 +0200 Subject: [PATCH 05/13] tests: merge testing/{infrastructure,test_bugs}.py from PyPy (py3.6) --- testing/infrastructure.py | 19 ++++++++++++++++--- testing/test_bugs.py | 24 ++++++++++++------------ 2 files changed, 28 insertions(+), 15 deletions(-) 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 e6ab5af..2c4fc7c 100644 --- a/testing/test_bugs.py +++ b/testing/test_bugs.py @@ -17,10 +17,8 @@ # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -import sys - 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 @@ -28,7 +26,7 @@ import pytest -class HistoricalTestReader(HistoricalReader, TestReader): +class HistoricalTestReader(HistoricalReader, BaseTestReader): pass @@ -48,7 +46,8 @@ def test_cmd_instantiation_crash(): read_spec(spec, HistoricalTestReader) -@pytest.mark.skipif(sys.platform == "osx", reason="hangs on osx") +@pytest.mark.skipif("os.name != 'posix' or 'darwin' in sys.platform or " + "'kfreebsd' in sys.platform") def test_signal_failure(monkeypatch): import os import pty @@ -63,13 +62,14 @@ def really_failing_signal(a, b): mfd, sfd = pty.openpty() 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) + c.prepare() + c.restore() + monkeypatch.setattr(signal, 'signal', failing_signal) + c.prepare() + monkeypatch.setattr(signal, 'signal', really_failing_signal) + c.restore() finally: os.close(mfd) os.close(sfd) From 2021915c29a88e9474a76cc1075f4fdae0baae73 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 20:04:40 +0200 Subject: [PATCH 06/13] ci: PYTEST_ADDOPTS+=-vv --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7c2d912..c7ea7bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: python env: global: - - PYTEST_ADDOPTS="--cov --cov-report=xml" + - PYTEST_ADDOPTS="-vv --cov --cov-report=xml" jobs: include: From a20b35c39469265fa5134a4e96a3779b771bec57 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 20:29:11 +0200 Subject: [PATCH 07/13] TEMP: Travis: only osx --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7ea7bf..444da33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,22 +16,6 @@ jobs: - python -V - test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37 - - 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' - env: TOXENV=py37-coverage - - python: '3.8-dev' - env: TOXENV=py38-coverage - - python: 'pypy' - env: TOXENV=pypy-coverage - - python: 'pypy3' - env: TOXENV=pypy3-coverage # Fails currently badly. # - python: '3.7' # env: TOXENV=qa From f0028a2f99f9794ae2d49b1be88b5d20704e0130 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 20:29:26 +0200 Subject: [PATCH 08/13] debug test_signal_failure --- .travis.yml | 2 +- testing/test_bugs.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 444da33..5fd0951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: python env: global: - - PYTEST_ADDOPTS="-vv --cov --cov-report=xml" + - PYTEST_ADDOPTS="-s -vv --cov --cov-report=xml" jobs: include: diff --git a/testing/test_bugs.py b/testing/test_bugs.py index 2c4fc7c..33d8b54 100644 --- a/testing/test_bugs.py +++ b/testing/test_bugs.py @@ -46,8 +46,6 @@ def test_cmd_instantiation_crash(): read_spec(spec, HistoricalTestReader) -@pytest.mark.skipif("os.name != 'posix' or 'darwin' in sys.platform or " - "'kfreebsd' in sys.platform") def test_signal_failure(monkeypatch): import os import pty @@ -61,15 +59,22 @@ def really_failing_signal(a, b): raise AssertionError mfd, sfd = pty.openpty() + print("openpty", mfd, sfd) try: 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) From ac06c31353cb017b5555d4ffe7193130ea1e098c Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 20:31:01 +0200 Subject: [PATCH 09/13] pytest-timeout --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5fd0951..dc71366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: python env: global: - - PYTEST_ADDOPTS="-s -vv --cov --cov-report=xml" + - PYTEST_ADDOPTS="-s -vv --cov --cov-report=xml --timeout=30" jobs: include: @@ -15,6 +15,8 @@ jobs: - ln -sfn "$(which python3)" /usr/local/bin/python - python -V - test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37 + - tox --notest + - .tox/py37-coverage/bin/python -m pip install pytest-timeout # Fails currently badly. # - python: '3.7' From c9c24ad439533c0d7394b66e06e2e327b77cb95e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 20:33:16 +0200 Subject: [PATCH 10/13] debug restore --- pyrepl/unix_console.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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() From 172264051873ef86444976aabd572bd8504dfbd2 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 21:41:03 +0200 Subject: [PATCH 11/13] use before_install to install tox --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc71366..f245bcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ jobs: osx_image: xcode10.2 language: generic env: TOXENV=py37-coverage - before_install: + 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 @@ -22,7 +22,7 @@ jobs: # - python: '3.7' # env: TOXENV=qa -install: +before_install: - pip install tox script: From 6f48b6065e6244481c01a3cac67fef1cdf61cd29 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 21:42:05 +0200 Subject: [PATCH 12/13] Revert "use before_install to install tox" This reverts commit bddc9613e47c507873f01bee6d15f9a7d2be2302. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f245bcc..dc71366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ jobs: osx_image: xcode10.2 language: generic env: TOXENV=py37-coverage - install: + 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 @@ -22,7 +22,7 @@ jobs: # - python: '3.7' # env: TOXENV=qa -before_install: +install: - pip install tox script: From 7cf96e80784b02ca245bf0e0ccea7567d1c3ae9e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 17 Aug 2019 21:42:31 +0200 Subject: [PATCH 13/13] use before_script for pytest-timeout --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index dc71366..aa96a57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ jobs: - 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