diff --git a/.coveragerc b/.coveragerc index 2784a20bef0..dd73cf40030 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,6 @@ [run] +branch = True +source = tmuxp omit = tests/* */_vendor/* diff --git a/.travis.yml b/.travis.yml index 54638cce389..0fb0d3480f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,35 +1,37 @@ language: python -dist: precise +dist: trusty sudo: false python: - 2.7 - - 3.3 - - 3.4 - - 3.5 - 3.6 - pypy3.5-5.8.0 - pypy-5.6.0 env: - - TMUX_VERSION=master - - TMUX_VERSION=2.6 - - TMUX_VERSION=2.5 - - TMUX_VERSION=2.4 - - TMUX_VERSION=2.3 - - TMUX_VERSION=2.2 - - TMUX_VERSION=2.1 - - TMUX_VERSION=2.0 - - TMUX_VERSION=1.8 - - TMUX_VERSION=1.9a + global: + - RETRY_TIMEOUT_SECONDS=15 + matrix: + - TMUX_VERSION=master + - TMUX_VERSION=2.6 + - TMUX_VERSION=2.5 + - TMUX_VERSION=2.4 + - TMUX_VERSION=2.3 + - TMUX_VERSION=2.2 + - TMUX_VERSION=2.1 + - TMUX_VERSION=2.0 + - TMUX_VERSION=1.9a + - TMUX_VERSION=1.8 matrix: allow_failures: - env: TMUX_VERSION=master + before_install: - export PIP_USE_MIRRORS=true - pip install --upgrade pytest # https://github.com/travis-ci/travis-ci/issues/4873 - pip install --upgrade pip wheel virtualenv setuptools - - pip install coveralls + - pip install pytest-cov coverage codecov install: - pip install -e . + - pip install -r requirements/test.txt before_script: - git clone https://github.com/tmux/tmux.git tmux - cd tmux @@ -39,11 +41,11 @@ before_script: - export PATH=$HOME/tmux/bin:$PATH - cd .. - tmux -V -script: coverage run --source=tmuxp setup.py test +script: py.test --cov addons: apt: packages: - libevent-dev - libncurses-dev after_success: - - bash <(curl -s https://codecov.io/bash) + - codecov diff --git a/doc/developing.rst b/doc/developing.rst index 9c8f58c7e80..55def7bfbc3 100644 --- a/doc/developing.rst +++ b/doc/developing.rst @@ -187,6 +187,14 @@ tmuxp is tested against tmux 1.8 and the latest git source. Interpretters tested are 2.6, 2.7 and 3.3. The `travis build site`_ uses this `.travis.yml`_ configuration: +Testing options +--------------- + +``RETRY_TIMEOUT_SECONDS`` can be toggled if certain workspace builder +tests are being stubborn. + +e.g. ``RETRY_TIMEOUT_SECONDS=10 py.test `` + .. literalinclude:: ../.travis.yml :language: yaml diff --git a/requirements/test.txt b/requirements/test.txt index b41dff1365d..2c9d71008a3 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,2 +1,2 @@ -pytest==3.4.1 # Updated from 3.0.4 -pytest-rerunfailures==4.0 # Updated from 2.0.1 +pytest==3.4.1 +pytest-rerunfailures==4.0 diff --git a/setup.cfg b/setup.cfg index 615899d1dec..9cda12e03c3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,4 +3,4 @@ exclude = .*/,.tox,*.egg,tmuxp/_compat.py,tmuxp/__*__.py, select = E,W,F,N [tool:pytest] -addopts = --rerun 5 +addopts = --reruns=5 diff --git a/tests/test_workspacebuilder.py b/tests/test_workspacebuilder.py index 97ea40e955e..2a3d234e39e 100644 --- a/tests/test_workspacebuilder.py +++ b/tests/test_workspacebuilder.py @@ -22,6 +22,9 @@ from .fixtures._util import loadfixture +RETRY_TIMEOUT_SECONDS = int(os.getenv('RETRY_TIMEOUT_SECONDS', 8)) + + def test_split_windows(session): yaml_config = loadfixture("workspacebuilder/two_pane.yaml") s = session @@ -293,15 +296,17 @@ def test_window_options_after(session): def assert_last_line(p, s): correct = False - for _ in range(10): + timeout = time.time() + RETRY_TIMEOUT_SECONDS # seconds timeout + + while True: pane_out = p.cmd('capture-pane', '-p', '-J').stdout while not pane_out[-1].strip(): # delete trailing lines tmux 1.8 pane_out.pop() if len(pane_out) > 1 and pane_out[-2].strip() == s: correct = True break - - time.sleep(0.1) + elif time.time() > timeout: + break # Print output for easier debugging if assertion fails if not correct: @@ -390,31 +395,38 @@ def test_automatic_rename_option(session): assert s.name != 'tmuxp' w = s.windows[0] - for _ in range(10): + timeout = time.time() + RETRY_TIMEOUT_SECONDS # seconds timeout + while True: session.server._update_windows() if w.name != 'sh': break - time.sleep(.2) + elif time.time() > timeout: + break assert w.name != 'sh' pane_base_index = w.show_window_option('pane-base-index', g=True) w.select_pane(pane_base_index) - for _ in range(10): + timeout = time.time() + RETRY_TIMEOUT_SECONDS # seconds timeout + while True: session.server._update_windows() if w.name == 'sh': break - time.sleep(.3) + elif time.time() > timeout: + break assert w.name == text_type('sh') w.select_pane('-D') - for _ in range(10): + + timeout = time.time() + RETRY_TIMEOUT_SECONDS # seconds timeout + while True: session.server._update_windows() if w['window_name'] != 'sh': break - time.sleep(.2) + elif time.time() > timeout: + break assert w.name != text_type('sh')