diff --git a/docs/source/usage/shell-prompts.rst b/docs/source/usage/shell-prompts.rst index 0a5c1f38..1ddb0a14 100644 --- a/docs/source/usage/shell-prompts.rst +++ b/docs/source/usage/shell-prompts.rst @@ -111,7 +111,7 @@ following in ``~/.profile``: .. code-block:: bash - if test "x$0" != "x${0#dash}" ; then + if test "$0" != "${0#dash}" ; then export ENV={repository_root}/powerline/bindings/shell/powerline.sh fi diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 75f8e08d..377c41a8 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -21,7 +21,7 @@ _powerline_tmux_setenv() { } _powerline_tmux_set_pwd() { - if test "x$_POWERLINE_SAVED_PWD" != "x$PWD" ; then + if test "$_POWERLINE_SAVED_PWD" != "$PWD" ; then _POWERLINE_SAVED_PWD="$PWD" _powerline_tmux_setenv PWD "$PWD" fi @@ -39,8 +39,8 @@ _powerline_init_tmux_support() { trap '_powerline_tmux_set_columns' WINCH _powerline_tmux_set_columns - test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND/_powerline_tmux_set_pwd}" || - PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n_powerline_tmux_set_pwd' + test "$PROMPT_COMMAND" != "${PROMPT_COMMAND/_powerline_tmux_set_pwd}" \ + || PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n_powerline_tmux_set_pwd' fi } @@ -82,8 +82,8 @@ _powerline_setup_prompt() { if test -z "${POWERLINE_COMMAND}" ; then POWERLINE_COMMAND="$("$POWERLINE_CONFIG_COMMAND" shell command)" fi - test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND%_powerline_set_prompt*}" || - PROMPT_COMMAND=$'_powerline_set_prompt\n'"${PROMPT_COMMAND}" + test "$PROMPT_COMMAND" != "${PROMPT_COMMAND%_powerline_set_prompt*}" \ + || PROMPT_COMMAND=$'_powerline_set_prompt\n'"${PROMPT_COMMAND}" PS2="$(_powerline_local_prompt left -r.bash 0 0 continuation)" PS3="$(_powerline_local_prompt left '' 0 0 select)" } diff --git a/powerline/bindings/fish/powerline-setup.fish b/powerline/bindings/fish/powerline-setup.fish index 44d03287..3887138f 100644 --- a/powerline/bindings/fish/powerline-setup.fish +++ b/powerline/bindings/fish/powerline-setup.fish @@ -34,7 +34,7 @@ function powerline-setup set -g POWERLINE_COMMAND (env $POWERLINE_CONFIG_COMMAND shell command) end function _powerline_set_default_mode --on-variable fish_key_bindings - if test x$fish_key_bindings != xfish_vi_key_bindings + if test $fish_key_bindings != fish_vi_key_bindings set -g _POWERLINE_DEFAULT_MODE default else set -g -e _POWERLINE_DEFAULT_MODE diff --git a/powerline/bindings/rc/powerline.rc b/powerline/bindings/rc/powerline.rc index a6d96eff..b2d6538f 100644 --- a/powerline/bindings/rc/powerline.rc +++ b/powerline/bindings/rc/powerline.rc @@ -37,7 +37,7 @@ fn _powerline_common_setup { } fn _powerline_tmux_pane { - if (test x$TMUX_PANE '!=' x) { + if (test -n $TMUX_PANE) { echo $TMUX_PANE | tr -d ' %' } else { TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d ' %' @@ -54,9 +54,9 @@ if (test -z $POWERLINE_CONFIG_COMMAND) { echo powerline-config executable not found, unable to proceed >[2=1] } } -if (test x$POWERLINE_CONFIG_COMMAND '!=' x) { +if (test -n $POWERLINE_CONFIG_COMMAND) { if ($POWERLINE_CONFIG_COMMAND shell --shell rcsh uses prompt) { - if (test x$POWERLINE_COMMAND_ARGS '!=' x) { + if (test -n $POWERLINE_COMMAND_ARGS) { # Perform splitting POWERLINE_COMMAND_ARGS=( `{echo $POWERLINE_COMMAND_ARGS} ) } @@ -75,11 +75,11 @@ if (test x$POWERLINE_CONFIG_COMMAND '!=' x) { } _powerline_common_setup } - if (test x$TMUX '!=' x) { + if (test -n $TMUX) { if ($POWERLINE_CONFIG_COMMAND shell --shell rcsh uses tmux) { _POWERLINE_TMUX=$TMUX fn _powerline_tmux_setenv { - if (test x$2 '!=' x) { + if (test -n $2) { TMUX=$_POWERLINE_TMUX tmux setenv -g TMUX_$1^_`{ _powerline_tmux_pane } $2 diff --git a/powerline/bindings/shell/powerline.sh b/powerline/bindings/shell/powerline.sh index d2339a1b..15e13f26 100644 --- a/powerline/bindings/shell/powerline.sh +++ b/powerline/bindings/shell/powerline.sh @@ -115,7 +115,7 @@ _powerline_tmux_setenv() { } _powerline_tmux_set_pwd() { - if test "x$_POWERLINE_SAVED_PWD" != "x$PWD" ; then + if test "$_POWERLINE_SAVED_PWD" != "$PWD" ; then _POWERLINE_SAVED_PWD="$PWD" _powerline_tmux_setenv PWD "$PWD" fi diff --git a/powerline/bindings/zsh/__init__.py b/powerline/bindings/zsh/__init__.py index 1f93d272..1037bba2 100644 --- a/powerline/bindings/zsh/__init__.py +++ b/powerline/bindings/zsh/__init__.py @@ -111,7 +111,7 @@ if hasattr(zsh, 'expand') and zsh.expand('${:-}') == '': zsh_expand = zsh.expand else: def zsh_expand(s): - zsh.eval('_POWERLINE_REPLY="' + s + '"') + zsh.eval('local _POWERLINE_REPLY="' + s + '"') ret = zsh.getvalue('_POWERLINE_REPLY') zsh.setvalue('_POWERLINE_REPLY', None) return ret diff --git a/tests/__init__.py b/tests/__init__.py index 9a961acd..e69de29b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,11 +0,0 @@ -# vim:fileencoding=utf-8:noet -from __future__ import (unicode_literals, division, absolute_import, print_function) - -import sys - -if sys.version_info < (2, 7): - from unittest2 import TestCase, main # NOQA - from unittest2.case import SkipTest # NOQA -else: - from unittest import TestCase, main # NOQA - from unittest.case import SkipTest # NOQA diff --git a/tests/common.sh b/tests/common.sh deleted file mode 100644 index eb3bbab7..00000000 --- a/tests/common.sh +++ /dev/null @@ -1,42 +0,0 @@ -. tests/bot-ci/scripts/common/main.sh -set +x - -: ${PYTHON:=python} - -FAILED=0 - -FAIL_SUMMARY="" - -enter_suite() { - local suite_name="$1" - export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name" -} - -exit_suite() { - if test $FAILED -ne 0 ; then - echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:" - echo "${FAIL_SUMMARY}" - fi - export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE%/*}" - if test "x$1" != "x--continue" ; then - exit $FAILED - fi -} - -fail() { - local allow_failure= - if test "x$1" = "x--allow-failure" ; then - shift - allow_failure=A - fi - local test_name="$1" - local fail_char="$allow_failure$2" - local message="$3" - local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message" - FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" - echo "Failed: $full_msg" - echo "$full_msg" >> tests/failures - if test "x$allow_failure" = "x" ; then - FAILED=1 - fi -} diff --git a/tests/install.sh b/tests/install.sh index d9fb48af..b83b529a 100755 --- a/tests/install.sh +++ b/tests/install.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e +set -x remote_master_hex() { local url="$1" @@ -16,7 +17,7 @@ checkout_cached_dir() { fi if ! test -d "$target" ; then git clone --depth=1 "$url" "$target" - mv "$target"/.git/refs/heads/master .version + git rev-parse HEAD > .version rm -rf "$target"/.git fi } diff --git a/tests/lib/terminal.py b/tests/lib/terminal.py deleted file mode 100644 index 29177e2a..00000000 --- a/tests/lib/terminal.py +++ /dev/null @@ -1,137 +0,0 @@ -# vim:fileencoding=utf-8:noet -from __future__ import (unicode_literals, division, absolute_import, print_function) - -import threading - -from time import sleep -from itertools import groupby -from signal import SIGKILL - -import pexpect - -from tests.lib.vterm import VTerm, Dimensions - - -class MutableDimensions(object): - def __init__(self, rows, cols): - super(MutableDimensions, self).__init__() - self._list = [rows, cols] - - def __getitem__(self, idx): - return self._list[idx] - - def __setitem__(self, idx, val): - self._list[idx] = val - - def __iter__(self): - return iter(self._list) - - def __len__(self): - return 2 - - def __nonzero__(self): - return True - - __bool__ = __nonzero__ - - rows = property( - fget = lambda self: self._list[0], - fset = lambda self, val: self._list.__setitem__(0, val), - ) - cols = property( - fget = lambda self: self._list[1], - fset = lambda self, val: self._list.__setitem__(1, val), - ) - - -class ExpectProcess(threading.Thread): - def __init__(self, lib, dim, cmd, args, cwd=None, env=None): - super(ExpectProcess, self).__init__() - self.vterm = VTerm(lib, dim) - self.lock = threading.Lock() - self.dim = Dimensions(*dim) - self.cmd = cmd - self.args = args - self.cwd = cwd - self.env = env - self.buffer = [] - self.child_lock = threading.Lock() - self.shutdown_event = threading.Event() - - def run(self): - child = pexpect.spawn(self.cmd, self.args, cwd=self.cwd, env=self.env) - sleep(0.5) - child.setwinsize(self.dim.rows, self.dim.cols) - sleep(0.5) - self.child = child - status = None - while status is None and not self.shutdown_event.is_set(): - try: - with self.child_lock: - s = child.read_nonblocking(size=1024, timeout=0) - status = child.status - except pexpect.TIMEOUT: - pass - except pexpect.EOF: - break - else: - with self.lock: - self.vterm.push(s) - self.buffer.append(s) - - if status is None: - child.kill(SIGKILL) - - def kill(self): - self.shutdown_event.set() - - def resize(self, dim): - with self.child_lock: - self.dim = Dimensions(*dim) - self.child.setwinsize(self.dim.rows, self.dim.cols) - self.vterm.resize(self.dim) - - def __getitem__(self, position): - with self.lock: - return self.vterm.vtscreen[position] - - def read(self): - with self.lock: - ret = b''.join(self.buffer) - del self.buffer[:] - return ret - - def send(self, data): - with self.child_lock: - self.child.send(data) - - def get_highlighted_text(self, text, attrs, default_props=()): - ret = [] - new_attrs = attrs.copy() - for cell_properties, segment_text in text: - segment_text = segment_text.translate({'{': '{{', '}': '}}'}) - if cell_properties not in new_attrs: - new_attrs[cell_properties] = len(new_attrs) + 1 - props_name = new_attrs[cell_properties] - if props_name in default_props: - ret.append(segment_text) - else: - ret.append('{' + str(props_name) + ':' + segment_text + '}') - return ''.join(ret), new_attrs - - def get_row(self, row, attrs, default_props=()): - with self.lock: - return self.get_highlighted_text(( - (key, ''.join((cell.text for cell in subline))) - for key, subline in groupby(( - self.vterm.vtscreen[row, col] - for col in range(self.dim.cols) - ), lambda cell: cell.cell_properties_key) - ), attrs, default_props) - - def get_screen(self, attrs, default_props=()): - lines = [] - for row in range(self.dim.rows): - line, attrs = self.get_row(row, attrs, default_props) - lines.append(line) - return '\n'.join(lines), attrs diff --git a/tests/modules/__init__.py b/tests/modules/__init__.py new file mode 100644 index 00000000..9a961acd --- /dev/null +++ b/tests/modules/__init__.py @@ -0,0 +1,11 @@ +# vim:fileencoding=utf-8:noet +from __future__ import (unicode_literals, division, absolute_import, print_function) + +import sys + +if sys.version_info < (2, 7): + from unittest2 import TestCase, main # NOQA + from unittest2.case import SkipTest # NOQA +else: + from unittest import TestCase, main # NOQA + from unittest.case import SkipTest # NOQA diff --git a/tests/lib/__init__.py b/tests/modules/lib/__init__.py similarity index 100% rename from tests/lib/__init__.py rename to tests/modules/lib/__init__.py diff --git a/tests/lib/config_mock.py b/tests/modules/lib/config_mock.py similarity index 98% rename from tests/lib/config_mock.py rename to tests/modules/lib/config_mock.py index eaba015d..900b60fa 100644 --- a/tests/lib/config_mock.py +++ b/tests/modules/lib/config_mock.py @@ -12,7 +12,7 @@ from powerline.renderer import Renderer from powerline.lib.config import ConfigLoader from powerline import Powerline, get_default_theme -from tests.lib import Args, replace_attr +from tests.modules.lib import Args, replace_attr UT = get_default_theme(is_unicode=True) @@ -175,7 +175,7 @@ def get_powerline(config, **kwargs): TestPowerline, _helpers=helpers, ext='test', - renderer_module='tests.lib.config_mock', + renderer_module='tests.modules.lib.config_mock', logger=Logger(), **kwargs ) diff --git a/tests/lib/fsconfig.py b/tests/modules/lib/fsconfig.py similarity index 97% rename from tests/lib/fsconfig.py rename to tests/modules/lib/fsconfig.py index 248a3a70..757e8743 100644 --- a/tests/lib/fsconfig.py +++ b/tests/modules/lib/fsconfig.py @@ -59,7 +59,7 @@ class FSTree(object): self.p = TestPowerline( _paths=self.get_config_paths(self.root), ext='test', - renderer_module='tests.lib.config_mock', + renderer_module='tests.modules.lib.config_mock', **self.p_kwargs ) if os.environ.get('POWERLINE_RUN_LINT_DURING_TESTS'): diff --git a/tests/modules/lib/terminal.py b/tests/modules/lib/terminal.py new file mode 100644 index 00000000..75bcf4e2 --- /dev/null +++ b/tests/modules/lib/terminal.py @@ -0,0 +1,269 @@ +# vim:fileencoding=utf-8:noet +from __future__ import (unicode_literals, division, absolute_import, print_function) + +import threading +import os + +from time import sleep +from itertools import groupby +from signal import SIGKILL +from difflib import ndiff + +import pexpect + +from powerline.lib.unicode import u + +from tests.modules.lib.vterm import VTerm, Dimensions + + +class MutableDimensions(object): + def __init__(self, rows, cols): + super(MutableDimensions, self).__init__() + self._list = [rows, cols] + + def __getitem__(self, idx): + return self._list[idx] + + def __setitem__(self, idx, val): + self._list[idx] = val + + def __iter__(self): + return iter(self._list) + + def __len__(self): + return 2 + + def __nonzero__(self): + return True + + __bool__ = __nonzero__ + + rows = property( + fget = lambda self: self._list[0], + fset = lambda self, val: self._list.__setitem__(0, val), + ) + cols = property( + fget = lambda self: self._list[1], + fset = lambda self, val: self._list.__setitem__(1, val), + ) + + +class ExpectProcess(threading.Thread): + def __init__(self, lib, dim, cmd, args, cwd=None, env=None): + super(ExpectProcess, self).__init__() + self.vterm = VTerm(lib, dim) + self.lock = threading.Lock() + self.dim = Dimensions(*dim) + self.cmd = cmd + self.args = args + self.cwd = cwd + self.env = env + self.buffer = [] + self.child_lock = threading.Lock() + self.shutdown_event = threading.Event() + + def run(self): + child = pexpect.spawn(self.cmd, self.args, cwd=self.cwd, env=self.env) + sleep(0.5) + child.setwinsize(self.dim.rows, self.dim.cols) + sleep(0.5) + self.child = child + status = None + while status is None and not self.shutdown_event.is_set(): + try: + with self.child_lock: + s = child.read_nonblocking(size=1024, timeout=0) + status = child.status + except pexpect.TIMEOUT: + pass + except pexpect.EOF: + break + else: + with self.lock: + self.vterm.push(s) + self.buffer.append(s) + + if status is None: + child.kill(SIGKILL) + + def kill(self): + self.shutdown_event.set() + + def resize(self, dim): + with self.child_lock: + self.dim = Dimensions(*dim) + self.child.setwinsize(self.dim.rows, self.dim.cols) + self.vterm.resize(self.dim) + + def __getitem__(self, position): + with self.lock: + return self.vterm.vtscreen[position] + + def read(self): + with self.lock: + ret = b''.join(self.buffer) + del self.buffer[:] + return ret + + def send(self, data): + with self.child_lock: + self.child.send(data) + + def get_highlighted_text(self, text, attrs, default_props=()): + ret = [] + new_attrs = attrs.copy() + for cell_properties, segment_text in text: + segment_text = segment_text.translate({'{': '{{', '}': '}}'}) + if cell_properties not in new_attrs: + new_attrs[cell_properties] = len(new_attrs) + 1 + props_name = new_attrs[cell_properties] + if props_name in default_props: + ret.append(segment_text) + else: + ret.append('{' + str(props_name) + ':' + segment_text + '}') + return ''.join(ret), new_attrs + + def get_row(self, row, attrs, default_props=()): + with self.lock: + return self.get_highlighted_text(( + (key, ''.join((cell.text for cell in subline))) + for key, subline in groupby(( + self.vterm.vtscreen[row, col] + for col in range(self.dim.cols) + ), lambda cell: cell.cell_properties_key) + ), attrs, default_props) + + def get_screen(self, attrs, default_props=()): + lines = [] + for row in range(self.dim.rows): + line, attrs = self.get_row(row, attrs, default_props) + lines.append(line) + return '\n'.join(lines), attrs + + +def test_expected_result(p, test, last_attempt, last_attempt_cb=None): + expected_text, attrs = test['expected_result'] + attempts = 3 + result = None + while attempts: + actual_text, all_attrs = p.get_row(test['row'], attrs) + if actual_text == expected_text: + return True + attempts -= 1 + print('Actual result does not match expected. Attempts left: {0}.'.format(attempts)) + sleep(2) + print('Result:') + print(actual_text) + print('Expected:') + print(expected_text) + print('Attributes:') + print(all_attrs) + print('Screen:') + screen, screen_attrs = p.get_screen(attrs) + print(screen) + print(screen_attrs) + print('_' * 80) + print('Diff:') + print('=' * 80) + print(''.join(( + u(line) for line in ndiff([actual_text + '\n'], [expected_text + '\n'])) + )) + if last_attempt and last_attempt_cb: + last_attempt_cb() + return False + + +ENV_BASE = { + # Reasoning: + # 1. vt* TERMs (used to be vt100 here) make tmux-1.9 use different and + # identical colors for inactive windows. This is not like tmux-1.6: + # foreground color is different from separator color and equal to (0, + # 102, 153) for some reason (separator has correct color). tmux-1.8 is + # fine, so are older versions (though tmux-1.6 and tmux-1.7 do not have + # highlighting for previously active window) and my system tmux-1.9a. + # 2. screen, xterm and some other non-256color terminals both have the same + # issue and make libvterm emit complains like `Unhandled CSI SGR 3231`. + # 3. screen-256color, xterm-256color and other -256color terminals make + # libvterm emit complains about unhandled escapes to stderr. + # 4. `st-256color` does not have any of the above problems, but it may be + # not present on the target system because it is installed with + # x11-terms/st and not with sys-libs/ncurses. + # + # For the given reasons decision was made: to fix tmux-1.9 tests and not + # make libvterm emit any data to stderr st-256color $TERM should be used, up + # until libvterm has its own terminfo database entry (if it ever will). To + # make sure that relevant terminfo entry is present on the target system it + # should be distributed with powerline test package. To make distribution + # not require modifying anything outside of powerline test directory + # TERMINFO variable is set. + # + # This fix propagates to non-tmux vterm tests just in case. + 'TERM': 'st-256color', + # Also $TERMINFO definition in get_env + + 'POWERLINE_CONFIG_PATHS': os.path.abspath('powerline/config_files'), + 'POWERLINE_COMMAND': 'powerline-render', + 'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH', ''), + 'PYTHONPATH': os.environ.get('PYTHONPATH', ''), +} + + +def get_env(vterm_path, test_dir, *args, **kwargs): + env = ENV_BASE.copy() + env.update({ + 'TERMINFO': os.path.join(test_dir, 'terminfo'), + 'PATH': vterm_path, + 'SHELL': os.path.join(vterm_path, 'bash'), + }) + env.update(*args, **kwargs) + return env + + +def do_terminal_tests(tests, cmd, dim, args, env, cwd=None, fin_cb=None, + last_attempt_cb=None, attempts=3): + lib = os.environ.get('POWERLINE_LIBVTERM') + if not lib: + if os.path.exists('tests/bot-ci/deps/libvterm/libvterm.so'): + lib = 'tests/bot-ci/deps/libvterm/libvterm.so' + else: + lib = 'libvterm.so' + + while attempts: + try: + p = ExpectProcess( + lib=lib, + dim=dim, + cmd=cmd, + args=args, + cwd=cwd, + env=env, + ) + p.start() + + ret = True + + for test in tests: + try: + test_prep = test['prep_cb'] + except KeyError: + pass + else: + test_prep(p) + ret = ( + ret + and test_expected_result(p, test, attempts == 0, + last_attempt_cb) + ) + + if ret: + return ret + finally: + if fin_cb: + fin_cb(p=p, cmd=cmd, env=env) + p.kill() + p.join(10) + assert(not p.isAlive()) + + attempts -= 1 + + return False diff --git a/tests/lib/vterm.py b/tests/modules/lib/vterm.py similarity index 100% rename from tests/lib/vterm.py rename to tests/modules/lib/vterm.py diff --git a/tests/matchers.py b/tests/modules/matchers.py similarity index 100% rename from tests/matchers.py rename to tests/modules/matchers.py diff --git a/tests/vim.py b/tests/modules/vim.py similarity index 100% rename from tests/vim.py rename to tests/modules/vim.py diff --git a/tests/run_daemon_tests.sh b/tests/run_daemon_tests.sh deleted file mode 100755 index af68eacf..00000000 --- a/tests/run_daemon_tests.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -. tests/common.sh - -enter_suite daemon - -export ADDRESS="powerline-ipc-test-$$" -echo "Powerline address: $ADDRESS" -if $PYTHON scripts/powerline-daemon -s$ADDRESS ; then - sleep 1 - if ! ( \ - $PYTHON client/powerline.py --socket $ADDRESS -p/dev/null shell left | \ - grep 'file not found' - ) ; then - fail "devnull" F "-p/dev/null argument ignored or not treated properly" - fi - if ( \ - $PYTHON client/powerline.py --socket $ADDRESS \ - -p$PWD/powerline/config_files shell left | \ - grep 'file not found' - ) ; then - fail "nodevnull" F "-p/dev/null argument remembered while it should not" - fi - if ! ( \ - cd tests && \ - $PYTHON ../client/powerline.py --socket $ADDRESS \ - -p$PWD/../powerline/config_files shell left | \ - grep 'tests' - ) ; then - fail "segment" F "Output lacks string “tests”" - fi -else - fail "exitcode" E "Daemon exited with status $?" -fi -if $PYTHON scripts/powerline-daemon -s$ADDRESS -k ; then - : -else - fail "-k" F "powerline-daemon -k failed with exit code $?" -fi - -exit_suite diff --git a/tests/run_lint_tests.sh b/tests/run_lint_tests.sh deleted file mode 100755 index 585e7a03..00000000 --- a/tests/run_lint_tests.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -. tests/common.sh - -enter_suite lint - -if ! ${PYTHON} scripts/powerline-lint -p powerline/config_files ; then - fail "test" F "Running powerline-lint failed" -fi - -exit_suite diff --git a/tests/run_shell_tests.sh b/tests/run_shell_tests.sh deleted file mode 100755 index 29e6fac7..00000000 --- a/tests/run_shell_tests.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -exit 0 -FAILED=0 -if ! sh tests/test_shells/test.sh --fast ; then - echo "Failed shells" - FAILED=1 -fi -exit $FAILED diff --git a/tests/run_vim_tests.sh b/tests/run_vim_tests.sh deleted file mode 100755 index c32831db..00000000 --- a/tests/run_vim_tests.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -. tests/common.sh - -enter_suite vim - -if test -z "$VIM" ; then - if test -n "$USE_UCS2_PYTHON" ; then - NEW_VIM="$ROOT/tests/bot-ci/deps/vim/master-$UCS2_PYTHON_VARIANT-ucs2-double/vim" - OLD_VIM="$ROOT/tests/bot-ci/deps/vim/v7.0.112-$UCS2_PYTHON_VARIANT-ucs2/vim" - opt_dir="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT" - main_path="$opt_dir/lib/python$UCS2_PYTHON_VARIANT" - site_path="$main_path/site-packages" - venv_main_path="$VIRTUAL_ENV/lib/python$UCS2_PYTHON_VARIANT" - venv_site_path="$venv_main_path/site-packages" - new_paths="${main_path}:${site_path}:${venv_main_path}:${venv_site_path}" - export PYTHONPATH="$new_paths${PYTHONPATH:+:}$PYTHONPATH" - else - if test "$PYTHON_IMPLEMENTATION" != "CPython" ; then - exit 0 - fi - if test -d "$ROOT/tests/bot-ci/deps" ; then - NEW_VIM="$ROOT/tests/bot-ci/deps/vim/master-$PYTHON_MM/vim" - OLD_VIM="$ROOT/tests/bot-ci/deps/vim/v7.0.112-$PYTHON_MM/vim" - else - NEW_VIM="vim" - fi - if test -e "$OLD_VIM" ; then - VIMS="NEW_VIM OLD_VIM" - else - VIMS="NEW_VIM" - fi - fi -else - NEW_VIM="$VIM" - OLD_VIM="$VIM" -fi - -# Define some overrides. These ones must be ignored and do not affect Vim -# status/tab lines. -export POWERLINE_CONFIG_OVERRIDES='common.default_top_theme=ascii' -export POWERLINE_THEME_OVERRIDES='default.segments.left=[]' - -test_script() { - local vim="$1" - local script="$2" - local test_name_prefix="$3" - echo "Running script $script with $vim" - if ! test -e "$vim" ; then - return 0 - fi - if ! "$vim" -u NONE -S $script || test -f message.fail ; then - local test_name="$test_name_prefix-${script##*/}" - fail "${test_name%.vim}" F "Failed script $script run with $VIM" - cat message.fail >&2 - rm message.fail - fi -} - -for script in tests/test_*.vim ; do - if test "${script%.old.vim}" = "${script}" ; then - test_script "$NEW_VIM" "$script" new - fi -done - -if test -e "$OLD_VIM" ; then - for script in tests/test_*.old.vim ; do - test_script "$OLD_VIM" "$script" old - done -fi - -exit_suite diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh new file mode 100644 index 00000000..a95d8044 --- /dev/null +++ b/tests/shlib/common.sh @@ -0,0 +1,86 @@ +. tests/bot-ci/scripts/common/main.sh +set +x + +: ${PYTHON:=python} +: ${USER:=`id -un`} +: ${HOME:=`getent passwd $USER | cut -d: -f6`} + +export USER HOME + +if test -z "$FAILED" ; then + FAILED=0 + + FAIL_SUMMARY="" + + TMP_ROOT="$ROOT/tests/tmp" + FAILURES_FILE="$ROOT/tests/failures" +fi + +enter_suite() { + local suite_name="$1" ; shift + export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name" +} + +exit_suite() { + if test "$POWERLINE_CURRENT_SUITE" = "$POWERLINE_TMP_DIR_SUITE" ; then + rm_test_root + fi + if test $FAILED -ne 0 ; then + echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:" + echo "${FAIL_SUMMARY}" + fi + export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE%/*}" + if test "$1" != "--continue" ; then + exit $FAILED + fi +} + +fail() { + local allow_failure= + if test "$1" = "--allow-failure" ; then + shift + allow_failure=A + fi + local test_name="$1" ; shift + local fail_char="$allow_failure$1" ; shift + local message="$1" ; shift + local full_msg="$fail_char $POWERLINE_CURRENT_SUITE|$test_name :: $message" + FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" + echo "Failed: $full_msg" + echo "$full_msg" >> "$FAILURES_FILE" + if test -z "$allow_failure" ; then + FAILED=1 + fi +} + +make_test_root() { + local suffix="${POWERLINE_CURRENT_SUITE##*/}" + + local tmpdir="$TMP_ROOT/$suffix/" + export POWERLINE_TMP_DIR_SUITE="$POWERLINE_CURRENT_SUITE" + + if test -d "$tmpdir" ; then + rm -r "$tmpdir" + fi + + mkdir -p "$tmpdir" + + export TEST_ROOT="$tmpdir" +} + +rm_test_root() { + if test -e "$FAILURES_FILE" ; then + return 0 + fi + local suffix="${POWERLINE_CURRENT_SUITE##*/}" + if test -d "$TMP_ROOT/$suffix" ; then + rm -r "$TMP_ROOT/$suffix" + rmdir "$TMP_ROOT" &>/dev/null || true + fi +} + +if ! which realpath ; then + realpath() { + $PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1" + } +fi diff --git a/tests/shlib/vim.sh b/tests/shlib/vim.sh new file mode 100644 index 00000000..49346dac --- /dev/null +++ b/tests/shlib/vim.sh @@ -0,0 +1,33 @@ +. tests/bot-ci/scripts/common/main.sh + +if test -z "$POWERLINE_VIM_EXE" ; then + if test -n "$USE_UCS2_PYTHON" ; then + NEW_VIM="$ROOT/tests/bot-ci/deps/vim/master-$UCS2_PYTHON_VARIANT-ucs2-double/vim" + OLD_VIM="$ROOT/tests/bot-ci/deps/vim/v7.0.112-$UCS2_PYTHON_VARIANT-ucs2/vim" + opt_dir="$HOME/opt/cpython-ucs2-$UCS2_PYTHON_VARIANT" + main_path="$opt_dir/lib/python$UCS2_PYTHON_VARIANT" + site_path="$main_path/site-packages" + venv_main_path="$VIRTUAL_ENV/lib/python$UCS2_PYTHON_VARIANT" + venv_site_path="$venv_main_path/site-packages" + new_paths="${main_path}:${site_path}:${venv_main_path}:${venv_site_path}" + export PYTHONPATH="$new_paths${PYTHONPATH:+:}$PYTHONPATH" + else + if test "$PYTHON_IMPLEMENTATION" != "CPython" ; then + exit 0 + fi + if test -d "$ROOT/tests/bot-ci/deps" ; then + NEW_VIM="$ROOT/tests/bot-ci/deps/vim/master-$PYTHON_MM/vim" + OLD_VIM="$ROOT/tests/bot-ci/deps/vim/v7.0.112-$PYTHON_MM/vim" + else + NEW_VIM="vim" + fi + if test -e "$OLD_VIM" ; then + VIMS="NEW_VIM OLD_VIM" + else + VIMS="NEW_VIM" + fi + fi +else + NEW_VIM="$POWERLINE_VIM_EXE" + OLD_VIM="$POWERLINE_VIM_EXE" +fi diff --git a/tests/shlib/vterm.sh b/tests/shlib/vterm.sh new file mode 100644 index 00000000..5017827f --- /dev/null +++ b/tests/shlib/vterm.sh @@ -0,0 +1,26 @@ +. tests/shlib/common.sh +. tests/bot-ci/scripts/common/main.sh +set +x + +vterm_setup() { + local test_dir="$1" ; shift + + rm -rf "$test_dir" + mkdir "$test_dir" + mkdir "$test_dir/path" + + ln -s "$(which "${PYTHON}")" "$test_dir/path/python" + ln -s "$(which bash)" "$test_dir/path" + + cp -r "$ROOT/tests/terminfo" "$test_dir" +} + +vterm_shutdown() { + local test_dir="$1" ; shift + + if test $FAILED -eq 0 ; then + rm -rf "$test_dir" + else + echo "$FAIL_SUMMARY" + fi +} diff --git a/tests/test.sh b/tests/test.sh index 68bd9310..1c6f9881 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,13 +1,8 @@ #!/bin/bash -. tests/common.sh +. tests/shlib/common.sh enter_suite root -: ${USER:=`id -un`} -: ${HOME:=`getent passwd $USER | cut -d: -f6`} - -export USER HOME - if test "$TRAVIS" = true ; then export PATH="$HOME/opt/fish/bin:${PATH}" export PATH="$PWD/tests/bot-ci/deps/rc:$PATH" @@ -22,18 +17,16 @@ if test "$TRAVIS" = true ; then . virtualenvwrapper.sh workon cpython-ucs2-$UCS2_PYTHON_VARIANT set -e + else + LIBRARY_PATH="$(ldd "$(which python)" | grep libpython | sed 's/^.* => //;s/ .*$//')" + LIBRARY_DIR="$(dirname "${LIBRARY_PATH}")" + export LD_LIBRARY_PATH="$LIBRARY_DIR${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" fi fi -if ! which realpath ; then - realpath() { - $PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1" - } -fi - export PYTHON="${PYTHON:=python}" export PYTHONPATH="${PYTHONPATH}${PYTHONPATH:+:}`realpath .`" -for script in tests/run_*_tests.sh ; do +for script in "$ROOT"/tests/test_*/test.sh ; do test_name="${script##*/run_}" if ! sh $script ; then fail "${test_name%_tests.sh}" F "Failed $script" diff --git a/tests/run_awesome_tests.sh b/tests/test_awesome/test.sh similarity index 91% rename from tests/run_awesome_tests.sh rename to tests/test_awesome/test.sh index b3dac2cd..93d50303 100755 --- a/tests/run_awesome_tests.sh +++ b/tests/test_awesome/test.sh @@ -1,14 +1,13 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite awesome -TEST_ROOT="$ROOT/tests/awesome" +make_test_root + TEST_PATH="$TEST_ROOT/path" TEST_STATIC_ROOT="$ROOT/tests/test_awesome" -test -d "$TEST_ROOT" && rm -r "$TEST_ROOT" -mkdir "$TEST_ROOT" cp -r "$TEST_STATIC_ROOT/path" "$TEST_ROOT" cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT" @@ -31,7 +30,7 @@ for pexe in powerline powerline.sh powerline.py ; do else continue fi - if test "x$pexe" != 'xpowerline.sh' || test -e "$TEST_PATH/socat" ; then + if test "$pexe" != 'powerline.sh' || test -e "$TEST_PATH/socat" ; then POWERLINE_COMMAND="$pexe" break fi @@ -75,7 +74,7 @@ check_log() { return 1 fi local expline="powerline_widget:set_markup(' default-right ')" - if test "x$expline" != "x$line" ; then + if test "$expline" != "$line" ; then echo "Line: '$line'" echo "Expected: '$expline'" fail "log:line" F "Unexpected line" @@ -120,7 +119,7 @@ else sleep 5 killscript "$(cat "$TEST_ROOT/$args-pid")" rm "$TEST_ROOT/$args-pid" - if test "x$(cat "$DEPRECATED_LOG")" != "x" ; then + if test -n "$(cat "$DEPRECATED_LOG")" ; then display_log "$DEPRECATED_LOG" fail "output" E "Nonempty $DEPRECATED_SCRIPT output" fi @@ -154,7 +153,7 @@ run "$POWERLINE_COMMAND" --socket $ADDRESS wm.awesome > "$TEST_ROOT/output.log.3 run "$POWERLINE_COMMAND" --socket $ADDRESS wm.awesome > "$TEST_ROOT/output.log.4" 2>&1 run "$POWERLINE_COMMAND" --socket $ADDRESS wm.awesome > "$TEST_ROOT/output.log.5" 2>&1 for log_file in "$TEST_ROOT"/output.log.* ; do - if test "x$(cat "$log_file")" != "x" ; then + if test -n "$(cat "$log_file")" ; then display_log "$log_file" fail "output" E "Nonempty $POWERLINE_COMMAND output at run ${log_file#*.}" fi @@ -162,13 +161,13 @@ for log_file in "$TEST_ROOT"/output.log.* ; do done sleep 5 run python "$POWERLINE_DAEMON" --socket $ADDRESS --quiet --kill > "$TEST_ROOT/kill.log" 2>&1 -if test "x$(cat "$TEST_ROOT/kill.log")" != "x" ; then +if test -n "$(cat "$TEST_ROOT/kill.log")" ; then display_log "$TEST_ROOT/kill.log" fail "daemonlog" E "Nonempty kill log" fi rm "$TEST_ROOT/kill.log" wait $DPID -if test "x$(cat "$TEST_ROOT/daemon.log")" != "x" ; then +if test -n "$(cat "$TEST_ROOT/daemon.log")" ; then display_log "$TEST_ROOT/daemon.log" fail "daemonlog" E "Nonempty daemon log" fi @@ -186,8 +185,4 @@ then fail "lint" F "Checking test config failed" fi -if test $FAILED -eq 0 ; then - rm -r "$TEST_ROOT" -fi - exit_suite diff --git a/tests/run_bar_tests.sh b/tests/test_bar/test.sh similarity index 91% rename from tests/run_bar_tests.sh rename to tests/test_bar/test.sh index 7d658ff1..d6522eed 100755 --- a/tests/run_bar_tests.sh +++ b/tests/test_bar/test.sh @@ -1,14 +1,12 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite bar -TEST_ROOT="$ROOT/tests/bar" +make_test_root TEST_PATH="$TEST_ROOT/path" TEST_STATIC_ROOT="$ROOT/tests/test_bar" -test -d "$TEST_ROOT" && rm -r "$TEST_ROOT" -mkdir "$TEST_ROOT" cp -r "$TEST_STATIC_ROOT/path" "$TEST_ROOT" cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT" @@ -51,7 +49,7 @@ check_log() { if test "$warns" = "warns" ; then local warning="$(head -n1 "$log_file" | sed 's/.*://')" local expwarning="The 'bar' bindings are deprecated, please switch to 'lemonbar'" - if test "x$warning" != "x$expwarning" ; then + if test "$warning" != "$expwarning" ; then echo "Got: $warning" echo "Exp: $expwarning" fail "warn" F "Expected warning" @@ -68,7 +66,7 @@ check_log() { return 1 fi local expline="%{l}%{F#ffd0d0d0}%{B#ff303030} $text-left %{F-B--u}%{F#ff303030} %{F-B--u}%{r}%{F#ff303030} %{F-B--u}%{F#ffd0d0d0}%{B#ff303030} $text-right %{F-B--u}" - if test "x$expline" != "x$line" ; then + if test "$expline" != "$line" ; then echo "Line: '$line'" echo "Expected: '$expline'" fail "log:line" F "Unexpected line" @@ -151,14 +149,14 @@ else if test "$fnum" -ne 2 ; then fail "fnum" F "Expected two output files" fi - if test "x${args#--height}" != "x$args" ; then + if test "${args#--height}" != "$args" ; then height="${args#--height}" height="${height# }" height="${height#=}" height="${height%% *}" fi command="lemonbar" - if test "x${args#--bar-command}" != "x$args" ; then + if test "${args#--bar-command}" != "$args" ; then command="${args#--bar-command}" command="${command# }" command="${command#=}" @@ -168,11 +166,11 @@ else rm "$TEST_ROOT/args.log" script_args="${args#*-- }" script_args="${script_args# }" - if test "x${script_args}" '=' "x$args" ; then + if test "${script_args}" = "$args" ; then script_args= fi expected_args="$command -g 1920x$height+0${script_args:+ }$script_args${NL}$command -g 1920x$height+1${script_args:+ }$script_args" - if test "x$expected_args" != "x$received_args" ; then + if test "$expected_args" != "$received_args" ; then echo "args:${NL}<$received_args>" echo "expected:${NL}<$expected_args>" fail "args" F "Expected different args" @@ -194,8 +192,4 @@ then fail "lint" F "Checking test config failed" fi -if test $FAILED -eq 0 ; then - rm -r "$TEST_ROOT" -fi - exit_suite diff --git a/tests/test_daemon/test.sh b/tests/test_daemon/test.sh new file mode 100755 index 00000000..6538e4fd --- /dev/null +++ b/tests/test_daemon/test.sh @@ -0,0 +1,41 @@ +#!/bin/sh +. tests/shlib/common.sh + +enter_suite daemon + +export ADDRESS="powerline-ipc-test-$$" +echo "Powerline address: $ADDRESS" +if "$PYTHON" "$ROOT/scripts/powerline-daemon" -s"$ADDRESS" ; then + sleep 1 + if ! ( \ + "$PYTHON" "$ROOT/client/powerline.py" \ + --socket "$ADDRESS" -p/dev/null shell left \ + | grep "file not found" + ) ; then + fail "devnull" F "-p/dev/null argument ignored or not treated properly" + fi + if ( \ + "$PYTHON" "$ROOT/client/powerline.py" --socket "$ADDRESS" \ + -p"$ROOT/powerline/config_files" shell left \ + | grep "file not found" + ) ; then + fail "nodevnull" F "-p/dev/null argument remembered while it should not" + fi + if ! ( \ + cd "$ROOT/tests/test_daemon" \ + && "$PYTHON" "$ROOT/client/powerline.py" --socket "$ADDRESS" \ + -p"$ROOT/powerline/config_files" shell left \ + | grep "test_daemon" + ) ; then + fail "segment" F "Output lacks string “tests”" + fi +else + fail "exitcode" E "Daemon exited with status $?" +fi +if "$PYTHON" "$ROOT/scripts/powerline-daemon" -s"$ADDRESS" -k ; then + : +else + fail "-k" F "powerline-daemon -k failed with exit code $?" +fi + +exit_suite diff --git a/tests/run_vterm_tests.sh b/tests/test_in_vterm/test.sh similarity index 57% rename from tests/run_vterm_tests.sh rename to tests/test_in_vterm/test.sh index c918ba32..bbd49582 100755 --- a/tests/run_vterm_tests.sh +++ b/tests/test_in_vterm/test.sh @@ -1,11 +1,11 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite vterm -for t in tests/test_in_vterm/test_*.sh ; do +for t in "$ROOT"/tests/test_in_vterm/test_*.sh ; do test_name="${t##*/test_}" - if ! sh "$t" ; then + if ! "$t" ; then fail "${test_name%.sh}" F "Failed running $t" fi done diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index 635c83a9..11ba95f3 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -8,36 +8,20 @@ import json from time import sleep from subprocess import check_call -from difflib import ndiff from glob import glob1 from traceback import print_exc -from powerline.lib.unicode import u from powerline.lib.dict import updated from powerline.bindings.tmux import get_tmux_version from powerline import get_fallback_logger -from tests.lib.terminal import ExpectProcess, MutableDimensions +from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, + do_terminal_tests, get_env) VTERM_TEST_DIR = os.path.abspath('tests/vterm_tmux') -def convert_expected_result(p, expected_result): - return p.get_highlighted_text(expected_result, {}) - - -def cell_properties_key_to_shell_escape(cell_properties_key): - fg, bg, bold, underline, italic = cell_properties_key - return('\x1b[38;2;{0};48;2;{1}{bold}{underline}{italic}m'.format( - ';'.join((str(i) for i in fg)), - ';'.join((str(i) for i in bg)), - bold=(';1' if bold else ''), - underline=(';4' if underline else ''), - italic=(';3' if italic else ''), - )) - - def tmux_logs_iter(test_dir): for tail in glob1(test_dir, '*.log'): yield os.path.join(test_dir, tail) @@ -54,36 +38,6 @@ def print_tmux_logs(): os.unlink(f) -def test_expected_result(p, expected_result, last_attempt, last_attempt_cb): - expected_text, attrs = expected_result - attempts = 3 - result = None - while attempts: - actual_text, all_attrs = p.get_row(p.dim.rows - 1, attrs) - if actual_text == expected_text: - return True - attempts -= 1 - print('Actual result does not match expected. Attempts left: {0}.'.format(attempts)) - sleep(2) - print('Result:') - print(actual_text) - print('Expected:') - print(expected_text) - print('Attributes:') - print(all_attrs) - print('Screen:') - screen, screen_attrs = p.get_screen(attrs) - print(screen) - print(screen_attrs) - print('_' * 80) - print('Diff:') - print('=' * 80) - print(''.join((u(line) for line in ndiff([actual_text], [expected_text])))) - if last_attempt: - last_attempt_cb() - return False - - def get_expected_result(tmux_version, expected_result_old, expected_result_1_7=None, @@ -99,50 +53,27 @@ def get_expected_result(tmux_version, return expected_result_old +def tmux_fin_cb(p, cmd, env): + try: + check_call([ + cmd, '-S', env['POWERLINE_TMUX_SOCKET_PATH'], 'kill-server' + ], env=env, cwd=VTERM_TEST_DIR) + except Exception: + print_exc() + for f in tmux_logs_iter(VTERM_TEST_DIR): + os.unlink(f) + + def main(attempts=3): vterm_path = os.path.join(VTERM_TEST_DIR, 'path') tmux_exe = os.path.join(vterm_path, 'tmux') - if os.path.exists('tests/bot-ci/deps/libvterm/libvterm.so'): - lib = 'tests/bot-ci/deps/libvterm/libvterm.so' - else: - lib = os.environ.get('POWERLINE_LIBVTERM', 'libvterm.so') + socket_path = os.path.abspath('tmux-socket-{0}'.format(attempts)) + if os.path.exists(socket_path): + os.unlink(socket_path) - env = { - # Reasoning: - # 1. vt* TERMs (used to be vt100 here) make tmux-1.9 use - # different and identical colors for inactive windows. This - # is not like tmux-1.6: foreground color is different from - # separator color and equal to (0, 102, 153) for some reason - # (separator has correct color). tmux-1.8 is fine, so are - # older versions (though tmux-1.6 and tmux-1.7 do not have - # highlighting for previously active window) and my system - # tmux-1.9a. - # 2. screen, xterm and some other non-256color terminals both - # have the same issue and make libvterm emit complains like - # `Unhandled CSI SGR 3231`. - # 3. screen-256color, xterm-256color and other -256color - # terminals make libvterm emit complains about unhandled - # escapes to stderr. - # 4. `st-256color` does not have any of the above problems, but - # it may be not present on the target system because it is - # installed with x11-terms/st and not with sys-libs/ncurses. - # - # For the given reasons decision was made: to fix tmux-1.9 tests - # and not make libvterm emit any data to stderr st-256color - # $TERM should be used, up until libvterm has its own terminfo - # database entry (if it ever will). To make sure that relevant - # terminfo entry is present on the target system it should be - # distributed with powerline test package. To make distribution - # not require modifying anything outside of powerline test - # directory TERMINFO variable is set. - 'TERMINFO': os.path.join(VTERM_TEST_DIR, 'terminfo'), - 'TERM': 'st-256color', - 'PATH': vterm_path, - 'SHELL': os.path.join(VTERM_TEST_DIR, 'path', 'bash'), - 'POWERLINE_CONFIG_PATHS': os.path.abspath('powerline/config_files'), - 'POWERLINE_COMMAND': 'powerline-render', + env = get_env(vterm_path, VTERM_TEST_DIR, { 'POWERLINE_THEME_OVERRIDES': ';'.join(( key + '=' + json.dumps(val) for key, val in ( @@ -162,9 +93,8 @@ def main(attempts=3): ('default.segment_data.s2.contents', 'S2 string here'), ) )), - 'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH', ''), - 'PYTHONPATH': os.environ.get('PYTHONPATH', ''), - } + 'POWERLINE_TMUX_SOCKET_PATH': socket_path, + }) conf_path = os.path.abspath('powerline/bindings/tmux/powerline.conf') conf_line = 'source "' + ( @@ -177,6 +107,14 @@ def main(attempts=3): dim = MutableDimensions(rows=50, cols=200) + def prepare_test_1(p): + sleep(5) + + def prepare_test_2(p): + dim.cols = 40 + p.resize(dim) + sleep(5) + base_attrs = { ((0, 0, 0), (243, 243, 243), 1, 0, 0): 'lead', ((243, 243, 243), (11, 11, 11), 0, 0, 0): 'leadsep', @@ -185,106 +123,96 @@ def main(attempts=3): ((88, 88, 88), (11, 11, 11), 0, 0, 0): 'cwdhsep', ((0, 0, 0), (0, 224, 0), 0, 0, 0): 'defstl', } - expected_results = ( - get_expected_result( - tmux_version, - expected_result_old=( - '{lead: 0 }{leadsep: }{bg: S2 string here }' - '{4: 0 }{cwdhsep:| }{6:bash }' - '{bg: }{4: 1- }{cwdhsep:| }{6:bash }' - '{bg: }{7: }{8:2* | }{9:bash }{10: }' - '{bg:' + (' ' * 124) + '}' - '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, { - ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, - ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, - ((11, 11, 11), (0, 102, 153), 0, 0, 0): 7, - ((102, 204, 255), (0, 102, 153), 0, 0, 0): 8, - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 9, - ((0, 102, 153), (11, 11, 11), 0, 0, 0): 10, - })), - expected_result_1_8=( - '{lead: 0 }{leadsep: }{bg: S2 string here }' - '{4: 0 }{cwdhsep:| }{6:bash }' - '{bg: }{4: 1- }{cwdhsep:| }{7:bash }' - '{bg: }{8: }{9:2* | }{10:bash }{7: }' - '{bg:' + (' ' * 124) + '}' - '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, { - ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, - ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, - ((0, 102, 153), (11, 11, 11), 0, 0, 0): 7, - ((11, 11, 11), (0, 102, 153), 0, 0, 0): 8, - ((102, 204, 255), (0, 102, 153), 0, 0, 0): 9, - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 10, - })), - expected_result_2_0=( - '{lead: 0 }{leadsep: }{bg: S2 string here }' - '{4: 0 }{cwdhsep:| }{6:bash }' - '{bg: }{4: 1- }{cwdhsep:| }{7:bash }' - '{bg: }{8: }{9:2* | }{10:bash }{7: }' - '{bg:' + (' ' * 125) + '}' - '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, { - ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, - ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, - ((0, 102, 153), (11, 11, 11), 0, 0, 0): 7, - ((11, 11, 11), (0, 102, 153), 0, 0, 0): 8, - ((102, 204, 255), (0, 102, 153), 0, 0, 0): 9, - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 10, - })), - ), - get_expected_result( - tmux_version, - expected_result_old=('{bg:' + (' ' * 40) + '}', base_attrs), - expected_result_1_7=( - '{lead: 0 }' - '{leadsep: }{bg: <}{4:h }{bg: }{5: }' - '{6:2* | }{7:bash }{8: }{bg: }{cwdhsep: }' - '{cwd: S1 string here }', updated(base_attrs, { - ((188, 188, 188), (11, 11, 11), 0, 0, 0): 4, - ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, - ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, - ((0, 102, 153), (11, 11, 11), 0, 0, 0): 8, - })), - expected_result_1_8=( - '{lead: 0 }' - '{leadsep: }{bg: <}{4:h }{bg: }{5: }' - '{6:2* | }{7:bash }{4: }{bg: }{cwdhsep: }' - '{cwd: S1 string here }', updated(base_attrs, { - ((0, 102, 153), (11, 11, 11), 0, 0, 0): 4, - ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, - ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, - })), - expected_result_2_0=( - '{lead: 0 }' - '{leadsep: }{bg:<}{4:ash }{bg: }{5: }' - '{6:2* | }{7:bash }{4: }{cwdhsep: }' - '{cwd: S1 string here }', updated(base_attrs, { - ((0, 102, 153), (11, 11, 11), 0, 0, 0): 4, - ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, - ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, - ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, - })), - ), + tests = ( + { + 'expected_result': get_expected_result( + tmux_version, + expected_result_old=( + '{lead: 0 }{leadsep: }{bg: S2 string here }' + '{4: 0 }{cwdhsep:| }{6:bash }' + '{bg: }{4: 1- }{cwdhsep:| }{6:bash }' + '{bg: }{7: }{8:2* | }{9:bash }{10: }' + '{bg:' + (' ' * 124) + '}' + '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, { + ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, + ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, + ((11, 11, 11), (0, 102, 153), 0, 0, 0): 7, + ((102, 204, 255), (0, 102, 153), 0, 0, 0): 8, + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 9, + ((0, 102, 153), (11, 11, 11), 0, 0, 0): 10, + })), + expected_result_1_8=( + '{lead: 0 }{leadsep: }{bg: S2 string here }' + '{4: 0 }{cwdhsep:| }{6:bash }' + '{bg: }{4: 1- }{cwdhsep:| }{7:bash }' + '{bg: }{8: }{9:2* | }{10:bash }{7: }' + '{bg:' + (' ' * 124) + '}' + '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, { + ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, + ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, + ((0, 102, 153), (11, 11, 11), 0, 0, 0): 7, + ((11, 11, 11), (0, 102, 153), 0, 0, 0): 8, + ((102, 204, 255), (0, 102, 153), 0, 0, 0): 9, + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 10, + })), + expected_result_2_0=( + '{lead: 0 }{leadsep: }{bg: S2 string here }' + '{4: 0 }{cwdhsep:| }{6:bash }' + '{bg: }{4: 1- }{cwdhsep:| }{7:bash }' + '{bg: }{8: }{9:2* | }{10:bash }{7: }' + '{bg:' + (' ' * 125) + '}' + '{cwdhsep: }{cwd: S1 string here }', updated(base_attrs, { + ((133, 133, 133), (11, 11, 11), 0, 0, 0): 4, + ((188, 188, 188), (11, 11, 11), 0, 0, 0): 6, + ((0, 102, 153), (11, 11, 11), 0, 0, 0): 7, + ((11, 11, 11), (0, 102, 153), 0, 0, 0): 8, + ((102, 204, 255), (0, 102, 153), 0, 0, 0): 9, + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 10, + })), + ), + 'prep_cb': prepare_test_1, + 'row': dim.rows - 1, + }, { + 'expected_result': get_expected_result( + tmux_version, + expected_result_old=('{bg:' + (' ' * 40) + '}', base_attrs), + expected_result_1_7=( + '{lead: 0 }' + '{leadsep: }{bg: <}{4:h }{bg: }{5: }' + '{6:2* | }{7:bash }{8: }{bg: }{cwdhsep: }' + '{cwd: S1 string here }', updated(base_attrs, { + ((188, 188, 188), (11, 11, 11), 0, 0, 0): 4, + ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, + ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, + ((0, 102, 153), (11, 11, 11), 0, 0, 0): 8, + })), + expected_result_1_8=( + '{lead: 0 }' + '{leadsep: }{bg: <}{4:h }{bg: }{5: }' + '{6:2* | }{7:bash }{4: }{bg: }{cwdhsep: }' + '{cwd: S1 string here }', updated(base_attrs, { + ((0, 102, 153), (11, 11, 11), 0, 0, 0): 4, + ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, + ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, + })), + expected_result_2_0=( + '{lead: 0 }' + '{leadsep: }{bg:<}{4:ash }{bg: }{5: }' + '{6:2* | }{7:bash }{4: }{cwdhsep: }' + '{cwd: S1 string here }', updated(base_attrs, { + ((0, 102, 153), (11, 11, 11), 0, 0, 0): 4, + ((11, 11, 11), (0, 102, 153), 0, 0, 0): 5, + ((102, 204, 255), (0, 102, 153), 0, 0, 0): 6, + ((255, 255, 255), (0, 102, 153), 1, 0, 0): 7, + })), + ), + 'prep_cb': prepare_test_2, + 'row': dim.rows - 1, + } ) - def prepare_test_1(): - sleep(5) - - def prepare_test_2(): - dim.cols = 40 - p.resize(dim) - sleep(5) - - test_preps = ( - prepare_test_1, - prepare_test_2, - ) - - socket_path = os.path.abspath('tmux-socket-{0}'.format(attempts)) - if os.path.exists(socket_path): - os.unlink(socket_path) - args = [ # Specify full path to tmux socket (testing tmux instance must not # interfere with user one) @@ -301,41 +229,16 @@ def main(attempts=3): 'new-window', 'bash --norc --noprofile -i', ';', ] - try: - p = ExpectProcess( - lib=lib, - dim=dim, - cmd=tmux_exe, - args=args, - cwd=VTERM_TEST_DIR, - env=env, - ) - p.start() - - ret = True - - for test_prep, expected_result in zip(test_preps, expected_results): - test_prep() - ret = ( - ret - and test_expected_result(p, expected_result, attempts == 0, - print_tmux_logs) - ) - - if ret or attempts == 0: - return ret - finally: - try: - check_call([tmux_exe, '-S', socket_path, 'kill-server'], env=env, - cwd=VTERM_TEST_DIR) - except Exception: - print_exc() - p.kill() - p.join(10) - for f in tmux_logs_iter(VTERM_TEST_DIR): - os.unlink(f) - assert(not p.isAlive()) - return main(attempts=(attempts - 1)) + return do_terminal_tests( + tests=tests, + cmd=tmux_exe, + dim=dim, + args=args, + env=env, + cwd=VTERM_TEST_DIR, + fin_cb=tmux_fin_cb, + last_attempt_cb=print_tmux_logs, + ) if __name__ == '__main__': diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index c62ce530..b2a2ab4b 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -1,20 +1,17 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh +. tests/shlib/vterm.sh enter_suite tmux -rm -rf tests/vterm_tmux -mkdir tests/vterm_tmux -mkdir tests/vterm_tmux/path +VTERM_TEST_DIR="$ROOT/tests/vterm_tmux" -ln -s "$(which "${PYTHON}")" tests/vterm_tmux/path/python -ln -s "$(which bash)" tests/vterm_tmux/path -ln -s "$(which env)" tests/vterm_tmux/path -ln -s "$(which cut)" tests/vterm_tmux/path -ln -s "$PWD/scripts/powerline-render" tests/vterm_tmux/path -ln -s "$PWD/scripts/powerline-config" tests/vterm_tmux/path +vterm_setup "$VTERM_TEST_DIR" -cp -r tests/terminfo tests/vterm_tmux +ln -s "$(which env)" "$VTERM_TEST_DIR/path" +ln -s "$(which cut)" "$VTERM_TEST_DIR/path" +ln -s "$ROOT/scripts/powerline-render" "$VTERM_TEST_DIR/path" +ln -s "$ROOT/scripts/powerline-config" "$VTERM_TEST_DIR/path" test_tmux() { if test "$PYTHON_IMPLEMENTATION" = PyPy; then @@ -25,17 +22,18 @@ test_tmux() { if ! which "${POWERLINE_TMUX_EXE}" ; then return 0 fi - ln -sf "$(which "${POWERLINE_TMUX_EXE}")" tests/vterm_tmux/path - f=tests/test_in_vterm/test_tmux.py - if ! "${PYTHON}" $f ; then + ln -sf "$(which "${POWERLINE_TMUX_EXE}")" "$VTERM_TEST_DIR/path/tmux" + f="$ROOT/tests/test_in_vterm/test_tmux.py" + if ! "${PYTHON}" "$f" ; then local test_name="$("$POWERLINE_TMUX_EXE" -V 2>&1 | cut -d' ' -f2)" fail "$test_name" F "Failed vterm test $f" fi } -if test -z "$POWERLINE_TMUX_EXE" && test -d tests/bot-ci/deps/tmux ; then - for tmux in tests/bot-ci/deps/tmux/tmux-*/tmux ; do - export POWERLINE_TMUX_EXE="$PWD/$tmux" +if test -z "$POWERLINE_TMUX_EXE" && test -d "$ROOT/tests/bot-ci/deps/tmux" +then + for tmux in "$ROOT"/tests/bot-ci/deps/tmux/tmux-*/tmux ; do + export POWERLINE_TMUX_EXE="$tmux" test_tmux || true done else @@ -43,10 +41,6 @@ else test_tmux || true fi -if test $FAILED -eq 0 ; then - rm -rf tests/vterm_tmux -else - echo "$FAIL_SUMMARY" -fi +vterm_shutdown "$VTERM_TEST_DIR" exit_suite diff --git a/tests/test_in_vterm/test_vim.py b/tests/test_in_vterm/test_vim.py new file mode 100755 index 00000000..3403ec46 --- /dev/null +++ b/tests/test_in_vterm/test_vim.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# vim:fileencoding=utf-8:noet +from __future__ import (unicode_literals, division, absolute_import, print_function) + +import os +import sys +import json + +from time import sleep +from subprocess import check_call +from glob import glob1 +from traceback import print_exc + +from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, + do_terminal_tests, get_env) + + +VTERM_TEST_DIR = os.path.abspath('tests/vterm_vim') + + +def main(attempts=3): + vterm_path = os.path.join(VTERM_TEST_DIR, 'path') + + vim_exe = os.path.join(vterm_path, 'vim') + + env = get_env(vterm_path, VTERM_TEST_DIR) + + dim = MutableDimensions(rows=50, cols=200) + + tests = ( + ) + + args = [] + + return do_terminal_tests( + tests=tests, + cmd=vim_exe, + dim=dim, + args=args, + env=env, + cwd=VTERM_TEST_DIR, + ) + + +if __name__ == '__main__': + if main(): + raise SystemExit(0) + else: + raise SystemExit(1) diff --git a/tests/test_in_vterm/test_vim.sh b/tests/test_in_vterm/test_vim.sh new file mode 100755 index 00000000..18e65265 --- /dev/null +++ b/tests/test_in_vterm/test_vim.sh @@ -0,0 +1,41 @@ +#!/bin/sh +. tests/shlib/common.sh +. tests/shlib/vterm.sh +. tests/shlib/vim.sh + +enter_suite vim + +VTERM_TEST_DIR="$ROOT/tests/vterm_vim" + +vterm_setup "$VTERM_TEST_DIR" + +test_vim() { + if test "$PYTHON_IMPLEMENTATION" != CPython ; then + # Can only link with cpython + return 0 + fi + if ! which "$POWERLINE_VIM_EXE" ; then + return 0 + fi + ln -sf "$(which "${POWERLINE_VIM_EXE}")" "$VTERM_TEST_DIR/path/vim" + f="$ROOT/tests/test_in_vterm/test_vim.py" + if ! "${PYTHON}" "$f" ; then + local test_name="$(LANG=C "$POWERLINE_VIM_EXE" --cmd 'echo version' --cmd qa 2>&1)" + fail "$test_name" F "Failed vterm test $f" + fi +} + +if test -z "$POWERLINE_VIM_EXE" && test -d "$ROOT/tests/bot-ci/deps/vim" +then + for vim in "$OLD_VIM" "$NEW_VIM" ; do + export POWERLINE_VIM_EXE="$vim" + test_vim || true + done +else + export POWERLINE_VIM_EXE="${POWERLINE_VIM_EXE:-vim}" + test_vim || true +fi + +vterm_shutdown "$VTERM_TEST_DIR" + +exit_suite diff --git a/tests/test_lint/test.sh b/tests/test_lint/test.sh new file mode 100755 index 00000000..f73ea981 --- /dev/null +++ b/tests/test_lint/test.sh @@ -0,0 +1,10 @@ +#!/bin/sh +. tests/shlib/common.sh + +enter_suite lint + +if ! "$PYTHON" "$ROOT/scripts/powerline-lint" -p "$ROOT/powerline/config_files" ; then + fail "test" F "Running powerline-lint failed" +fi + +exit_suite diff --git a/tests/empty b/tests/test_python/empty similarity index 100% rename from tests/empty rename to tests/test_python/empty diff --git a/tests/run_python_tests.sh b/tests/test_python/test.sh similarity index 52% rename from tests/run_python_tests.sh rename to tests/test_python/test.sh index f5524142..667d642d 100755 --- a/tests/run_python_tests.sh +++ b/tests/test_python/test.sh @@ -1,11 +1,11 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite python -for file in tests/test_*.py ; do +for file in "$ROOT"/tests/test_python/test_*.py ; do test_name="${file##*/test_}" - if ! ${PYTHON} $file --verbose --catch ; then + if ! "$PYTHON" "$file" --verbose --catch ; then fail "${test_name%.py}" F "Failed test(s) from $file" fi done diff --git a/tests/test_cmdline.py b/tests/test_python/test_cmdline.py similarity index 97% rename from tests/test_cmdline.py rename to tests/test_python/test_cmdline.py index cd021be6..b77988b2 100644 --- a/tests/test_cmdline.py +++ b/tests/test_python/test_cmdline.py @@ -13,8 +13,8 @@ else: from powerline.commands.main import get_argparser, finish_args -from tests import TestCase -from tests.lib import replace_attr +from tests.modules import TestCase +from tests.modules.lib import replace_attr class TestParser(TestCase): @@ -140,5 +140,5 @@ class TestParser(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_config_merging.py b/tests/test_python/test_config_merging.py similarity index 96% rename from tests/test_config_merging.py rename to tests/test_python/test_config_merging.py index 7e8a1366..3f4fa2ac 100644 --- a/tests/test_config_merging.py +++ b/tests/test_python/test_config_merging.py @@ -11,8 +11,8 @@ from shutil import rmtree from powerline.lib.dict import mergedicts_copy as mdc from powerline import Powerline -from tests import TestCase -from tests.lib.config_mock import select_renderer, UT +from tests.modules import TestCase +from tests.modules.lib.config_mock import select_renderer, UT CONFIG_DIR = 'tests/config' @@ -139,7 +139,7 @@ class WithConfigTree(object): select_renderer(simpler_renderer=True) self.p = TestPowerline( ext='test', - renderer_module='tests.lib.config_mock', + renderer_module='tests.modules.lib.config_mock', **self.p_kwargs ) if os.environ.get('POWERLINE_RUN_LINT_DURING_TESTS'): @@ -266,5 +266,5 @@ class TestMerging(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_config_reload.py b/tests/test_python/test_config_reload.py similarity index 98% rename from tests/test_config_reload.py rename to tests/test_python/test_config_reload.py index e07b3deb..a418d496 100644 --- a/tests/test_config_reload.py +++ b/tests/test_python/test_config_reload.py @@ -5,8 +5,8 @@ from time import sleep from copy import deepcopy from functools import wraps -from tests import TestCase -from tests.lib.config_mock import get_powerline, add_watcher_events, UT +from tests.modules import TestCase +from tests.modules.lib.config_mock import get_powerline, add_watcher_events, UT config = { @@ -315,5 +315,5 @@ class TestConfigReload(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_configuration.py b/tests/test_python/test_configuration.py similarity index 98% rename from tests/test_configuration.py rename to tests/test_python/test_configuration.py index fd3d4097..aa9e8448 100644 --- a/tests/test_configuration.py +++ b/tests/test_python/test_configuration.py @@ -7,11 +7,12 @@ import os from functools import wraps from copy import deepcopy -import tests.vim as vim_module +import tests.modules.vim as vim_module -from tests import TestCase -from tests.lib.config_mock import get_powerline, get_powerline_raw, swap_attributes, UT -from tests.lib import Args, replace_item +from tests.modules import TestCase +from tests.modules.lib.config_mock import (get_powerline, get_powerline_raw, + swap_attributes, UT) +from tests.modules.lib import Args, replace_item def highlighted_string(s, group, **kwargs): @@ -797,7 +798,6 @@ class TestVim(TestCase): def test_environ_update(self): # Regression test: test that segment obtains environment from vim, not # from os.environ. - import tests.vim as vim_module with vim_module._with('globals', powerline_config_paths=['/']): from powerline.vim import VimPowerline import powerline as powerline_module @@ -817,7 +817,7 @@ class TestVim(TestCase): import powerline as powerline_module with swap_attributes(config, powerline_module): with get_powerline_raw(config, VimPowerline, replace_gcp=True) as powerline: - powerline.add_local_theme('tests.matchers.always_true', { + powerline.add_local_theme('tests.modules.matchers.always_true', { 'segment_data': { 'foo': { 'contents': '“bar”' @@ -840,7 +840,7 @@ class TestVim(TestCase): @classmethod def setUpClass(cls): - sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'path'))) + sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'vim_sys_path'))) @classmethod def tearDownClass(cls): @@ -873,5 +873,5 @@ class TestLemonbar(TestRender): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_lib.py b/tests/test_python/test_lib.py similarity index 99% rename from tests/test_lib.py rename to tests/test_python/test_lib.py index f35f231c..6260659c 100644 --- a/tests/test_lib.py +++ b/tests/test_python/test_lib.py @@ -21,8 +21,8 @@ from powerline.lib.shell import run_cmd import powerline.lib.unicode as plu -from tests.lib import Pl, replace_attr -from tests import TestCase, SkipTest +from tests.modules.lib import Pl, replace_attr +from tests.modules import TestCase, SkipTest try: @@ -704,7 +704,7 @@ class TestVCS(TestCase): @classmethod def setUpClass(cls): cls.powerline_old_cwd = os.getcwd() - os.chdir(os.path.dirname(__file__)) + os.chdir(os.path.dirname(os.path.dirname(__file__))) call(['git', 'init', '--quiet', GIT_REPO]) assert os.path.isdir(GIT_REPO) call(['git', 'config', '--local', 'user.name', 'Foo'], cwd=GIT_REPO) @@ -736,5 +736,5 @@ class TestVCS(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_lib_config.py b/tests/test_python/test_lib_config.py similarity index 83% rename from tests/test_lib_config.py rename to tests/test_python/test_lib_config.py index 2b3db707..053462a2 100644 --- a/tests/test_lib_config.py +++ b/tests/test_python/test_lib_config.py @@ -5,11 +5,11 @@ import os from powerline.lib.config import ConfigLoader -from tests import TestCase -from tests.lib.fsconfig import FSTree +from tests.modules import TestCase +from tests.modules.lib.fsconfig import FSTree -FILE_ROOT = os.path.join(os.path.dirname(__file__), 'cfglib') +FILE_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'cfglib') class LoadedList(list): @@ -48,5 +48,5 @@ class TestLoaderCondition(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_listers.py b/tests/test_python/test_listers.py similarity index 97% rename from tests/test_listers.py rename to tests/test_python/test_listers.py index 3d3ed094..a33f0333 100644 --- a/tests/test_listers.py +++ b/tests/test_python/test_listers.py @@ -3,8 +3,8 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct import powerline.listers.i3wm as i3wm -from tests.lib import Args, replace_attr, Pl -from tests import TestCase +from tests.modules.lib import Args, replace_attr, Pl +from tests.modules import TestCase class TestI3WM(TestCase): @@ -223,5 +223,5 @@ class TestI3WM(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_logging.py b/tests/test_python/test_logging.py similarity index 98% rename from tests/test_logging.py rename to tests/test_python/test_logging.py index 6de4a389..d7cfe4ad 100644 --- a/tests/test_logging.py +++ b/tests/test_python/test_logging.py @@ -14,8 +14,8 @@ from shutil import rmtree from powerline import finish_common_config, create_logger -from tests import TestCase -from tests.lib import replace_attr +from tests.modules import TestCase +from tests.modules.lib import replace_attr TIMESTAMP_RE = r'\d{4}-\d\d-\d\d \d\d:\d\d:\d\d,\d{3}' @@ -454,7 +454,7 @@ def setUpModule(): global __file__ old_cwd = os.getcwd() __file__ = os.path.abspath(__file__) - os.chdir(os.path.dirname(__file__)) + os.chdir(os.path.dirname(os.path.dirname(__file__))) def tearDownModule(): @@ -463,5 +463,5 @@ def tearDownModule(): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_provided_config_files.py b/tests/test_python/test_provided_config_files.py similarity index 93% rename from tests/test_provided_config_files.py rename to tests/test_python/test_provided_config_files.py index 3ea9a7e8..9478568d 100644 --- a/tests/test_provided_config_files.py +++ b/tests/test_python/test_provided_config_files.py @@ -9,10 +9,10 @@ import os import json import logging -import tests.vim as vim_module +import tests.modules.vim as vim_module -from tests.lib import Args, urllib_read, replace_attr -from tests import TestCase +from tests.modules.lib import Args, urllib_read, replace_attr +from tests.modules import TestCase from powerline import NotInterceptedError from powerline.segments.common import wthr @@ -46,7 +46,7 @@ def get_logger(stream=None): class TestVimConfig(TestCase): def test_vim(self): from powerline.vim import VimPowerline - cfg_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'powerline', 'config_files') + cfg_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'powerline', 'config_files') buffers = ( (('bufoptions',), {'buftype': 'help'}), (('bufname', '[Command Line]'), {}), @@ -101,7 +101,7 @@ class TestVimConfig(TestCase): @classmethod def setUpClass(cls): - sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'path'))) + sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'vim_sys_path'))) @classmethod def tearDownClass(cls): @@ -182,7 +182,7 @@ def setUpModule(): global saved_get_config_paths import powerline saved_get_config_paths = powerline.get_config_paths - path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'powerline', 'config_files') + path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'powerline', 'config_files') powerline.get_config_paths = lambda: [path] old_cwd = os.getcwd() @@ -197,5 +197,5 @@ def tearDownModule(): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_segments.py b/tests/test_python/test_segments.py similarity index 99% rename from tests/test_segments.py rename to tests/test_python/test_segments.py index 4149e937..4aef6a19 100644 --- a/tests/test_segments.py +++ b/tests/test_python/test_segments.py @@ -13,10 +13,11 @@ from powerline.segments import shell, tmux, pdb, i3wm from powerline.lib.vcs import get_fallback_create_watcher from powerline.lib.unicode import out_u -import tests.vim as vim_module +import tests.modules.vim as vim_module -from tests.lib import Args, urllib_read, replace_attr, new_module, replace_module_module, replace_env, Pl -from tests import TestCase, SkipTest +from tests.modules.lib import (Args, urllib_read, replace_attr, new_module, + replace_module_module, replace_env, Pl) +from tests.modules import TestCase, SkipTest def get_dummy_guess(**kwargs): @@ -1290,7 +1291,11 @@ class TestVim(TestCase): pl = Pl() segment_info = vim_module._get_segment_info() self.assertEqual(self.vim.file_size(pl=pl, segment_info=segment_info), '0 B') - with vim_module._with('buffer', os.path.join(os.path.dirname(__file__), 'empty')) as segment_info: + with vim_module._with( + 'buffer', + os.path.join( + os.path.dirname(os.path.dirname(__file__)), 'empty') + ) as segment_info: self.assertEqual(self.vim.file_size(pl=pl, segment_info=segment_info), '0 B') def test_file_opts(self): @@ -1598,7 +1603,7 @@ class TestVim(TestCase): @classmethod def setUpClass(cls): - sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'path'))) + sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'vim_sys_path'))) from powerline.segments import vim cls.vim = vim from powerline.segments.common import vcs @@ -1663,7 +1668,7 @@ def setUpModule(): global __file__ old_cwd = os.getcwd() __file__ = os.path.abspath(__file__) - os.chdir(os.path.dirname(__file__)) + os.chdir(os.path.dirname(os.path.dirname(__file__))) def tearDownModule(): @@ -1672,5 +1677,5 @@ def tearDownModule(): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_selectors.py b/tests/test_python/test_selectors.py similarity index 78% rename from tests/test_selectors.py rename to tests/test_python/test_selectors.py index a127ae9e..74ace8d7 100644 --- a/tests/test_selectors.py +++ b/tests/test_python/test_selectors.py @@ -6,10 +6,10 @@ import sys from functools import partial -import tests.vim as vim_module +import tests.modules.vim as vim_module -from tests.lib import Pl -from tests import TestCase +from tests.modules.lib import Pl +from tests.modules import TestCase class TestVim(TestCase): @@ -22,7 +22,7 @@ class TestVim(TestCase): @classmethod def setUpClass(cls): - sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'path'))) + sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'vim_sys_path'))) from powerline.selectors import vim cls.vim = vim @@ -32,5 +32,5 @@ class TestVim(TestCase): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_watcher.py b/tests/test_python/test_watcher.py similarity index 98% rename from tests/test_watcher.py rename to tests/test_python/test_watcher.py index 571cc8c4..a246d0be 100644 --- a/tests/test_watcher.py +++ b/tests/test_python/test_watcher.py @@ -13,7 +13,7 @@ from powerline.lib.watcher.uv import UvNotFound from powerline import get_fallback_logger from powerline.lib.monotonic import monotonic -from tests import TestCase, SkipTest +from tests.modules import TestCase, SkipTest INOTIFY_DIR = 'inotify' + os.path.basename(os.environ.get('PYTHON', '')) @@ -231,7 +231,7 @@ old_cwd = None def setUpModule(): global old_cwd old_cwd = os.getcwd() - os.chdir(os.path.dirname(__file__)) + os.chdir(os.path.dirname(os.path.dirname(__file__))) os.mkdir(INOTIFY_DIR) @@ -241,5 +241,5 @@ def tearDownModule(): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_shells/input.ipython b/tests/test_shells/input.ipython deleted file mode 100644 index 23b80198..00000000 --- a/tests/test_shells/input.ipython +++ /dev/null @@ -1,7 +0,0 @@ -print ('cd ' + 'tests/shell/3rd') # Start of the test marker -bool 42 -bool 44 -class Test(object): -pass - -exit diff --git a/tests/test_shells/input.bash b/tests/test_shells/inputs/bash similarity index 98% rename from tests/test_shells/input.bash rename to tests/test_shells/inputs/bash index bbd8d0bb..beffd308 100644 --- a/tests/test_shells/input.bash +++ b/tests/test_shells/inputs/bash @@ -32,7 +32,7 @@ ABOVE_FULL='[{ set_theme default_leftonly export VIRTUAL_ENV= source powerline/bindings/bash/powerline.sh -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/input.busybox b/tests/test_shells/inputs/busybox similarity index 97% rename from tests/test_shells/input.busybox rename to tests/test_shells/inputs/busybox index 16824d7b..5d1495a0 100644 --- a/tests/test_shells/input.busybox +++ b/tests/test_shells/inputs/busybox @@ -8,7 +8,7 @@ set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false set_theme default_leftonly . powerline/bindings/shell/powerline.sh export VIRTUAL_ENV= -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/input.dash b/tests/test_shells/inputs/dash similarity index 97% rename from tests/test_shells/input.dash rename to tests/test_shells/inputs/dash index 16824d7b..5d1495a0 100644 --- a/tests/test_shells/input.dash +++ b/tests/test_shells/inputs/dash @@ -8,7 +8,7 @@ set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false set_theme default_leftonly . powerline/bindings/shell/powerline.sh export VIRTUAL_ENV= -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/input.fish b/tests/test_shells/inputs/fish similarity index 98% rename from tests/test_shells/input.fish rename to tests/test_shells/inputs/fish index 4be37c31..9a20613a 100644 --- a/tests/test_shells/input.fish +++ b/tests/test_shells/inputs/fish @@ -37,7 +37,7 @@ while jobs | grep fish_update_completions end powerline-setup setenv VIRTUAL_ENV -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. setenv VIRTUAL_ENV "$HOME/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/inputs/ipython b/tests/test_shells/inputs/ipython new file mode 100644 index 00000000..257cba6f --- /dev/null +++ b/tests/test_shells/inputs/ipython @@ -0,0 +1,7 @@ +print ('cd ' + '"$TEST_ROOT"/3rd') # Start of the test marker +bool 42 +bool 44 +class Test(object): +pass + +exit diff --git a/tests/test_shells/input.mksh b/tests/test_shells/inputs/mksh similarity index 97% rename from tests/test_shells/input.mksh rename to tests/test_shells/inputs/mksh index 1656800e..ca457835 100644 --- a/tests/test_shells/input.mksh +++ b/tests/test_shells/inputs/mksh @@ -8,7 +8,7 @@ set_theme default_leftonly set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false . powerline/bindings/shell/powerline.sh export VIRTUAL_ENV= -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/input.pdb b/tests/test_shells/inputs/pdb similarity index 100% rename from tests/test_shells/input.pdb rename to tests/test_shells/inputs/pdb diff --git a/tests/test_shells/input.rc b/tests/test_shells/inputs/rc similarity index 92% rename from tests/test_shells/input.rc rename to tests/test_shells/inputs/rc index 1ae37ff0..c88bcf93 100644 --- a/tests/test_shells/input.rc +++ b/tests/test_shells/inputs/rc @@ -5,7 +5,8 @@ set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false POWERLINE_CONFIG_OVERRIDES = 'ext.shell.theme=default_leftonly' . powerline/bindings/rc/powerline.rc VIRTUAL_ENV = () -cd tests/shell/3rd +cd $TEST_ROOT/3rd +true cd "$TEST_ROOT"/3rd # Test start marker cd .git cd .. VIRTUAL_ENV = '/home/foo/.virtenvs/some-virtual-environment' diff --git a/tests/test_shells/input.tcsh b/tests/test_shells/inputs/tcsh similarity index 96% rename from tests/test_shells/input.tcsh rename to tests/test_shells/inputs/tcsh index 509c7ae6..c7d722a6 100644 --- a/tests/test_shells/input.tcsh +++ b/tests/test_shells/inputs/tcsh @@ -2,7 +2,7 @@ setenv POWERLINE_THEME_OVERRIDES "default_leftonly.segment_data.hostname.args.on setenv POWERLINE_CONFIG_OVERRIDES "ext.shell.theme=default_leftonly" source powerline/bindings/tcsh/powerline.tcsh unsetenv VIRTUAL_ENV -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. setenv VIRTUAL_ENV "/home/foo/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/input.zsh b/tests/test_shells/inputs/zsh similarity index 98% rename from tests/test_shells/input.zsh rename to tests/test_shells/inputs/zsh index ce29ddce..811684e0 100644 --- a/tests/test_shells/input.zsh +++ b/tests/test_shells/inputs/zsh @@ -43,7 +43,7 @@ ABOVE_FULL='[{ }]' set_theme default_leftonly export VIRTUAL_ENV= -cd tests/shell/3rd +cd "$TEST_ROOT"/3rd cd .git cd .. VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" diff --git a/tests/test_shells/bash.daemon.ok b/tests/test_shells/outputs/bash.daemon.ok similarity index 82% rename from tests/test_shells/bash.daemon.ok rename to tests/test_shells/outputs/bash.daemon.ok index 50d7d212..a0aba45b 100644 --- a/tests/test_shells/bash.daemon.ok +++ b/tests/test_shells/outputs/bash.daemon.ok @@ -1,23 +1,23 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh [1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false - USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo ' -                                     abc -                                     def -                                     ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo ' +                                   abc +                                   def +                                   ' abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/bash.nodaemon.ok b/tests/test_shells/outputs/bash.nodaemon.ok similarity index 84% rename from tests/test_shells/bash.nodaemon.ok rename to tests/test_shells/outputs/bash.nodaemon.ok index 9571a21c..118dfe50 100644 --- a/tests/test_shells/bash.nodaemon.ok +++ b/tests/test_shells/outputs/bash.nodaemon.ok @@ -1,15 +1,15 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh [1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false - USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo '    abc    def    ' @@ -17,7 +17,7 @@ abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/busybox.daemon.ok b/tests/test_shells/outputs/busybox.daemon.ok similarity index 72% rename from tests/test_shells/busybox.daemon.ok rename to tests/test_shells/outputs/busybox.daemon.ok index a8c3faa5..446d88e8 100644 --- a/tests/test_shells/busybox.daemon.ok +++ b/tests/test_shells/outputs/busybox.daemon.ok @@ -1,22 +1,22 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false - USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo ' -                                     abc -                                     def -                                     ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo ' +                                   abc +                                   def +                                   ' abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/busybox.nodaemon.ok b/tests/test_shells/outputs/busybox.nodaemon.ok similarity index 74% rename from tests/test_shells/busybox.nodaemon.ok rename to tests/test_shells/outputs/busybox.nodaemon.ok index 00b8b7cc..afda9a58 100644 --- a/tests/test_shells/busybox.nodaemon.ok +++ b/tests/test_shells/outputs/busybox.nodaemon.ok @@ -1,14 +1,14 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false - USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo '    abc    def    ' @@ -16,7 +16,7 @@ abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/dash.daemon.ok b/tests/test_shells/outputs/dash.daemon.ok similarity index 70% rename from tests/test_shells/dash.daemon.ok rename to tests/test_shells/outputs/dash.daemon.ok index bfe8fab0..71ca5003 100644 --- a/tests/test_shells/dash.daemon.ok +++ b/tests/test_shells/outputs/dash.daemon.ok @@ -1,21 +1,21 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s set_theme_option default_leftonly.segment_data.hostname.display false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1   USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo ' -                                     abc -                                     def -                                     ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1   USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo ' +                                   abc +                                   def +                                   ' abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/dash.nodaemon.ok b/tests/test_shells/outputs/dash.nodaemon.ok similarity index 72% rename from tests/test_shells/dash.nodaemon.ok rename to tests/test_shells/outputs/dash.nodaemon.ok index c4f8e567..c289cd2e 100644 --- a/tests/test_shells/dash.nodaemon.ok +++ b/tests/test_shells/outputs/dash.nodaemon.ok @@ -1,13 +1,13 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s set_theme_option default_leftonly.segment_data.hostname.display false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1   USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1   USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo '    abc    def    ' @@ -15,7 +15,7 @@ set_theme_option default_leftonly.segment_data.hostname.display false abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/fish.ok b/tests/test_shells/outputs/fish.ok similarity index 90% rename from tests/test_shells/fish.ok rename to tests/test_shells/outputs/fish.ok index 973cf05a..4d208bb1 100644 --- a/tests/test_shells/fish.ok +++ b/tests/test_shells/outputs/fish.ok @@ -1,11 +1,11 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd     HOSTNAME  USER   BRANCH  …  shell  3rd  .git   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd     HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m     HOSTNAME  USER   BRANCH  …  shell  3rd  ^H     HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]   diff --git a/tests/test_shells/ipython.ok b/tests/test_shells/outputs/ipython.ok similarity index 100% rename from tests/test_shells/ipython.ok rename to tests/test_shells/outputs/ipython.ok diff --git a/tests/test_shells/mksh.daemon.ok b/tests/test_shells/outputs/mksh.daemon.ok similarity index 72% rename from tests/test_shells/mksh.daemon.ok rename to tests/test_shells/outputs/mksh.daemon.ok index 2a367dcf..264dff87 100644 --- a/tests/test_shells/mksh.daemon.ok +++ b/tests/test_shells/outputs/mksh.daemon.ok @@ -1,25 +1,25 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh [1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1 +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1 [1] + Terminated bash -c ... -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false - USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo -n -  BRANCH  …  tests  shell  3rd  echo ' -                                     abc -                                     def -                                     ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo -n +  BRANCH  …  tmp  shell  3rd  echo ' +                                   abc +                                   def +                                   ' abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/mksh.nodaemon.ok b/tests/test_shells/outputs/mksh.nodaemon.ok similarity index 74% rename from tests/test_shells/mksh.nodaemon.ok rename to tests/test_shells/outputs/mksh.nodaemon.ok index 09190f8d..d8d9d705 100644 --- a/tests/test_shells/mksh.nodaemon.ok +++ b/tests/test_shells/outputs/mksh.nodaemon.ok @@ -1,17 +1,17 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="$HOME/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh [1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1 +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1 [1] + Terminated bash -c ... -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false - USER   BRANCH  …  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false -  BRANCH  …  tests  shell  3rd  echo -n -  BRANCH  …  tests  shell  3rd  echo ' +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  …  tmp  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false +  BRANCH  …  tmp  shell  3rd  echo -n +  BRANCH  …  tmp  shell  3rd  echo '    abc    def    ' @@ -19,7 +19,7 @@ abc def -  BRANCH  …  tests  shell  3rd  cd "$DIR1" +  BRANCH  …  tmp  shell  3rd  cd "$DIR1"   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/pdb.module.ok b/tests/test_shells/outputs/pdb.module.ok similarity index 100% rename from tests/test_shells/pdb.module.ok rename to tests/test_shells/outputs/pdb.module.ok diff --git a/tests/test_shells/pdb.subclass.ok b/tests/test_shells/outputs/pdb.subclass.ok similarity index 100% rename from tests/test_shells/pdb.subclass.ok rename to tests/test_shells/outputs/pdb.subclass.ok diff --git a/tests/test_shells/rc.daemon.ok b/tests/test_shells/outputs/rc.daemon.ok similarity index 83% rename from tests/test_shells/rc.daemon.ok rename to tests/test_shells/outputs/rc.daemon.ok index 9bbee845..c49b9a32 100644 --- a/tests/test_shells/rc.daemon.ok +++ b/tests/test_shells/outputs/rc.daemon.ok @@ -1,12 +1,12 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV = '/home/foo/.virtenvs/some-virtual-environment' -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV = () -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV = '/home/foo/.virtenvs/some-virtual-environment' +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV = () +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `{cat pid} ; sleep 1s -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd $DIR1 +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `{cat pid} ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd $DIR1   HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m  cd ../$DIR2   HOSTNAME  USER   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/rc.nodaemon.ok b/tests/test_shells/outputs/rc.nodaemon.ok similarity index 83% rename from tests/test_shells/rc.nodaemon.ok rename to tests/test_shells/outputs/rc.nodaemon.ok index d45c7bd3..28376cb5 100644 --- a/tests/test_shells/rc.nodaemon.ok +++ b/tests/test_shells/outputs/rc.nodaemon.ok @@ -1,12 +1,12 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV = '/home/foo/.virtenvs/some-virtual-environment' -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV = () -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV = '/home/foo/.virtenvs/some-virtual-environment' +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV = () +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `{cat pid} ; sleep 1s -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd $DIR1 +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `{cat pid} ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd $DIR1   HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m  cd ../$DIR2   HOSTNAME  USER   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]  cd ../'%%' diff --git a/tests/test_shells/tcsh.ok b/tests/test_shells/outputs/tcsh.ok similarity index 83% rename from tests/test_shells/tcsh.ok rename to tests/test_shells/outputs/tcsh.ok index 3b25f86f..07089bff 100644 --- a/tests/test_shells/tcsh.ok +++ b/tests/test_shells/outputs/tcsh.ok @@ -1,11 +1,11 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd     HOSTNAME  USER   BRANCH  …  shell  3rd  .git   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1   -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1   +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd     HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m     HOSTNAME  USER   BRANCH  …  shell  3rd  ^H     HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]   diff --git a/tests/test_shells/zsh.daemon.ok b/tests/test_shells/outputs/zsh.daemon.ok similarity index 67% rename from tests/test_shells/zsh.daemon.ok rename to tests/test_shells/outputs/zsh.daemon.ok index bea39b96..32e80d8d 100644 --- a/tests/test_shells/zsh.daemon.ok +++ b/tests/test_shells/outputs/zsh.daemon.ok @@ -1,14 +1,14 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh [1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1] + terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd "$DIR1" +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd "$DIR1"   HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   HOSTNAME  USER   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]  cd ../'%%' @@ -18,35 +18,35 @@   HOSTNAME  USER   BRANCH  …  shell  3rd  $(echo)  cd ../'`echo`'   HOSTNAME  USER   BRANCH  …  shell  3rd  `echo`  cd ../'«Unicode!»'   HOSTNAME  USER   BRANCH  …  shell  3rd  «Unicode!»  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bindkey -v ; set_theme default - INSERT   HOSTNAME  USER  …  tests  shell  3rd   COMMND   HOSTNAME  USER  …  tests  shell  3rd   - INSERT   HOSTNAME  USER  …  tests  shell  3rd   - INSERT   HOSTNAME  USER  …  tests  shell  3rd  echo abc +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bindkey -v ; set_theme default + INSERT   HOSTNAME  USER  …  tmp  shell  3rd   COMMND   HOSTNAME  USER  …  tmp  shell  3rd   + INSERT   HOSTNAME  USER  …  tmp  shell  3rd   + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  echo abc abc - INSERT   HOSTNAME  USER  …  tests  shell  3rd  false - INSERT   HOSTNAME  USER  …  tests  shell  3rd  set_theme_option default.segment_data.hostname.display false - INSERT  USER  …  tests  shell  3rd  set_theme_option default.segment_data.user.display false - INSERT  …  tests  shell  3rd  select abc in def ghi jkl - select                            do - select                             echo $abc - select                             break - select                            done + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  false + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  set_theme_option default.segment_data.hostname.display false + INSERT  USER  …  tmp  shell  3rd  set_theme_option default.segment_data.user.display false + INSERT  …  tmp  shell  3rd  select abc in def ghi jkl + select                          do + select                           echo $abc + select                           break + select                          done 1) def 2) ghi 3) jkl -                   Select variant  1 +                 Select variant  1 def - INSERT  …  tests  shell  3rd  cd . - INSERT  …  tests  shell  3rd  cd . - INSERT  …  tests  shell  3rd  set_theme_option default.segments.above "$ABOVE_LEFT" - INSERT  …  tests  shell  3rd  export DISPLAYED_ENV_VAR=foo + INSERT  …  tmp  shell  3rd  cd . + INSERT  …  tmp  shell  3rd  cd . + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above "$ABOVE_LEFT" + INSERT  …  tmp  shell  3rd  export DISPLAYED_ENV_VAR=foo  foo   - INSERT  …  tests  shell  3rd  unset DISPLAYED_ENV_VAR - INSERT  …  tests  shell  3rd  set_theme_option default.segments.above "$ABOVE_FULL" + INSERT  …  tmp  shell  3rd  unset DISPLAYED_ENV_VAR + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above "$ABOVE_FULL"                                                                                                                                                                                                                                                                                                             - INSERT  …  tests  shell  3rd  export DISPLAYED_ENV_VAR=foo + INSERT  …  tmp  shell  3rd  export DISPLAYED_ENV_VAR=foo                                                                                                                                                                                                                                                                                                       foo  - INSERT  …  tests  shell  3rd  unset DISPLAYED_ENV_VAR + INSERT  …  tmp  shell  3rd  unset DISPLAYED_ENV_VAR                                                                                                                                                                                                                                                                                                             - INSERT  …  tests  shell  3rd  set_theme_option default.segments.above - INSERT  …  tests  shell  3rd  hash -d foo=$PWD:h ; cd . + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above + INSERT  …  tmp  shell  3rd  hash -d foo=$PWD:h ; cd .  INSERT  ~foo  3rd  set_theme_option default.dividers.left.hard \$ABC  INSERT $ABC~foo  3rd $ABCtrue diff --git a/tests/test_shells/zsh.nodaemon.ok b/tests/test_shells/outputs/zsh.nodaemon.ok similarity index 69% rename from tests/test_shells/zsh.nodaemon.ok rename to tests/test_shells/outputs/zsh.nodaemon.ok index d6f4d518..3aa285f8 100644 --- a/tests/test_shells/zsh.nodaemon.ok +++ b/tests/test_shells/outputs/zsh.nodaemon.ok @@ -1,14 +1,14 @@ -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git   HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh [1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1] + terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd "$DIR1" +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd "$DIR1"   HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2"   HOSTNAME  USER   BRANCH  …  shell  3rd  ^H  cd ../'\[\]'   HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]  cd ../'%%' @@ -18,15 +18,15 @@   HOSTNAME  USER   BRANCH  …  shell  3rd  $(echo)  cd ../'`echo`'   HOSTNAME  USER   BRANCH  …  shell  3rd  `echo`  cd ../'«Unicode!»'   HOSTNAME  USER   BRANCH  …  shell  3rd  «Unicode!»  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bindkey -v ; set_theme default - INSERT   HOSTNAME  USER  …  tests  shell  3rd   COMMND   HOSTNAME  USER  …  tests  shell  3rd   - INSERT   HOSTNAME  USER  …  tests  shell  3rd   - INSERT   HOSTNAME  USER  …  tests  shell  3rd  echo abc +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bindkey -v ; set_theme default + INSERT   HOSTNAME  USER  …  tmp  shell  3rd   COMMND   HOSTNAME  USER  …  tmp  shell  3rd   + INSERT   HOSTNAME  USER  …  tmp  shell  3rd   + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  echo abc abc - INSERT   HOSTNAME  USER  …  tests  shell  3rd  false - INSERT   HOSTNAME  USER  …  tests  shell  3rd  set_theme_option default.segment_data.hostname.display false - INSERT  USER  …  tests  shell  3rd  set_theme_option default.segment_data.user.display false - INSERT  …  tests  shell  3rd  select abc in def ghi jkl + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  false + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  set_theme_option default.segment_data.hostname.display false + INSERT  USER  …  tmp  shell  3rd  set_theme_option default.segment_data.user.display false + INSERT  …  tmp  shell  3rd  select abc in def ghi jkl  select  do  select   echo $abc  select   break @@ -34,19 +34,19 @@ abc 1) def 2) ghi 3) jkl  Select variant  1 def - INSERT  …  tests  shell  3rd  cd . - INSERT  …  tests  shell  3rd  cd . - INSERT  …  tests  shell  3rd  set_theme_option default.segments.above "$ABOVE_LEFT" - INSERT  …  tests  shell  3rd  export DISPLAYED_ENV_VAR=foo + INSERT  …  tmp  shell  3rd  cd . + INSERT  …  tmp  shell  3rd  cd . + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above "$ABOVE_LEFT" + INSERT  …  tmp  shell  3rd  export DISPLAYED_ENV_VAR=foo  foo   - INSERT  …  tests  shell  3rd  unset DISPLAYED_ENV_VAR - INSERT  …  tests  shell  3rd  set_theme_option default.segments.above "$ABOVE_FULL" + INSERT  …  tmp  shell  3rd  unset DISPLAYED_ENV_VAR + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above "$ABOVE_FULL"                                                                                                                                                                                                                                                                                                             - INSERT  …  tests  shell  3rd  export DISPLAYED_ENV_VAR=foo + INSERT  …  tmp  shell  3rd  export DISPLAYED_ENV_VAR=foo                                                                                                                                                                                                                                                                                                       foo  - INSERT  …  tests  shell  3rd  unset DISPLAYED_ENV_VAR + INSERT  …  tmp  shell  3rd  unset DISPLAYED_ENV_VAR                                                                                                                                                                                                                                                                                                             - INSERT  …  tests  shell  3rd  set_theme_option default.segments.above - INSERT  …  tests  shell  3rd  hash -d foo=$PWD:h ; cd . + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above + INSERT  …  tmp  shell  3rd  hash -d foo=$PWD:h ; cd .  INSERT  ~foo  3rd  set_theme_option default.dividers.left.hard \$ABC  INSERT $ABC~foo  3rd $ABCtrue diff --git a/tests/test_shells/outputs/zsh.zpython.ok b/tests/test_shells/outputs/zsh.zpython.ok new file mode 100644 index 00000000..32e80d8d --- /dev/null +++ b/tests/test_shells/outputs/zsh.zpython.ok @@ -0,0 +1,52 @@ + +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd .git +  HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" +  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tmp  shell  3rd  VIRTUAL_ENV= +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bgscript.sh & waitpid.sh +[1] PID +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  false +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  1  1  kill `cat pid` ; sleep 1s +[1] + terminated bgscript.sh +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  cd "$DIR1" +  HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2" +  HOSTNAME  USER   BRANCH  …  shell  3rd  ^H  cd ../'\[\]' +  HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]  cd ../'%%' +  HOSTNAME  USER   BRANCH  …  shell  3rd  %%  cd ../'#[bold]' +  HOSTNAME  USER   BRANCH  …  shell  3rd  #[bold]  cd ../'(echo)' +  HOSTNAME  USER   BRANCH  …  shell  3rd  (echo)  cd ../'$(echo)' +  HOSTNAME  USER   BRANCH  …  shell  3rd  $(echo)  cd ../'`echo`' +  HOSTNAME  USER   BRANCH  …  shell  3rd  `echo`  cd ../'«Unicode!»' +  HOSTNAME  USER   BRANCH  …  shell  3rd  «Unicode!»  cd .. +  HOSTNAME  USER   BRANCH  …  tmp  shell  3rd  bindkey -v ; set_theme default + INSERT   HOSTNAME  USER  …  tmp  shell  3rd   COMMND   HOSTNAME  USER  …  tmp  shell  3rd   + INSERT   HOSTNAME  USER  …  tmp  shell  3rd   + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  echo abc +abc + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  false + INSERT   HOSTNAME  USER  …  tmp  shell  3rd  set_theme_option default.segment_data.hostname.display false + INSERT  USER  …  tmp  shell  3rd  set_theme_option default.segment_data.user.display false + INSERT  …  tmp  shell  3rd  select abc in def ghi jkl + select                          do + select                           echo $abc + select                           break + select                          done +1) def 2) ghi 3) jkl +                 Select variant  1 +def + INSERT  …  tmp  shell  3rd  cd . + INSERT  …  tmp  shell  3rd  cd . + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above "$ABOVE_LEFT" + INSERT  …  tmp  shell  3rd  export DISPLAYED_ENV_VAR=foo + foo   + INSERT  …  tmp  shell  3rd  unset DISPLAYED_ENV_VAR + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above "$ABOVE_FULL" +                                                                                                                                                                                                                                                                                                            + INSERT  …  tmp  shell  3rd  export DISPLAYED_ENV_VAR=foo +                                                                                                                                                                                                                                                                                                      foo  + INSERT  …  tmp  shell  3rd  unset DISPLAYED_ENV_VAR +                                                                                                                                                                                                                                                                                                            + INSERT  …  tmp  shell  3rd  set_theme_option default.segments.above + INSERT  …  tmp  shell  3rd  hash -d foo=$PWD:h ; cd . + INSERT  ~foo  3rd  set_theme_option default.dividers.left.hard \$ABC + INSERT $ABC~foo  3rd $ABCtrue diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index 9b2a19a3..79261554 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -10,12 +10,13 @@ import platform import re +test_root = os.environ['TEST_ROOT'] test_type = sys.argv[1] test_client = sys.argv[2] shell = sys.argv[3] -fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client, 'full.log'))) -new_fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client, 'log'))) -pid_fname = os.path.join('tests', 'shell', '3rd', 'pid') +fname = os.path.join(test_root, '.'.join((shell, test_type, test_client, 'full.log'))) +new_fname = os.path.join(test_root, '.'.join((shell, test_type, test_client, 'log'))) +pid_fname = os.path.join(test_root, '3rd', 'pid') is_pypy = platform.python_implementation() == 'PyPy' @@ -32,7 +33,7 @@ REFS_RE = re.compile(r'^\[\d+ refs\]\n') IPYPY_DEANSI_RE = re.compile(r'\033(?:\[(?:\?\d+[lh]|[^a-zA-Z]+[a-ln-zA-Z])|[=>])') ZSH_HL_RE = re.compile(r'\033\[\?\d+[hl]') -start_str = 'cd tests/shell/3rd' +start_str = 'cd "$TEST_ROOT"/3rd' if shell == 'pdb': start_str = 'class Foo(object):' diff --git a/tests/test_shells/run_script.py b/tests/test_shells/run_script.py index 3d5eddd5..2eebca19 100755 --- a/tests/test_shells/run_script.py +++ b/tests/test_shells/run_script.py @@ -25,6 +25,7 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser): def main(): + test_root = os.environ['TEST_ROOT'] parser = get_argparser() args = parser.parse_args() @@ -33,11 +34,10 @@ def main(): test_client = args.client or test_type log_file_base = '{0}.{1}.{2}'.format(shell, test_type, test_client) - full_log_file_name = os.path.join('tests', 'shell', '{0}.full.log'.format(log_file_base)) - # postproc_log_file_name = os.path.join('tests', 'shell', '{0}.log'.format(log_file_base)) + full_log_file_name = os.path.join(test_root, '{0}.full.log'.format(log_file_base)) local_paths = [ - os.path.abspath(os.path.join('tests', 'shell', 'path')), + os.path.abspath(os.path.join(test_root, 'path')), os.path.abspath('scripts'), ] @@ -55,8 +55,8 @@ def main(): 'TERM': 'screen-256color', 'DIR1': os.environ['DIR1'], 'DIR2': os.environ['DIR2'], - 'XDG_CONFIG_HOME': os.path.abspath(os.path.join('tests', 'shell', 'fish_home')), - 'IPYTHONDIR': os.path.abspath(os.path.join('tests', 'shell', 'ipython_home')), + 'XDG_CONFIG_HOME': os.path.abspath(os.path.join(test_root, 'fish_home')), + 'IPYTHONDIR': os.path.abspath(os.path.join(test_root, 'ipython_home')), 'PYTHONPATH': python_paths, 'POWERLINE_CONFIG_OVERRIDES': os.environ.get('POWERLINE_CONFIG_OVERRIDES', ''), 'POWERLINE_THEME_OVERRIDES': os.environ.get('POWERLINE_THEME_OVERRIDES', ''), @@ -64,6 +64,7 @@ def main(): 'POWERLINE_COMMAND_ARGS': os.environ.get('POWERLINE_COMMAND_ARGS', ''), 'POWERLINE_COMMAND': os.environ.get('POWERLINE_COMMAND', ''), 'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH', ''), + 'TEST_ROOT': test_root, } os.environ['PATH'] = environ['PATH'] @@ -88,7 +89,7 @@ def main(): sleep(0.5) child.setwinsize(1, 300) - with open(os.path.join('tests', 'test_shells', 'input.{0}'.format(shell)), 'rb') as F: + with open(os.path.join('tests', 'test_shells', 'inputs', shell), 'rb') as F: if not args.wait_for_echo: child.send(F.read()) else: @@ -111,11 +112,11 @@ def main(): child.close(force=True) check_call([ - os.path.join('tests', 'shell', 'path', 'python'), + os.path.join(test_root, 'path', 'python'), os.path.join('tests', 'test_shells', 'postproc.py'), test_type, test_client, shell ]) - pidfile = os.path.join('tests', 'shell', '3rd', 'pid') + pidfile = os.path.join(test_root, '3rd', 'pid') if os.path.exists(pidfile): os.unlink(pidfile) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 0cc79716..d70e8ac8 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -1,23 +1,18 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh -enter_suite shells +enter_suite shell -if test "x$1" = "x--fast" ; then +if test $# -eq 0 ; then FAST=1 - shift fi ONLY_SHELL="$1" ONLY_TEST_TYPE="$2" ONLY_TEST_CLIENT="$3" -if ! test -z "$ONLY_SHELL$ONLY_TEST_TYPE$ONLY_TEST_CLIENT" ; then - FAST= -fi - export PYTHON -if test "x$ONLY_SHELL" = "x--help" ; then +if test "$ONLY_SHELL" = "--help" ; then cat << EOF Usage: $0 [[[ONLY_SHELL | ""] (ONLY_TEST_TYPE | "")] (ONLY_TEST_CLIENT | "")] @@ -33,14 +28,16 @@ check_screen_log() { TEST_TYPE="$1" TEST_CLIENT="$2" SH="$3" - if test -e tests/test_shells/${SH}.${TEST_TYPE}.ok ; then - diff -a -u tests/test_shells/${SH}.${TEST_TYPE}.ok tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log + if test -e "$ROOT/tests/test_shells/outputs/${SH}.${TEST_TYPE}.ok" ; then + diff -a -u "$ROOT/tests/test_shells/outputs/${SH}.${TEST_TYPE}.ok" \ + "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log" return $? - elif test -e tests/test_shells/${SH}.ok ; then - diff -a -u tests/test_shells/${SH}.ok tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log + elif test -e "$ROOT/tests/test_shells/outputs/${SH}.ok" ; then + diff -a -u "$ROOT/tests/test_shells/outputs/${SH}.ok" \ + "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log" return $? else - cat tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log + cat "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log" return 1 fi } @@ -55,13 +52,13 @@ print_full_output() { SH="$3" echo "Full output:" echo '============================================================' - cat tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log + cat "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log" echo echo '____________________________________________________________' - if test "x$POWERLINE_TEST_NO_CAT_V" != "x1" ; then + if test "$POWERLINE_TEST_NO_CAT_V" != "1" ; then echo "Full output (cat -v):" echo '============================================================' - cat -v tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log + cat -v "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log" echo echo '____________________________________________________________' fi @@ -76,9 +73,9 @@ do_run_test() { local wait_for_echo_arg= if ( \ - test "x${SH}" = "xdash" \ + test "${SH}" = "dash" \ || ( \ - test "x${SH}" = "xpdb" \ + test "${SH}" = "pdb" \ && ( \ ( \ test "$PYTHON_VERSION_MAJOR" -eq 3 \ @@ -89,7 +86,7 @@ do_run_test() { ) \ ) \ || ( \ - test "x${SH}" = "xipython" \ + test "${SH}" = "ipython" \ && test "$("${PYTHON}" -mIPython --version | head -n1 | cut -d. -f1)" -ge 5 \ ) \ ) ; then @@ -100,7 +97,7 @@ do_run_test() { "$@" if ! check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} ; then echo '____________________________________________________________' - if test "x$POWERLINE_TEST_NO_CAT_V" != "x1" ; then + if test "$POWERLINE_TEST_NO_CAT_V" != "1" ; then # Repeat the diff to make it better viewable in travis output echo "Diff (cat -v):" echo '============================================================' @@ -109,9 +106,9 @@ do_run_test() { fi echo -n "Failed ${SH}. " print_full_output ${TEST_TYPE} ${TEST_CLIENT} ${SH} - case ${SH} in + case "${SH}" in *ksh) - ${SH} -c 'echo ${KSH_VERSION}' + "$TEST_ROOT/path/${SH}" -c 'echo ${KSH_VERSION}' ;; dash) # ? @@ -120,7 +117,7 @@ do_run_test() { busybox --help ;; *) - ${SH} --version + "$TEST_ROOT/path/${SH}" --version ;; esac if which dpkg >/dev/null ; then @@ -140,82 +137,82 @@ run_test() { attempts=1 fi while test $attempts -gt 0 ; do - rm -f tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log - rm -f tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log + rm -f "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log" + rm -f "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log" do_run_test "$@" && return 0 attempts=$(( attempts - 1 )) done return 1 } -test -d tests/shell && rm -r tests/shell -mkdir tests/shell -git init tests/shell/3rd -git --git-dir=tests/shell/3rd/.git checkout -b BRANCH +make_test_root + +git init "$TEST_ROOT/3rd" +git --git-dir="$TEST_ROOT/3rd/.git" checkout -b BRANCH export DIR1="" export DIR2="" -mkdir tests/shell/3rd/"$DIR1" -mkdir tests/shell/3rd/"$DIR2" -mkdir tests/shell/3rd/'\[\]' -mkdir tests/shell/3rd/'%%' -mkdir tests/shell/3rd/'#[bold]' -mkdir tests/shell/3rd/'(echo)' -mkdir tests/shell/3rd/'$(echo)' -mkdir tests/shell/3rd/'`echo`' -mkdir tests/shell/3rd/'«Unicode!»' +mkdir "$TEST_ROOT/3rd/$DIR1" +mkdir "$TEST_ROOT/3rd/$DIR2" +mkdir "$TEST_ROOT"/3rd/'\[\]' +mkdir "$TEST_ROOT"/3rd/'%%' +mkdir "$TEST_ROOT"/3rd/'#[bold]' +mkdir "$TEST_ROOT"/3rd/'(echo)' +mkdir "$TEST_ROOT"/3rd/'$(echo)' +mkdir "$TEST_ROOT"/3rd/'`echo`' +mkdir "$TEST_ROOT"/3rd/'«Unicode!»' -mkdir tests/shell/fish_home -mkdir tests/shell/fish_home/fish -mkdir tests/shell/fish_home/fish/generated_completions -cp -r tests/test_shells/ipython_home tests/shell +mkdir "$TEST_ROOT/fish_home" +mkdir "$TEST_ROOT/fish_home/fish" +mkdir "$TEST_ROOT/fish_home/fish/generated_completions" +cp -r "$ROOT/tests/test_shells/ipython_home" "$TEST_ROOT" -mkdir tests/shell/path -ln -s "$(which "${PYTHON}")" tests/shell/path/python -ln -s "$(which env)" tests/shell/path -ln -s "$(which git)" tests/shell/path -ln -s "$(which sleep)" tests/shell/path -ln -s "$(which cat)" tests/shell/path -ln -s "$(which false)" tests/shell/path -ln -s "$(which true)" tests/shell/path -ln -s "$(which kill)" tests/shell/path -ln -s "$(which echo)" tests/shell/path -ln -s "$(which which)" tests/shell/path -ln -s "$(which dirname)" tests/shell/path -ln -s "$(which wc)" tests/shell/path -ln -s "$(which stty)" tests/shell/path -ln -s "$(which cut)" tests/shell/path -ln -s "$(which bc)" tests/shell/path -ln -s "$(which expr)" tests/shell/path -ln -s "$(which mktemp)" tests/shell/path -ln -s "$(which grep)" tests/shell/path -ln -s "$(which sed)" tests/shell/path -ln -s "$(which rm)" tests/shell/path -ln -s "$(which tr)" tests/shell/path -ln -s "$(which uname)" tests/shell/path -ln -s "$(which test)" tests/shell/path -ln -s "$(which pwd)" tests/shell/path -ln -s "$(which hostname)" tests/shell/path -ln -s ../../test_shells/bgscript.sh tests/shell/path -ln -s ../../test_shells/waitpid.sh tests/shell/path +mkdir "$TEST_ROOT/path" +ln -s "$(which "${PYTHON}")" "$TEST_ROOT/path/python" +ln -s "$(which env)" "$TEST_ROOT/path" +ln -s "$(which git)" "$TEST_ROOT/path" +ln -s "$(which sleep)" "$TEST_ROOT/path" +ln -s "$(which cat)" "$TEST_ROOT/path" +ln -s "$(which false)" "$TEST_ROOT/path" +ln -s "$(which true)" "$TEST_ROOT/path" +ln -s "$(which kill)" "$TEST_ROOT/path" +ln -s "$(which echo)" "$TEST_ROOT/path" +ln -s "$(which which)" "$TEST_ROOT/path" +ln -s "$(which dirname)" "$TEST_ROOT/path" +ln -s "$(which wc)" "$TEST_ROOT/path" +ln -s "$(which stty)" "$TEST_ROOT/path" +ln -s "$(which cut)" "$TEST_ROOT/path" +ln -s "$(which bc)" "$TEST_ROOT/path" +ln -s "$(which expr)" "$TEST_ROOT/path" +ln -s "$(which mktemp)" "$TEST_ROOT/path" +ln -s "$(which grep)" "$TEST_ROOT/path" +ln -s "$(which sed)" "$TEST_ROOT/path" +ln -s "$(which rm)" "$TEST_ROOT/path" +ln -s "$(which tr)" "$TEST_ROOT/path" +ln -s "$(which uname)" "$TEST_ROOT/path" +ln -s "$(which test)" "$TEST_ROOT/path" +ln -s "$(which pwd)" "$TEST_ROOT/path" +ln -s "$(which hostname)" "$TEST_ROOT/path" +ln -s "$ROOT/tests/test_shells/bgscript.sh" "$TEST_ROOT/path" +ln -s "$ROOT/tests/test_shells/waitpid.sh" "$TEST_ROOT/path" if which socat ; then - ln -s "$(which socat)" tests/shell/path + ln -s "$(which socat)" "$TEST_ROOT/path" fi for pexe in powerline powerline-config powerline-render powerline.sh powerline.py ; do - if test -e scripts/$pexe ; then - ln -s "$PWD/scripts/$pexe" tests/shell/path + if test -e "$ROOT/scripts/$pexe" ; then + ln -s "$ROOT/scripts/$pexe" "$TEST_ROOT/path" elif test -e client/$pexe ; then - ln -s "$PWD/client/$pexe" tests/shell/path + ln -s "$ROOT/client/$pexe" "$TEST_ROOT/path" elif which $pexe ; then - ln -s "$(which $pexe)" tests/shell/path + ln -s "$(which $pexe)" "$TEST_ROOT/path" else echo "Executable $pexe was not found" exit 1 fi done -ln -s python tests/shell/path/pdb +ln -s python "$TEST_ROOT/path/pdb" PDB_PYTHON=pdb -ln -s python tests/shell/path/ipython +ln -s python "$TEST_ROOT/path/ipython" IPYTHON_PYTHON=ipython if test -z "$POWERLINE_RC_EXE" ; then @@ -229,10 +226,20 @@ if test -z "$POWERLINE_RC_EXE" ; then fi if which "$POWERLINE_RC_EXE" >/dev/null ; then - ln -s "$(which $POWERLINE_RC_EXE)" tests/shell/path/rc + ln -s "$(which $POWERLINE_RC_EXE)" "$TEST_ROOT/path/rc" fi -for exe in bash zsh busybox fish tcsh mksh dash ; do +exes="bash zsh busybox tcsh mksh" + +if test "$TRAVIS" != "true" ; then + # For some reason fish does not work on travis + exes="$exes fish" +fi + +# dash has some problems with job control +#exes="$exes dash" + +for exe in $exes ; do if which $exe >/dev/null ; then if test "$exe" = "fish" ; then fish_version="$(fish --version 2>&1)" @@ -261,12 +268,12 @@ for exe in bash zsh busybox fish tcsh mksh dash ; do fi fi fi - ln -s "$(which $exe)" tests/shell/path + ln -s "$(which $exe)" "$TEST_ROOT/path" fi done -mkdir tests/shell/home -export HOME="$PWD/tests/shell/home" +mkdir "$TEST_ROOT/home" +export HOME="$TEST_ROOT/home" unset ENV @@ -277,7 +284,10 @@ echo "Powerline address: $ADDRESS" check_test_client() { local executable="$1" local client_type="$2" - local actual_mime_type="$(file --mime-type --brief --dereference "tests/shell/path/$executable" | cut -d/ -f1)" + local actual_mime_type="$( + file --mime-type --brief --dereference "$TEST_ROOT/path/$executable" \ + | cut -d/ -f1 + )" local expected_mime_type case "$client_type" in C) expected_mime_type="application/x-executable" ;; @@ -291,14 +301,20 @@ check_test_client() { fi } -if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbusybox || test "x${ONLY_SHELL}" = xrc ; then +if ( \ + test -z "${ONLY_SHELL}" \ + || test "${ONLY_SHELL%sh}" != "${ONLY_SHELL}" \ + || test "${ONLY_SHELL}" = "busybox" \ + || test "${ONLY_SHELL}" = "rc" \ +) ; then scripts/powerline-config shell command for TEST_TYPE in "daemon" "nodaemon" ; do - if test "x$ONLY_TEST_TYPE" != "x" && test "x$ONLY_TEST_TYPE" != "x$TEST_TYPE" ; then + if test -n "$ONLY_TEST_TYPE" && test "$ONLY_TEST_TYPE" != "$TEST_TYPE" + then continue fi - if test x$FAST = x1 ; then + if test "$FAST" = 1 ; then if test $TEST_TYPE = daemon ; then VARIANTS=3 else @@ -310,8 +326,8 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te if test $TEST_TYPE = daemon ; then sh -c ' - echo $$ > tests/shell/daemon_pid - exec $PYTHON ./scripts/powerline-daemon -s$ADDRESS -f >tests/shell/daemon_log 2>&1 + echo $$ > "$TEST_ROOT/daemon_pid" + exec "$PYTHON" ./scripts/powerline-daemon -s"$ADDRESS" -f >"$TEST_ROOT/daemon_log" 2>&1 ' & fi echo "> Testing $TEST_TYPE" @@ -333,17 +349,24 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te continue fi I="$(( I + 1 ))" - if test "$TEST_CLIENT" = "C" && ! test -x scripts/powerline ; then + if test "$TEST_CLIENT" = "C" && ! test -x "$ROOT/scripts/powerline" + then if which powerline >/dev/null ; then POWERLINE_COMMAND=powerline else continue fi fi - if test "$TEST_CLIENT" = "shell" && ! test -x tests/shell/path/socat ; then + if ( \ + test "$TEST_CLIENT" = "shell" \ + && ! test -x "$TEST_ROOT/path/socat" \ + ) ; then continue fi - if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then + if ( \ + test -n "$ONLY_TEST_CLIENT" \ + && test "$TEST_CLIENT" != "$ONLY_TEST_CLIENT" \ + ) ; then continue fi export POWERLINE_COMMAND_ARGS="--socket $ADDRESS" @@ -361,90 +384,96 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te "rc -i -p" do J="$(( J + 1 ))" - if test x$FAST = x1 ; then + if test "$FAST" = 1 ; then if test $(( (I + J) % $VARIANTS )) -ne $EXETEST ; then continue fi fi SH="${TEST_COMMAND%% *}" - if test "x$ONLY_SHELL" != "x" && test "x$ONLY_SHELL" != "x$SH" ; then + if test -n "$ONLY_SHELL" && test "$ONLY_SHELL" != "$SH" ; then continue fi - if ! test -x tests/shell/path/$SH ; then + if ! test -x "$TEST_ROOT/path/$SH" ; then continue fi - echo ">>> $(readlink "tests/shell/path/$SH")" + echo ">>> $(readlink "$TEST_ROOT/path/$SH")" if ! run_test $TEST_TYPE $TEST_CLIENT $TEST_COMMAND ; then - ALLOW_FAILURE_ARG= - # dash tests are not stable, see #931 - # also do not allow fish tests to spoil the build - if test x$FAST$SH = x1dash || test x$FAST$SH = x1fish ; then - ALLOW_FAILURE_ARG="--allow-failure" - fi - fail $ALLOW_FAILURE_ARG "$SH-$TEST_TYPE-$TEST_CLIENT:test" F "Failed checking $TEST_COMMAND" + fail "$SH-$TEST_TYPE-$TEST_CLIENT:test" F \ + "Failed checking $TEST_COMMAND" fi done done if test $TEST_TYPE = daemon ; then - $PYTHON ./scripts/powerline-daemon -s$ADDRESS -k - wait $(cat tests/shell/daemon_pid) - if ! test -z "$(cat tests/shell/daemon_log)" ; then + "$PYTHON" ./scripts/powerline-daemon -s"$ADDRESS" -k + wait $(cat "$TEST_ROOT/daemon_pid") + if ! test -z "$(cat "$TEST_ROOT/daemon_log")" ; then echo '____________________________________________________________' echo "Daemon log:" echo '============================================================' - cat tests/shell/daemon_log - fail "$SH-$TEST_TYPE-$TEST_CLIENT:log" E "Non-empty daemon log for ${TEST_COMMAND}" + cat "$TEST_ROOT/daemon_log" + fail "$SH-$TEST_TYPE-$TEST_CLIENT:log" E \ + "Non-empty daemon log for ${TEST_COMMAND}" fi fi done fi -if $PYTHON scripts/powerline-daemon -s$ADDRESS > tests/shell/daemon_log_2 2>&1 ; then +if "$PYTHON" scripts/powerline-daemon -s"$ADDRESS" \ + > "$TEST_ROOT/daemon_log_2" 2>&1 +then sleep 1 - $PYTHON scripts/powerline-daemon -s$ADDRESS -k + "$PYTHON" scripts/powerline-daemon -s"$ADDRESS" -k else fail "daemon:run" F "Daemon exited with status $?" fi -if ! test -z "$(cat tests/shell/daemon_log_2)" ; then +if ! test -z "$(cat "$TEST_ROOT/daemon_log_2")" ; then echo '____________________________________________________________' echo "Daemon log (2nd):" echo '============================================================' - cat tests/shell/daemon_log_2 + cat "$TEST_ROOT/daemon_log_2" fail "daemon:log" E "Daemon run with non-empty log" fi -if ( test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xzsh" ) \ - && ( test "x${ONLY_TEST_TYPE}" = "x" || test "x${ONLY_TEST_TYPE}" = "xzpython" ) \ - && zsh tests/test_shells/zsh_test_script.zsh 2>/dev/null; then +if ( test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "zsh" ) \ + && ( test -z "${ONLY_TEST_TYPE}" || test "${ONLY_TEST_TYPE}" = "zpython" ) \ + && "$TEST_ROOT/path/zsh" "$ROOT/tests/test_shells/zsh_test_script.zsh" +then echo "> zpython" if ! run_test zpython zpython zsh -f -i ; then fail "zsh-zpython:test" F "Failed checking zsh -f -i" fi fi -if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xpdb" ; then +if test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "pdb" ; then if test "$PYTHON_IMPLEMENTATION" != "PyPy" ; then - if test "x${ONLY_TEST_TYPE}" = "x" || test "x${ONLY_TEST_TYPE}" = "xsubclass" ; then + if test -z "${ONLY_TEST_TYPE}" || test "${ONLY_TEST_TYPE}" = "subclass" + then echo "> pdb subclass" - if ! run_test subclass python $PDB_PYTHON "$PWD/tests/test_shells/pdb-main.py" ; then - fail "pdb-subclass:test" F "Failed checking $PDB_PYTHON $PWD/tests/test_shells/pdb-main.py" + if ! run_test subclass python $PDB_PYTHON \ + "$ROOT/tests/test_shells/pdb-main.py" + then + fail "pdb-subclass:test" F \ + "Failed checking $PDB_PYTHON $ROOT/tests/test_shells/pdb-main.py" fi fi - if test "x${ONLY_TEST_TYPE}" = "x" || test "x${ONLY_TEST_TYPE}" = "xmodule" ; then + if test -z "${ONLY_TEST_TYPE}" || test "${ONLY_TEST_TYPE}" = "module" ; then echo "> pdb module" MODULE="powerline.bindings.pdb" if test "$PYTHON_MM" = "2.6" ; then MODULE="powerline.bindings.pdb.__main__" fi - if ! run_test module python $PDB_PYTHON -m$MODULE "$PWD/tests/test_shells/pdb-script.py" ; then - fail "pdb-module:test" F "Failed checking $PDB_PYTHON -m$MODULE $PWD/tests/test_shells/pdb-script" + if ! run_test module python "$PDB_PYTHON" -m"$MODULE" \ + "$ROOT/tests/test_shells/pdb-script.py" + then + fail "pdb-module:test" F \ + "Failed checking $PDB_PYTHON -m$MODULE $ROOT/tests/test_shells/pdb-script" fi fi fi fi -if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then +if test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "ipython" ; then if "${PYTHON}" -c "try: import IPython${NL}except ImportError: raise SystemExit(1)" ; then # Define some overrides which should be ignored by IPython. export POWERLINE_CONFIG_OVERRIDES='common.term_escape_style=fbterm' @@ -459,8 +488,4 @@ if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then fi fi -if test $FAILED -eq 0 ; then - rm -r tests/shell -fi - exit_suite diff --git a/tests/test_shells/zsh.zpython.ok b/tests/test_shells/zsh.zpython.ok deleted file mode 100644 index b19cf390..00000000 --- a/tests/test_shells/zsh.zpython.ok +++ /dev/null @@ -1,41 +0,0 @@ - -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd .git -  HOSTNAME  USER   BRANCH  …  shell  3rd  .git  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV="/home/USER/.virtenvs/some-virtual-environment" -  HOSTNAME  USER  (e) some-virtual-environment   BRANCH  …  tests  shell  3rd  VIRTUAL_ENV= -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bgscript.sh & waitpid.sh -[1] PID -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  false -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s -[1] + terminated bgscript.sh -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  cd "$DIR1" -  HOSTNAME  USER   BRANCH  …  shell  3rd  ^[[32m  cd ../"$DIR2" -  HOSTNAME  USER   BRANCH  …  shell  3rd  ^H  cd ../'\[\]' -  HOSTNAME  USER   BRANCH  …  shell  3rd  \[\]  cd ../'%%' -  HOSTNAME  USER   BRANCH  …  shell  3rd  %%  cd ../'#[bold]' -  HOSTNAME  USER   BRANCH  …  shell  3rd  #[bold]  cd ../'(echo)' -  HOSTNAME  USER   BRANCH  …  shell  3rd  (echo)  cd ../'$(echo)' -  HOSTNAME  USER   BRANCH  …  shell  3rd  $(echo)  cd ../'`echo`' -  HOSTNAME  USER   BRANCH  …  shell  3rd  `echo`  cd ../'«Unicode!»' -  HOSTNAME  USER   BRANCH  …  shell  3rd  «Unicode!»  cd .. -  HOSTNAME  USER   BRANCH  …  tests  shell  3rd  bindkey -v ; set_theme default - INSERT   HOSTNAME  USER  …  tests  shell  3rd   COMMND   HOSTNAME  USER  …  tests  shell  3rd   - INSERT   HOSTNAME  USER  …  tests  shell  3rd   - INSERT   HOSTNAME  USER  …  tests  shell  3rd  echo abc -abc - INSERT   HOSTNAME  USER  …  tests  shell  3rd  false - INSERT   HOSTNAME  USER  …  tests  shell  3rd  set_theme_option default.segment_data.hostname.display false - INSERT  USER  …  tests  shell  3rd  set_theme_option default.segment_data.user.display false - INSERT  …  tests  shell  3rd  select abc in def ghi jkl - select                            do - select                             echo $abc - select                             break - select                            done -1) def 2) ghi 3) jkl -                   Select variant  1 -def - INSERT  …  tests  shell  3rd  cd . - INSERT  …  tests  shell  3rd  cd . - INSERT  …  tests  shell  3rd  hash -d foo=$PWD:h ; cd . - INSERT  ~foo  3rd  set_theme_option default.dividers.left.hard \$ABC - INSERT $ABC~foo  3rd $ABCtrue diff --git a/tests/test_shells/zsh_test_script.zsh b/tests/test_shells/zsh_test_script.zsh index f4b894ce..3957f567 100644 --- a/tests/test_shells/zsh_test_script.zsh +++ b/tests/test_shells/zsh_test_script.zsh @@ -1,6 +1,8 @@ set -e +set -x . tests/bot-ci/scripts/common/main.sh -zmodload zpython +zmodload zpython || zmodload libzpython +zpython 'import zsh' zpython 'import platform' zpython 'zsh.setvalue("ZSH_PYTHON_VERSION", platform.python_version())' zpython 'zsh.setvalue("ZSH_PYTHON_IMPLEMENTATION", platform.python_implementation())' diff --git a/tests/setup_statusline_catcher.py b/tests/test_vim/pyfiles/setup_statusline_catcher.py similarity index 100% rename from tests/setup_statusline_catcher.py rename to tests/test_vim/pyfiles/setup_statusline_catcher.py diff --git a/tests/test_vim/test.sh b/tests/test_vim/test.sh new file mode 100755 index 00000000..a522946e --- /dev/null +++ b/tests/test_vim/test.sh @@ -0,0 +1,49 @@ +#!/bin/sh +. tests/shlib/common.sh +. tests/shlib/vim.sh + +enter_suite vim + +make_test_root + +# Define some overrides. These ones must be ignored and do not affect Vim +# status/tab lines. +export POWERLINE_CONFIG_OVERRIDES='common.default_top_theme=ascii' +export POWERLINE_THEME_OVERRIDES='default.segments.left=[]' + +test_script() { + local vim="$1" ; shift + local script="$1" ; shift + echo "Running script $script with $vim" + if ! test -e "$vim" ; then + return 0 + fi + if ! script="$script" "$vim" -u NONE -c 'source $script' \ + || test -f message.fail + then + local test_name="${script##*/}" + fail "${test_name%.vim}" F "Failed script $script run with $vim" + if test -e message.fail ; then + cat message.fail >&2 + rm message.fail + fi + fi +} + +TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests" + +cd "$TEST_ROOT" + +for script in "$TEST_SCRIPT_ROOT"/*.vim ; do + if test "${script%.old.vim}" = "${script}" ; then + test_script "$NEW_VIM" "$script" + fi +done + +if test -e "$OLD_VIM" ; then + for script in "$TEST_SCRIPT_ROOT"/*.old.vim ; do + test_script "$OLD_VIM" "$script" + done +fi + +exit_suite diff --git a/tests/test_commandt_plugin.vim b/tests/test_vim/tests/commandt_plugin.vim similarity index 91% rename from tests/test_commandt_plugin.vim rename to tests/test_vim/tests/commandt_plugin.vim index 355fff7c..9f944b94 100755 --- a/tests/test_commandt_plugin.vim +++ b/tests/test_vim/tests/commandt_plugin.vim @@ -1,7 +1,7 @@ #!/usr/bin/vim -S set nocompatible set columns=80 -execute 'source' fnameescape(expand(':p:h').'/vim_utils.vim') +execute 'source' fnameescape(expand(':p:h:h').'/vim_utils.vim') call EnablePlugins('command-t') call SourcePowerline() let g:statusline_values = [] @@ -9,9 +9,9 @@ call PyFile('setup_statusline_catcher') execute 'CommandTBuffer'|call feedkeys("\") call RunPython('powerline.render = _powerline_old_render') let g:expected_statusline = '%#Pl_231_16777215_240_5789784_bold# Command-T %#Pl_231_16777215_240_5789784_NONE# %#Pl_231_16777215_240_5789784_bold#BufferFinder %#Pl_240_5789784_236_3158064_NONE# %#Pl_231_16777215_236_3158064_NONE#                                                    ' +call CheckMessages() if index(g:statusline_values, g:expected_statusline) == -1 call CheckStatuslineValue(get(g:statusline_values, -1, ''), g:expected_statusline) cquit endif -call CheckMessages() qall diff --git a/tests/test_empty_encoding.old.vim b/tests/test_vim/tests/empty_encoding.old.vim similarity index 79% rename from tests/test_empty_encoding.old.vim rename to tests/test_vim/tests/empty_encoding.old.vim index e24cd447..124a10a3 100755 --- a/tests/test_empty_encoding.old.vim +++ b/tests/test_vim/tests/empty_encoding.old.vim @@ -11,10 +11,10 @@ if !empty(&encoding) cquit endif -let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] +let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config_files'] try - source powerline/bindings/vim/plugin/powerline.vim + source :p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim catch call writefile(['Unexpected exception:', v:exception], 'message.fail') cquit diff --git a/tests/test_foreign_stl_override.vim b/tests/test_vim/tests/foreign_stl_override.vim similarity index 71% rename from tests/test_foreign_stl_override.vim rename to tests/test_vim/tests/foreign_stl_override.vim index 0cafb558..2a5b8c01 100644 --- a/tests/test_foreign_stl_override.vim +++ b/tests/test_vim/tests/foreign_stl_override.vim @@ -1,10 +1,10 @@ scriptencoding utf-8 set encoding=utf-8 -let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] +let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config_files'] set laststatus=2 redir => g:messages try - source powerline/bindings/vim/plugin/powerline.vim + source :p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim redrawstatus! vsplit redrawstatus! diff --git a/tests/test_invalid_unicode.vim b/tests/test_vim/tests/invalid_unicode.vim similarity index 68% rename from tests/test_invalid_unicode.vim rename to tests/test_vim/tests/invalid_unicode.vim index d09e2bb2..ac91f3c5 100644 --- a/tests/test_invalid_unicode.vim +++ b/tests/test_vim/tests/invalid_unicode.vim @@ -1,11 +1,11 @@ set encoding=utf-8 -let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] +let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config_files'] set laststatus=2 set showtabline=2 edit `="\xFF"` redir => g:messages try - source powerline/bindings/vim/plugin/powerline.vim + source :p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim redrawstatus! catch call writefile(['Unexpected exception', v:exception], 'message.fail') diff --git a/tests/test_local_overrides.vim b/tests/test_vim/tests/local_overrides.vim similarity index 94% rename from tests/test_local_overrides.vim rename to tests/test_vim/tests/local_overrides.vim index 353c086d..aba14e2d 100755 --- a/tests/test_local_overrides.vim +++ b/tests/test_vim/tests/local_overrides.vim @@ -1,6 +1,6 @@ #!/usr/bin/vim -S set encoding=utf-8 -let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] +let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config_files'] let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}} let g:powerline_theme_overrides = {'default': {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}}} diff --git a/tests/test_nerdtree_plugin.vim b/tests/test_vim/tests/nerdtree_plugin.vim similarity index 83% rename from tests/test_nerdtree_plugin.vim rename to tests/test_vim/tests/nerdtree_plugin.vim index 56b85b77..761cb5ff 100755 --- a/tests/test_nerdtree_plugin.vim +++ b/tests/test_vim/tests/nerdtree_plugin.vim @@ -1,7 +1,7 @@ #!/usr/bin/vim -S set nocompatible set columns=80 -execute 'source' fnameescape(expand(':p:h').'/vim_utils.vim') +execute 'source' fnameescape(expand(':p:h:h').'/vim_utils.vim') call EnablePlugins('nerdtree') call SourcePowerline() NERDTree /home diff --git a/tests/test_plugin_file.vim b/tests/test_vim/tests/plugin_file.vim similarity index 64% rename from tests/test_plugin_file.vim rename to tests/test_vim/tests/plugin_file.vim index e139c44f..18489332 100755 --- a/tests/test_plugin_file.vim +++ b/tests/test_vim/tests/plugin_file.vim @@ -1,10 +1,10 @@ #!/usr/bin/vim -S set encoding=utf-8 -let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] +let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config_files'] tabedit abc tabedit def try - source powerline/bindings/vim/plugin/powerline.vim + source :p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim catch call writefile([v:exception], 'message.fail') cquit diff --git a/tests/test_tabline.vim b/tests/test_vim/tests/tabline.vim similarity index 93% rename from tests/test_tabline.vim rename to tests/test_vim/tests/tabline.vim index a2e1374f..ff76dc02 100755 --- a/tests/test_tabline.vim +++ b/tests/test_vim/tests/tabline.vim @@ -1,7 +1,7 @@ #!/usr/bin/vim -S set encoding=utf-8 -let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] -source powerline/bindings/vim/plugin/powerline.vim +let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config_files'] +source :p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim edit abc tabedit def tabedit ghi diff --git a/tests/vim_utils.vim b/tests/test_vim/vim_utils.vim similarity index 87% rename from tests/vim_utils.vim rename to tests/test_vim/vim_utils.vim index 5922d454..6219ec48 100644 --- a/tests/vim_utils.vim +++ b/tests/test_vim/vim_utils.vim @@ -1,9 +1,10 @@ let g:powerline_use_var_handler = 1 -let g:root=expand(':p:h:h') -let g:mf=g:root.'/message.fail' +let g:pyfiles_root=expand(':p:h').'/pyfiles' +let g:root=expand(':p:h:h:h') +let g:mf=fnamemodify('message.fail', ':p') -command -nargs=1 LST :call writefile(, g:mf) | cquit +command -nargs=1 LST :call writefile(, g:mf, 'a') | cquit command -nargs=1 ERR :LST [] command -nargs=1 EXC :ERR 'Unexpected exception', , v:exception, v:throwpoint @@ -76,9 +77,9 @@ function RunPython(s) endfunction function PyFile(f) if has('python') - execute 'pyfile' fnameescape(g:root.'/tests/'.a:f.'.py') + execute 'pyfile' fnameescape(g:pyfiles_root.'/'.a:f.'.py') else - execute 'py3file' fnameescape(g:root.'/tests/'.a:f.'.py') + execute 'py3file' fnameescape(g:pyfiles_root.'/'.a:f.'.py') endif endfunction diff --git a/tests/path/vim.py b/tests/vim_sys_path/vim.py similarity index 82% rename from tests/path/vim.py rename to tests/vim_sys_path/vim.py index 1de56240..e9dba669 100644 --- a/tests/path/vim.py +++ b/tests/vim_sys_path/vim.py @@ -1,7 +1,7 @@ # vim:fileencoding=utf-8:noet from __future__ import (unicode_literals, division, absolute_import, print_function) -from tests import vim +import tests.modules.vim as vim globals().update(vim._init())