From 1b3aacb8373590b5ce834a7c4e99a821b9b910f9 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 13:18:50 +0300 Subject: [PATCH 01/22] Move most of the vterm testing code to tests.lib.terminal --- tests/lib/terminal.py | 121 +++++++++++++++++++++++ tests/test_in_vterm/test_tmux.py | 159 +++++++------------------------ 2 files changed, 154 insertions(+), 126 deletions(-) diff --git a/tests/lib/terminal.py b/tests/lib/terminal.py index 29177e2a..84e4be1b 100644 --- a/tests/lib/terminal.py +++ b/tests/lib/terminal.py @@ -2,13 +2,17 @@ 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.lib.vterm import VTerm, Dimensions @@ -135,3 +139,120 @@ class ExpectProcess(threading.Thread): line, attrs = self.get_row(row, attrs, default_props) lines.append(line) return '\n'.join(lines), attrs + + +def test_expected_result(p, expected_result, last_attempt, + last_attempt_cb=None): + 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 + '\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, lib, dim, args, env, cwd=None, fin_cb=None, + last_attempt_cb=None, attempts=3): + while attempts: + try: + p = ExpectProcess( + lib=lib, + dim=dim, + cmd=cmd, + args=args, + cwd=cwd, + env=env, + ) + p.start() + + ret = True + + for test_prep, expected_result in tests: + test_prep(p) + ret = ( + ret + and test_expected_result(p, expected_result, 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/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index 635c83a9..ca3a4b45 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.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,6 +53,17 @@ 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') @@ -109,40 +74,11 @@ def main(attempts=3): else: lib = os.environ.get('POWERLINE_LIBVTERM', 'libvterm.so') - 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', + socket_path = os.path.abspath('tmux-socket-{0}'.format(attempts)) + if os.path.exists(socket_path): + os.unlink(socket_path) + + env = get_env(vterm_path, VTERM_TEST_DIR, { 'POWERLINE_THEME_OVERRIDES': ';'.join(( key + '=' + json.dumps(val) for key, val in ( @@ -162,9 +98,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 "' + ( @@ -268,10 +203,10 @@ def main(attempts=3): ), ) - def prepare_test_1(): + def prepare_test_1(p): sleep(5) - def prepare_test_2(): + def prepare_test_2(p): dim.cols = 40 p.resize(dim) sleep(5) @@ -281,10 +216,6 @@ def main(attempts=3): 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 +232,17 @@ 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=zip(test_preps, expected_results), + cmd=tmux_exe, + lib=lib, + dim=dim, + args=args, + env=env, + cwd=VTERM_TEST_DIR, + fin_cb=tmux_fin_cb, + last_attempt_cb=print_tmux_logs, + ) if __name__ == '__main__': From 65130ae6ff6f2968681787efa7bdeac0362223b2 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 13:25:44 +0300 Subject: [PATCH 02/22] Hide test/vterm_tmux in env variable, use absolute paths --- tests/common.sh | 2 +- tests/test_in_vterm/test_tmux.sh | 37 +++++++++++++++++--------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index eb3bbab7..5b3627a1 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -35,7 +35,7 @@ fail() { 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 + echo "$full_msg" >> "$ROOT/tests/failures" if test "x$allow_failure" = "x" ; then FAILED=1 fi diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index c62ce530..070532a8 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -3,18 +3,20 @@ 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 +rm -rf "$VTERM_TEST_DIR" +mkdir "$VTERM_TEST_DIR" +mkdir "$VTERM_TEST_DIR/path" -cp -r tests/terminfo tests/vterm_tmux +ln -s "$(which "${PYTHON}")" "$VTERM_TEST_DIR/path/python" +ln -s "$(which bash)" "$VTERM_TEST_DIR/path" +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" + +cp -r "$ROOT/tests/terminfo" "$VTERM_TEST_DIR" test_tmux() { if test "$PYTHON_IMPLEMENTATION" = PyPy; then @@ -25,17 +27,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" + 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 @@ -44,7 +47,7 @@ else fi if test $FAILED -eq 0 ; then - rm -rf tests/vterm_tmux + rm -rf "$VTERM_TEST_DIR" else echo "$FAIL_SUMMARY" fi From a05857e64eeed334996cd0de5d2c5c44ef2dc9ee Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 13:40:29 +0300 Subject: [PATCH 03/22] Move some code away of test_tmux.sh --- tests/common.sh | 6 ++++-- tests/test_in_vterm/test_tmux.sh | 15 +++------------ tests/vterm.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 tests/vterm.sh diff --git a/tests/common.sh b/tests/common.sh index 5b3627a1..1b323b7b 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -3,9 +3,11 @@ set +x : ${PYTHON:=python} -FAILED=0 +if test -z "$FAILED" ; then + FAILED=0 -FAIL_SUMMARY="" + FAIL_SUMMARY="" +fi enter_suite() { local suite_name="$1" diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index 070532a8..3e8a5c57 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -1,23 +1,18 @@ #!/bin/sh . tests/common.sh +. tests/vterm.sh enter_suite tmux VTERM_TEST_DIR="$ROOT/tests/vterm_tmux" -rm -rf "$VTERM_TEST_DIR" -mkdir "$VTERM_TEST_DIR" -mkdir "$VTERM_TEST_DIR/path" +vterm_setup "$VTERM_TEST_DIR" -ln -s "$(which "${PYTHON}")" "$VTERM_TEST_DIR/path/python" -ln -s "$(which bash)" "$VTERM_TEST_DIR/path" 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" -cp -r "$ROOT/tests/terminfo" "$VTERM_TEST_DIR" - test_tmux() { if test "$PYTHON_IMPLEMENTATION" = PyPy; then # FIXME PyPy3 segfaults for some reason, PyPy does it as well, but @@ -46,10 +41,6 @@ else test_tmux || true fi -if test $FAILED -eq 0 ; then - rm -rf "$VTERM_TEST_DIR" -else - echo "$FAIL_SUMMARY" -fi +vterm_shutdown "$VTERM_TEST_DIR" exit_suite diff --git a/tests/vterm.sh b/tests/vterm.sh new file mode 100644 index 00000000..8105ed29 --- /dev/null +++ b/tests/vterm.sh @@ -0,0 +1,26 @@ +. tests/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 +} From 96d83346a54168274ca770aead8882f5e9ecb127 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 13:41:54 +0300 Subject: [PATCH 04/22] Be more explicit about what to link tmux executable to --- tests/test_in_vterm/test_tmux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index 3e8a5c57..66418e02 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -22,7 +22,7 @@ test_tmux() { if ! which "${POWERLINE_TMUX_EXE}" ; then return 0 fi - ln -sf "$(which "${POWERLINE_TMUX_EXE}")" "$VTERM_TEST_DIR/path" + 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)" From 9d7366436b4821bb2fa9444479eccd4b195f95de Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 13:55:24 +0300 Subject: [PATCH 05/22] Move some env variables definition out of run_vim_tests.sh --- tests/run_vim_tests.sh | 37 +++---------------------------------- tests/vim.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 tests/vim.sh diff --git a/tests/run_vim_tests.sh b/tests/run_vim_tests.sh index c32831db..798d5536 100755 --- a/tests/run_vim_tests.sh +++ b/tests/run_vim_tests.sh @@ -1,40 +1,9 @@ #!/bin/sh . tests/common.sh +. tests/vim.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' @@ -48,9 +17,9 @@ test_script() { if ! test -e "$vim" ; then return 0 fi - if ! "$vim" -u NONE -S $script || test -f message.fail ; then + 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" + fail "${test_name%.vim}" F "Failed script $script run with $vim" cat message.fail >&2 rm message.fail fi diff --git a/tests/vim.sh b/tests/vim.sh new file mode 100644 index 00000000..49346dac --- /dev/null +++ b/tests/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 From 255ff49defcd4c90cdfd66d2575b04bf752df80b Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 14:36:50 +0300 Subject: [PATCH 06/22] Define tests via dictionaries, do not hardcode row number --- tests/lib/terminal.py | 18 +-- tests/test_in_vterm/test_tmux.py | 192 ++++++++++++++++--------------- 2 files changed, 108 insertions(+), 102 deletions(-) diff --git a/tests/lib/terminal.py b/tests/lib/terminal.py index 84e4be1b..8088a0cf 100644 --- a/tests/lib/terminal.py +++ b/tests/lib/terminal.py @@ -141,13 +141,12 @@ class ExpectProcess(threading.Thread): return '\n'.join(lines), attrs -def test_expected_result(p, expected_result, last_attempt, - last_attempt_cb=None): - expected_text, attrs = expected_result +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(p.dim.rows - 1, attrs) + actual_text, all_attrs = p.get_row(test['row'], attrs) if actual_text == expected_text: return True attempts -= 1 @@ -236,11 +235,16 @@ def do_terminal_tests(tests, cmd, lib, dim, args, env, cwd=None, fin_cb=None, ret = True - for test_prep, expected_result in tests: - test_prep(p) + for test in tests: + try: + test_prep = test['prep_cb'] + except KeyError: + pass + else: + test_prep(p) ret = ( ret - and test_expected_result(p, expected_result, attempts == 0, + and test_expected_result(p, test, attempts == 0, last_attempt_cb) ) diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index ca3a4b45..de8a87d6 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -112,97 +112,6 @@ def main(attempts=3): dim = MutableDimensions(rows=50, cols=200) - base_attrs = { - ((0, 0, 0), (243, 243, 243), 1, 0, 0): 'lead', - ((243, 243, 243), (11, 11, 11), 0, 0, 0): 'leadsep', - ((255, 255, 255), (11, 11, 11), 0, 0, 0): 'bg', - ((199, 199, 199), (88, 88, 88), 0, 0, 0): 'cwd', - ((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, - })), - ), - ) - def prepare_test_1(p): sleep(5) @@ -211,9 +120,102 @@ def main(attempts=3): p.resize(dim) sleep(5) - test_preps = ( - prepare_test_1, - prepare_test_2, + base_attrs = { + ((0, 0, 0), (243, 243, 243), 1, 0, 0): 'lead', + ((243, 243, 243), (11, 11, 11), 0, 0, 0): 'leadsep', + ((255, 255, 255), (11, 11, 11), 0, 0, 0): 'bg', + ((199, 199, 199), (88, 88, 88), 0, 0, 0): 'cwd', + ((88, 88, 88), (11, 11, 11), 0, 0, 0): 'cwdhsep', + ((0, 0, 0), (0, 224, 0), 0, 0, 0): 'defstl', + } + 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, + } ) args = [ @@ -233,7 +235,7 @@ def main(attempts=3): ] return do_terminal_tests( - tests=zip(test_preps, expected_results), + tests=tests, cmd=tmux_exe, lib=lib, dim=dim, From cac99271ca1c88fdb54cf43024b67c78ab20efad Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 14:42:54 +0300 Subject: [PATCH 07/22] Move lib variable to do_terminal_tests --- tests/lib/terminal.py | 9 ++++++++- tests/test_in_vterm/test_tmux.py | 6 ------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/lib/terminal.py b/tests/lib/terminal.py index 8088a0cf..7b3434a6 100644 --- a/tests/lib/terminal.py +++ b/tests/lib/terminal.py @@ -219,8 +219,15 @@ def get_env(vterm_path, test_dir, *args, **kwargs): return env -def do_terminal_tests(tests, cmd, lib, dim, args, env, cwd=None, fin_cb=None, +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( diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index de8a87d6..8bb98fd3 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -69,11 +69,6 @@ def main(attempts=3): 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) @@ -237,7 +232,6 @@ def main(attempts=3): return do_terminal_tests( tests=tests, cmd=tmux_exe, - lib=lib, dim=dim, args=args, env=env, From 2a1aef1bac095b97f38ca94cfa6fddac516a1ea2 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 14:44:26 +0300 Subject: [PATCH 08/22] Add blank vim+vterm tests --- tests/test_in_vterm/test_vim.py | 49 +++++++++++++++++++++++++++++++++ tests/test_in_vterm/test_vim.sh | 41 +++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100755 tests/test_in_vterm/test_vim.py create mode 100755 tests/test_in_vterm/test_vim.sh diff --git a/tests/test_in_vterm/test_vim.py b/tests/test_in_vterm/test_vim.py new file mode 100755 index 00000000..ff623527 --- /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.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..187a9d6c --- /dev/null +++ b/tests/test_in_vterm/test_vim.sh @@ -0,0 +1,41 @@ +#!/bin/sh +. tests/common.sh +. tests/vterm.sh +. tests/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 From c30383a1946988b598fa9e7eb6cb19c071e31e96 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 15:05:18 +0300 Subject: [PATCH 09/22] Move Python tests.* modules to tests/modules, rename tests/path --- tests/__init__.py | 11 ----------- tests/modules/__init__.py | 11 +++++++++++ tests/{ => modules}/lib/__init__.py | 0 tests/{ => modules}/lib/config_mock.py | 4 ++-- tests/{ => modules}/lib/fsconfig.py | 2 +- tests/{ => modules}/lib/terminal.py | 2 +- tests/{ => modules}/lib/vterm.py | 0 tests/{ => modules}/matchers.py | 0 tests/{ => modules}/vim.py | 0 tests/test_cmdline.py | 6 +++--- tests/test_commandt_plugin.vim | 0 tests/test_config_merging.py | 8 ++++---- tests/test_config_reload.py | 6 +++--- tests/test_configuration.py | 16 ++++++++-------- tests/test_empty_encoding.old.vim | 0 tests/test_in_vterm/test_tmux.py | 4 ++-- tests/test_in_vterm/test_vim.py | 4 ++-- tests/test_lib.py | 6 +++--- tests/test_lib_config.py | 6 +++--- tests/test_listers.py | 6 +++--- tests/test_local_overrides.vim | 0 tests/test_logging.py | 6 +++--- tests/test_nerdtree_plugin.vim | 0 tests/test_plugin_file.vim | 0 tests/test_provided_config_files.py | 10 +++++----- tests/test_segments.py | 11 ++++++----- tests/test_selectors.py | 10 +++++----- tests/test_tabline.vim | 0 tests/test_watcher.py | 4 ++-- tests/{path => vim_sys_path}/vim.py | 2 +- 30 files changed, 68 insertions(+), 67 deletions(-) create mode 100644 tests/modules/__init__.py rename tests/{ => modules}/lib/__init__.py (100%) rename tests/{ => modules}/lib/config_mock.py (98%) rename tests/{ => modules}/lib/fsconfig.py (97%) rename tests/{ => modules}/lib/terminal.py (99%) rename tests/{ => modules}/lib/vterm.py (100%) rename tests/{ => modules}/matchers.py (100%) rename tests/{ => modules}/vim.py (100%) mode change 100755 => 100644 tests/test_commandt_plugin.vim mode change 100755 => 100644 tests/test_empty_encoding.old.vim mode change 100755 => 100644 tests/test_local_overrides.vim mode change 100755 => 100644 tests/test_nerdtree_plugin.vim mode change 100755 => 100644 tests/test_plugin_file.vim mode change 100755 => 100644 tests/test_tabline.vim rename tests/{path => vim_sys_path}/vim.py (82%) 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/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/lib/terminal.py b/tests/modules/lib/terminal.py similarity index 99% rename from tests/lib/terminal.py rename to tests/modules/lib/terminal.py index 7b3434a6..75bcf4e2 100644 --- a/tests/lib/terminal.py +++ b/tests/modules/lib/terminal.py @@ -13,7 +13,7 @@ import pexpect from powerline.lib.unicode import u -from tests.lib.vterm import VTerm, Dimensions +from tests.modules.lib.vterm import VTerm, Dimensions class MutableDimensions(object): 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/test_cmdline.py b/tests/test_cmdline.py index cd021be6..b77988b2 100644 --- a/tests/test_cmdline.py +++ b/tests/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_commandt_plugin.vim b/tests/test_commandt_plugin.vim old mode 100755 new mode 100644 diff --git a/tests/test_config_merging.py b/tests/test_config_merging.py index 7e8a1366..3f4fa2ac 100644 --- a/tests/test_config_merging.py +++ b/tests/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_config_reload.py index e07b3deb..a418d496 100644 --- a/tests/test_config_reload.py +++ b/tests/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_configuration.py index fd3d4097..5728e672 100644 --- a/tests/test_configuration.py +++ b/tests/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(__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_empty_encoding.old.vim b/tests/test_empty_encoding.old.vim old mode 100755 new mode 100644 diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index 8bb98fd3..11ba95f3 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -15,8 +15,8 @@ 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, - do_terminal_tests, get_env) +from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, + do_terminal_tests, get_env) VTERM_TEST_DIR = os.path.abspath('tests/vterm_tmux') diff --git a/tests/test_in_vterm/test_vim.py b/tests/test_in_vterm/test_vim.py index ff623527..3403ec46 100755 --- a/tests/test_in_vterm/test_vim.py +++ b/tests/test_in_vterm/test_vim.py @@ -11,8 +11,8 @@ from subprocess import check_call from glob import glob1 from traceback import print_exc -from tests.lib.terminal import (ExpectProcess, MutableDimensions, - do_terminal_tests, get_env) +from tests.modules.lib.terminal import (ExpectProcess, MutableDimensions, + do_terminal_tests, get_env) VTERM_TEST_DIR = os.path.abspath('tests/vterm_vim') diff --git a/tests/test_lib.py b/tests/test_lib.py index f35f231c..c6338b88 100644 --- a/tests/test_lib.py +++ b/tests/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: @@ -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_lib_config.py index 2b3db707..ddbf4a0a 100644 --- a/tests/test_lib_config.py +++ b/tests/test_lib_config.py @@ -5,8 +5,8 @@ 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') @@ -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_listers.py index 3d3ed094..a33f0333 100644 --- a/tests/test_listers.py +++ b/tests/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_local_overrides.vim b/tests/test_local_overrides.vim old mode 100755 new mode 100644 diff --git a/tests/test_logging.py b/tests/test_logging.py index 6de4a389..cc5523cb 100644 --- a/tests/test_logging.py +++ b/tests/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}' @@ -463,5 +463,5 @@ def tearDownModule(): if __name__ == '__main__': - from tests import main + from tests.modules import main main() diff --git a/tests/test_nerdtree_plugin.vim b/tests/test_nerdtree_plugin.vim old mode 100755 new mode 100644 diff --git a/tests/test_plugin_file.vim b/tests/test_plugin_file.vim old mode 100755 new mode 100644 diff --git a/tests/test_provided_config_files.py b/tests/test_provided_config_files.py index 3ea9a7e8..ca190bd8 100644 --- a/tests/test_provided_config_files.py +++ b/tests/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 @@ -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(__file__), 'vim_sys_path'))) @classmethod def tearDownClass(cls): @@ -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_segments.py index 4149e937..23992329 100644 --- a/tests/test_segments.py +++ b/tests/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): @@ -1598,7 +1599,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(__file__), 'vim_sys_path'))) from powerline.segments import vim cls.vim = vim from powerline.segments.common import vcs @@ -1672,5 +1673,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_selectors.py index a127ae9e..ce0e383b 100644 --- a/tests/test_selectors.py +++ b/tests/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(__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_tabline.vim b/tests/test_tabline.vim old mode 100755 new mode 100644 diff --git a/tests/test_watcher.py b/tests/test_watcher.py index 571cc8c4..4cca6a29 100644 --- a/tests/test_watcher.py +++ b/tests/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', '')) @@ -241,5 +241,5 @@ def tearDownModule(): if __name__ == '__main__': - from tests import main + from tests.modules import main main() 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()) From 82ca32edc9da132b6ad80062df1f45c432103a53 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 15:19:24 +0300 Subject: [PATCH 10/22] Move vim integration tests to test_vim --- tests/run_vim_tests.sh | 23 +++++++++++-------- .../pyfiles}/setup_statusline_catcher.py | 0 .../tests/commandt_plugin.vim} | 4 ++-- .../tests/empty_encoding.old.vim} | 2 +- .../tests/foreign_stl_override.vim} | 2 +- .../tests/invalid_unicode.vim} | 2 +- .../tests/local_overrides.vim} | 2 +- .../tests/nerdtree_plugin.vim} | 2 +- .../tests/plugin_file.vim} | 2 +- .../tests/tabline.vim} | 2 +- tests/{ => test_vim}/vim_utils.vim | 9 ++++---- 11 files changed, 28 insertions(+), 22 deletions(-) rename tests/{ => test_vim/pyfiles}/setup_statusline_catcher.py (100%) rename tests/{test_commandt_plugin.vim => test_vim/tests/commandt_plugin.vim} (91%) mode change 100644 => 100755 rename tests/{test_empty_encoding.old.vim => test_vim/tests/empty_encoding.old.vim} (88%) mode change 100644 => 100755 rename tests/{test_foreign_stl_override.vim => test_vim/tests/foreign_stl_override.vim} (83%) rename tests/{test_invalid_unicode.vim => test_vim/tests/invalid_unicode.vim} (81%) rename tests/{test_local_overrides.vim => test_vim/tests/local_overrides.vim} (94%) mode change 100644 => 100755 rename tests/{test_nerdtree_plugin.vim => test_vim/tests/nerdtree_plugin.vim} (83%) mode change 100644 => 100755 rename tests/{test_plugin_file.vim => test_vim/tests/plugin_file.vim} (79%) mode change 100644 => 100755 rename tests/{test_tabline.vim => test_vim/tests/tabline.vim} (96%) mode change 100644 => 100755 rename tests/{ => test_vim}/vim_utils.vim (89%) diff --git a/tests/run_vim_tests.sh b/tests/run_vim_tests.sh index 798d5536..80e5400b 100755 --- a/tests/run_vim_tests.sh +++ b/tests/run_vim_tests.sh @@ -12,28 +12,33 @@ 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##*/}" + 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" - cat message.fail >&2 - rm message.fail + if test -e message.fail ; then + cat message.fail >&2 + rm message.fail + fi fi } -for script in tests/test_*.vim ; do +TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests" + +for script in "$TEST_SCRIPT_ROOT"/*.vim ; do if test "${script%.old.vim}" = "${script}" ; then - test_script "$NEW_VIM" "$script" new + test_script "$NEW_VIM" "$script" fi done if test -e "$OLD_VIM" ; then - for script in tests/test_*.old.vim ; do - test_script "$OLD_VIM" "$script" old + for script in "$TEST_SCRIPT_ROOT"/*.old.vim ; do + test_script "$OLD_VIM" "$script" done fi 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_commandt_plugin.vim b/tests/test_vim/tests/commandt_plugin.vim old mode 100644 new mode 100755 similarity index 91% rename from tests/test_commandt_plugin.vim rename to tests/test_vim/tests/commandt_plugin.vim index 355fff7c..9f944b94 --- 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 old mode 100644 new mode 100755 similarity index 88% rename from tests/test_empty_encoding.old.vim rename to tests/test_vim/tests/empty_encoding.old.vim index e24cd447..136d5100 --- a/tests/test_empty_encoding.old.vim +++ b/tests/test_vim/tests/empty_encoding.old.vim @@ -11,7 +11,7 @@ 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 diff --git a/tests/test_foreign_stl_override.vim b/tests/test_vim/tests/foreign_stl_override.vim similarity index 83% rename from tests/test_foreign_stl_override.vim rename to tests/test_vim/tests/foreign_stl_override.vim index 0cafb558..4f92d78d 100644 --- a/tests/test_foreign_stl_override.vim +++ b/tests/test_vim/tests/foreign_stl_override.vim @@ -1,6 +1,6 @@ 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 diff --git a/tests/test_invalid_unicode.vim b/tests/test_vim/tests/invalid_unicode.vim similarity index 81% rename from tests/test_invalid_unicode.vim rename to tests/test_vim/tests/invalid_unicode.vim index d09e2bb2..1718ba57 100644 --- a/tests/test_invalid_unicode.vim +++ b/tests/test_vim/tests/invalid_unicode.vim @@ -1,5 +1,5 @@ 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"` diff --git a/tests/test_local_overrides.vim b/tests/test_vim/tests/local_overrides.vim old mode 100644 new mode 100755 similarity index 94% rename from tests/test_local_overrides.vim rename to tests/test_vim/tests/local_overrides.vim index 353c086d..aba14e2d --- 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 old mode 100644 new mode 100755 similarity index 83% rename from tests/test_nerdtree_plugin.vim rename to tests/test_vim/tests/nerdtree_plugin.vim index 56b85b77..761cb5ff --- 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 old mode 100644 new mode 100755 similarity index 79% rename from tests/test_plugin_file.vim rename to tests/test_vim/tests/plugin_file.vim index e139c44f..0279683f --- a/tests/test_plugin_file.vim +++ b/tests/test_vim/tests/plugin_file.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'] tabedit abc tabedit def try diff --git a/tests/test_tabline.vim b/tests/test_vim/tests/tabline.vim old mode 100644 new mode 100755 similarity index 96% rename from tests/test_tabline.vim rename to tests/test_vim/tests/tabline.vim index a2e1374f..c9f48c12 --- a/tests/test_tabline.vim +++ b/tests/test_vim/tests/tabline.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'] source powerline/bindings/vim/plugin/powerline.vim edit abc tabedit def diff --git a/tests/vim_utils.vim b/tests/test_vim/vim_utils.vim similarity index 89% rename from tests/vim_utils.vim rename to tests/test_vim/vim_utils.vim index 5922d454..86ee7a30 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:pyfiles_root=expand(':p:h').'/pyfiles' +let g:root=expand(':p:h:h:h') let g:mf=g:root.'/message.fail' -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 From 53a7d1046efebbd4dde4e483dd259530a65047e6 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 15:30:15 +0300 Subject: [PATCH 11/22] Move messages.fail to a temporary directory --- tests/common.sh | 37 ++++++++++++++++--- tests/run_vim_tests.sh | 8 +++- tests/test_vim/tests/empty_encoding.old.vim | 2 +- tests/test_vim/tests/foreign_stl_override.vim | 2 +- tests/test_vim/tests/invalid_unicode.vim | 2 +- tests/test_vim/tests/plugin_file.vim | 2 +- tests/test_vim/tests/tabline.vim | 2 +- tests/test_vim/vim_utils.vim | 2 +- 8 files changed, 44 insertions(+), 13 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index 1b323b7b..7cba9b57 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -7,14 +7,18 @@ 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" + local suite_name="$1" ; shift export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE}/$suite_name" } exit_suite() { + rm_tmp_dir if test $FAILED -ne 0 ; then echo "Suite ${POWERLINE_CURRENT_SUITE} failed, summary:" echo "${FAIL_SUMMARY}" @@ -31,14 +35,37 @@ fail() { shift allow_failure=A fi - local test_name="$1" - local fail_char="$allow_failure$2" - local message="$3" + 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" >> "$ROOT/tests/failures" + echo "$full_msg" >> "$FAILURES_FILE" if test "x$allow_failure" = "x" ; then FAILED=1 fi } + +make_tmp_dir() { + local suffix="$1" ; shift + + local tmpdir="$TMP_ROOT/$suffix/" + + if test -d "$tmpdir" ; then + rm -r "$tmpdir" + fi + + mkdir -p "$tmpdir" + + printf '%s' "$tmpdir" +} + +rm_tmp_dir() { + if test -e "$FAILURES_FILE" ; then + return 0 + fi + if test -d "$TMP_ROOT" ; then + rm -r "$TMP_ROOT" + fi +} diff --git a/tests/run_vim_tests.sh b/tests/run_vim_tests.sh index 80e5400b..5f9d29a3 100755 --- a/tests/run_vim_tests.sh +++ b/tests/run_vim_tests.sh @@ -10,8 +10,8 @@ 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 vim="$1" ; shift + local script="$1" ; shift echo "Running script $script with $vim" if ! test -e "$vim" ; then return 0 @@ -28,8 +28,12 @@ test_script() { fi } +TMPDIR="$(make_tmp_dir vim)" + TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests" +cd "$TMPDIR" + for script in "$TEST_SCRIPT_ROOT"/*.vim ; do if test "${script%.old.vim}" = "${script}" ; then test_script "$NEW_VIM" "$script" diff --git a/tests/test_vim/tests/empty_encoding.old.vim b/tests/test_vim/tests/empty_encoding.old.vim index 136d5100..124a10a3 100755 --- a/tests/test_vim/tests/empty_encoding.old.vim +++ b/tests/test_vim/tests/empty_encoding.old.vim @@ -14,7 +14,7 @@ endif 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_vim/tests/foreign_stl_override.vim b/tests/test_vim/tests/foreign_stl_override.vim index 4f92d78d..2a5b8c01 100644 --- a/tests/test_vim/tests/foreign_stl_override.vim +++ b/tests/test_vim/tests/foreign_stl_override.vim @@ -4,7 +4,7 @@ let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config 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_vim/tests/invalid_unicode.vim b/tests/test_vim/tests/invalid_unicode.vim index 1718ba57..ac91f3c5 100644 --- a/tests/test_vim/tests/invalid_unicode.vim +++ b/tests/test_vim/tests/invalid_unicode.vim @@ -5,7 +5,7 @@ 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_vim/tests/plugin_file.vim b/tests/test_vim/tests/plugin_file.vim index 0279683f..18489332 100755 --- a/tests/test_vim/tests/plugin_file.vim +++ b/tests/test_vim/tests/plugin_file.vim @@ -4,7 +4,7 @@ let g:powerline_config_paths = [expand(':p:h:h:h:h') . '/powerline/config 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_vim/tests/tabline.vim b/tests/test_vim/tests/tabline.vim index c9f48c12..ff76dc02 100755 --- a/tests/test_vim/tests/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:h:h') . '/powerline/config_files'] -source powerline/bindings/vim/plugin/powerline.vim +source :p:h:h:h:h/powerline/bindings/vim/plugin/powerline.vim edit abc tabedit def tabedit ghi diff --git a/tests/test_vim/vim_utils.vim b/tests/test_vim/vim_utils.vim index 86ee7a30..6219ec48 100644 --- a/tests/test_vim/vim_utils.vim +++ b/tests/test_vim/vim_utils.vim @@ -2,7 +2,7 @@ let g:powerline_use_var_handler = 1 let g:pyfiles_root=expand(':p:h').'/pyfiles' let g:root=expand(':p:h:h:h') -let g:mf=g:root.'/message.fail' +let g:mf=fnamemodify('message.fail', ':p') command -nargs=1 LST :call writefile(, g:mf, 'a') | cquit command -nargs=1 ERR :LST [] From f3bf749467295864c707507a10f32472eb39296f Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 15:39:05 +0300 Subject: [PATCH 12/22] Move tests run by run_python_tests to tests/test_python --- tests/run_python_tests.sh | 2 +- tests/{ => test_python}/empty | 0 tests/{ => test_python}/test_cmdline.py | 0 tests/{ => test_python}/test_config_merging.py | 0 tests/{ => test_python}/test_config_reload.py | 0 tests/{ => test_python}/test_configuration.py | 2 +- tests/{ => test_python}/test_lib.py | 2 +- tests/{ => test_python}/test_lib_config.py | 2 +- tests/{ => test_python}/test_listers.py | 0 tests/{ => test_python}/test_logging.py | 2 +- tests/{ => test_python}/test_provided_config_files.py | 6 +++--- tests/{ => test_python}/test_segments.py | 10 +++++++--- tests/{ => test_python}/test_selectors.py | 2 +- tests/{ => test_python}/test_watcher.py | 2 +- 14 files changed, 17 insertions(+), 13 deletions(-) rename tests/{ => test_python}/empty (100%) rename tests/{ => test_python}/test_cmdline.py (100%) rename tests/{ => test_python}/test_config_merging.py (100%) rename tests/{ => test_python}/test_config_reload.py (100%) rename tests/{ => test_python}/test_configuration.py (99%) rename tests/{ => test_python}/test_lib.py (99%) rename tests/{ => test_python}/test_lib_config.py (93%) rename tests/{ => test_python}/test_listers.py (100%) rename tests/{ => test_python}/test_logging.py (99%) rename tests/{ => test_python}/test_provided_config_files.py (96%) rename tests/{ => test_python}/test_segments.py (99%) rename tests/{ => test_python}/test_selectors.py (94%) rename tests/{ => test_python}/test_watcher.py (99%) diff --git a/tests/run_python_tests.sh b/tests/run_python_tests.sh index f5524142..a0ac8620 100755 --- a/tests/run_python_tests.sh +++ b/tests/run_python_tests.sh @@ -3,7 +3,7 @@ enter_suite python -for file in tests/test_*.py ; do +for file in tests/test_python/test_*.py ; do test_name="${file##*/test_}" if ! ${PYTHON} $file --verbose --catch ; then fail "${test_name%.py}" F "Failed test(s) from $file" 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/test_cmdline.py b/tests/test_python/test_cmdline.py similarity index 100% rename from tests/test_cmdline.py rename to tests/test_python/test_cmdline.py diff --git a/tests/test_config_merging.py b/tests/test_python/test_config_merging.py similarity index 100% rename from tests/test_config_merging.py rename to tests/test_python/test_config_merging.py diff --git a/tests/test_config_reload.py b/tests/test_python/test_config_reload.py similarity index 100% rename from tests/test_config_reload.py rename to tests/test_python/test_config_reload.py diff --git a/tests/test_configuration.py b/tests/test_python/test_configuration.py similarity index 99% rename from tests/test_configuration.py rename to tests/test_python/test_configuration.py index 5728e672..aa9e8448 100644 --- a/tests/test_configuration.py +++ b/tests/test_python/test_configuration.py @@ -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__), 'vim_sys_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): 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 c6338b88..6260659c 100644 --- a/tests/test_lib.py +++ b/tests/test_python/test_lib.py @@ -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) diff --git a/tests/test_lib_config.py b/tests/test_python/test_lib_config.py similarity index 93% rename from tests/test_lib_config.py rename to tests/test_python/test_lib_config.py index ddbf4a0a..053462a2 100644 --- a/tests/test_lib_config.py +++ b/tests/test_python/test_lib_config.py @@ -9,7 +9,7 @@ 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): diff --git a/tests/test_listers.py b/tests/test_python/test_listers.py similarity index 100% rename from tests/test_listers.py rename to tests/test_python/test_listers.py diff --git a/tests/test_logging.py b/tests/test_python/test_logging.py similarity index 99% rename from tests/test_logging.py rename to tests/test_python/test_logging.py index cc5523cb..d7cfe4ad 100644 --- a/tests/test_logging.py +++ b/tests/test_python/test_logging.py @@ -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(): diff --git a/tests/test_provided_config_files.py b/tests/test_python/test_provided_config_files.py similarity index 96% rename from tests/test_provided_config_files.py rename to tests/test_python/test_provided_config_files.py index ca190bd8..9478568d 100644 --- a/tests/test_provided_config_files.py +++ b/tests/test_python/test_provided_config_files.py @@ -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__), 'vim_sys_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() 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 23992329..4aef6a19 100644 --- a/tests/test_segments.py +++ b/tests/test_python/test_segments.py @@ -1291,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): @@ -1599,7 +1603,7 @@ class TestVim(TestCase): @classmethod def setUpClass(cls): - sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'vim_sys_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 @@ -1664,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(): diff --git a/tests/test_selectors.py b/tests/test_python/test_selectors.py similarity index 94% rename from tests/test_selectors.py rename to tests/test_python/test_selectors.py index ce0e383b..74ace8d7 100644 --- a/tests/test_selectors.py +++ b/tests/test_python/test_selectors.py @@ -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__), 'vim_sys_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 diff --git a/tests/test_watcher.py b/tests/test_python/test_watcher.py similarity index 99% rename from tests/test_watcher.py rename to tests/test_python/test_watcher.py index 4cca6a29..a246d0be 100644 --- a/tests/test_watcher.py +++ b/tests/test_python/test_watcher.py @@ -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) From 0fc96abce20de8536eb1267b2024fb37b713d1ad Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 15:49:46 +0300 Subject: [PATCH 13/22] =?UTF-8?q?Move=20=E2=80=9Clibrary=E2=80=9D=20tests/?= =?UTF-8?q?*.sh=20to=20tests/shlib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/run_awesome_tests.sh | 2 +- tests/run_bar_tests.sh | 2 +- tests/run_daemon_tests.sh | 2 +- tests/run_lint_tests.sh | 2 +- tests/run_python_tests.sh | 2 +- tests/run_vim_tests.sh | 4 ++-- tests/run_vterm_tests.sh | 2 +- tests/{ => shlib}/common.sh | 0 tests/{ => shlib}/vim.sh | 0 tests/{ => shlib}/vterm.sh | 2 +- tests/test.sh | 2 +- tests/test_in_vterm/test_tmux.sh | 4 ++-- tests/test_in_vterm/test_vim.sh | 6 +++--- tests/test_shells/test.sh | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) rename tests/{ => shlib}/common.sh (100%) rename tests/{ => shlib}/vim.sh (100%) rename tests/{ => shlib}/vterm.sh (94%) diff --git a/tests/run_awesome_tests.sh b/tests/run_awesome_tests.sh index b3dac2cd..e6dd29e0 100755 --- a/tests/run_awesome_tests.sh +++ b/tests/run_awesome_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite awesome diff --git a/tests/run_bar_tests.sh b/tests/run_bar_tests.sh index 7d658ff1..cad433b9 100755 --- a/tests/run_bar_tests.sh +++ b/tests/run_bar_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite bar diff --git a/tests/run_daemon_tests.sh b/tests/run_daemon_tests.sh index af68eacf..45aaff9f 100755 --- a/tests/run_daemon_tests.sh +++ b/tests/run_daemon_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite daemon diff --git a/tests/run_lint_tests.sh b/tests/run_lint_tests.sh index 585e7a03..3a02612f 100755 --- a/tests/run_lint_tests.sh +++ b/tests/run_lint_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite lint diff --git a/tests/run_python_tests.sh b/tests/run_python_tests.sh index a0ac8620..8f53b433 100755 --- a/tests/run_python_tests.sh +++ b/tests/run_python_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite python diff --git a/tests/run_vim_tests.sh b/tests/run_vim_tests.sh index 5f9d29a3..36540454 100755 --- a/tests/run_vim_tests.sh +++ b/tests/run_vim_tests.sh @@ -1,6 +1,6 @@ #!/bin/sh -. tests/common.sh -. tests/vim.sh +. tests/shlib/common.sh +. tests/shlib/vim.sh enter_suite vim diff --git a/tests/run_vterm_tests.sh b/tests/run_vterm_tests.sh index c918ba32..40aaebe8 100755 --- a/tests/run_vterm_tests.sh +++ b/tests/run_vterm_tests.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite vterm diff --git a/tests/common.sh b/tests/shlib/common.sh similarity index 100% rename from tests/common.sh rename to tests/shlib/common.sh diff --git a/tests/vim.sh b/tests/shlib/vim.sh similarity index 100% rename from tests/vim.sh rename to tests/shlib/vim.sh diff --git a/tests/vterm.sh b/tests/shlib/vterm.sh similarity index 94% rename from tests/vterm.sh rename to tests/shlib/vterm.sh index 8105ed29..5017827f 100644 --- a/tests/vterm.sh +++ b/tests/shlib/vterm.sh @@ -1,4 +1,4 @@ -. tests/common.sh +. tests/shlib/common.sh . tests/bot-ci/scripts/common/main.sh set +x diff --git a/tests/test.sh b/tests/test.sh index 68bd9310..5a383f9d 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,5 +1,5 @@ #!/bin/bash -. tests/common.sh +. tests/shlib/common.sh enter_suite root diff --git a/tests/test_in_vterm/test_tmux.sh b/tests/test_in_vterm/test_tmux.sh index 66418e02..b2a2ab4b 100755 --- a/tests/test_in_vterm/test_tmux.sh +++ b/tests/test_in_vterm/test_tmux.sh @@ -1,6 +1,6 @@ #!/bin/sh -. tests/common.sh -. tests/vterm.sh +. tests/shlib/common.sh +. tests/shlib/vterm.sh enter_suite tmux diff --git a/tests/test_in_vterm/test_vim.sh b/tests/test_in_vterm/test_vim.sh index 187a9d6c..18e65265 100755 --- a/tests/test_in_vterm/test_vim.sh +++ b/tests/test_in_vterm/test_vim.sh @@ -1,7 +1,7 @@ #!/bin/sh -. tests/common.sh -. tests/vterm.sh -. tests/vim.sh +. tests/shlib/common.sh +. tests/shlib/vterm.sh +. tests/shlib/vim.sh enter_suite vim diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 0cc79716..ec240a0e 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -1,5 +1,5 @@ #!/bin/sh -. tests/common.sh +. tests/shlib/common.sh enter_suite shells From 1303cd1b04984ae1fa1df80557f526dd6c49ef19 Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 22:36:00 +0300 Subject: [PATCH 14/22] Move tests/run_*_tests.sh to tests/test_*/test.sh Warning: this also makes shell tests run. --- tests/run_daemon_tests.sh | 40 ------------------ tests/run_shell_tests.sh | 8 ---- tests/shlib/common.sh | 10 +++++ tests/test.sh | 13 +----- .../test.sh} | 8 +--- tests/{run_bar_tests.sh => test_bar/test.sh} | 8 +--- tests/test_daemon/test.sh | 41 +++++++++++++++++++ .../test.sh} | 4 +- .../{run_lint_tests.sh => test_lint/test.sh} | 2 +- .../test.sh} | 4 +- tests/test_shells/test.sh | 7 +--- tests/{run_vim_tests.sh => test_vim/test.sh} | 0 12 files changed, 60 insertions(+), 85 deletions(-) delete mode 100755 tests/run_daemon_tests.sh delete mode 100755 tests/run_shell_tests.sh rename tests/{run_awesome_tests.sh => test_awesome/test.sh} (97%) rename tests/{run_bar_tests.sh => test_bar/test.sh} (97%) create mode 100755 tests/test_daemon/test.sh rename tests/{run_vterm_tests.sh => test_in_vterm/test.sh} (68%) rename tests/{run_lint_tests.sh => test_lint/test.sh} (56%) rename tests/{run_python_tests.sh => test_python/test.sh} (61%) rename tests/{run_vim_tests.sh => test_vim/test.sh} (100%) diff --git a/tests/run_daemon_tests.sh b/tests/run_daemon_tests.sh deleted file mode 100755 index 45aaff9f..00000000 --- a/tests/run_daemon_tests.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -. tests/shlib/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_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/shlib/common.sh b/tests/shlib/common.sh index 7cba9b57..6fae3603 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -2,6 +2,10 @@ set +x : ${PYTHON:=python} +: ${USER:=`id -un`} +: ${HOME:=`getent passwd $USER | cut -d: -f6`} + +export USER HOME if test -z "$FAILED" ; then FAILED=0 @@ -69,3 +73,9 @@ rm_tmp_dir() { rm -r "$TMP_ROOT" fi } + +if ! which realpath ; then + realpath() { + $PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1" + } +fi diff --git a/tests/test.sh b/tests/test.sh index 5a383f9d..5d86cbca 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -3,11 +3,6 @@ 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" @@ -25,15 +20,9 @@ if test "$TRAVIS" = true ; then 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 97% rename from tests/run_awesome_tests.sh rename to tests/test_awesome/test.sh index e6dd29e0..8c883645 100755 --- a/tests/run_awesome_tests.sh +++ b/tests/test_awesome/test.sh @@ -3,12 +3,10 @@ enter_suite awesome -TEST_ROOT="$ROOT/tests/awesome" +TEST_ROOT="$(make_tmp_dir awesome)" 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" @@ -186,8 +184,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 97% rename from tests/run_bar_tests.sh rename to tests/test_bar/test.sh index cad433b9..ef7b546f 100755 --- a/tests/run_bar_tests.sh +++ b/tests/test_bar/test.sh @@ -3,12 +3,10 @@ enter_suite bar -TEST_ROOT="$ROOT/tests/bar" +TEST_ROOT="$(make_tmp_dir bar)" 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" @@ -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 68% rename from tests/run_vterm_tests.sh rename to tests/test_in_vterm/test.sh index 40aaebe8..bbd49582 100755 --- a/tests/run_vterm_tests.sh +++ b/tests/test_in_vterm/test.sh @@ -3,9 +3,9 @@ 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/run_lint_tests.sh b/tests/test_lint/test.sh similarity index 56% rename from tests/run_lint_tests.sh rename to tests/test_lint/test.sh index 3a02612f..f73ea981 100755 --- a/tests/run_lint_tests.sh +++ b/tests/test_lint/test.sh @@ -3,7 +3,7 @@ enter_suite lint -if ! ${PYTHON} scripts/powerline-lint -p powerline/config_files ; then +if ! "$PYTHON" "$ROOT/scripts/powerline-lint" -p "$ROOT/powerline/config_files" ; then fail "test" F "Running powerline-lint failed" fi diff --git a/tests/run_python_tests.sh b/tests/test_python/test.sh similarity index 61% rename from tests/run_python_tests.sh rename to tests/test_python/test.sh index 8f53b433..667d642d 100755 --- a/tests/run_python_tests.sh +++ b/tests/test_python/test.sh @@ -3,9 +3,9 @@ enter_suite python -for file in tests/test_python/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_shells/test.sh b/tests/test_shells/test.sh index ec240a0e..590284b8 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -3,18 +3,13 @@ enter_suite shells -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 diff --git a/tests/run_vim_tests.sh b/tests/test_vim/test.sh similarity index 100% rename from tests/run_vim_tests.sh rename to tests/test_vim/test.sh From 717ae5e428aa8269109f21e0e75d51d1624a71ce Mon Sep 17 00:00:00 2001 From: Foo Date: Sun, 30 Apr 2017 22:55:20 +0300 Subject: [PATCH 15/22] Refactor make_tmp_dir to make_test_root This fixes problem with `exit_suite --continue` wiping out tmp directory. --- tests/shlib/common.sh | 19 ++++++++++++------- tests/test_awesome/test.sh | 3 ++- tests/test_bar/test.sh | 2 +- tests/test_vim/test.sh | 6 +++--- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/shlib/common.sh b/tests/shlib/common.sh index 6fae3603..ea208ff8 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -22,7 +22,9 @@ enter_suite() { } exit_suite() { - rm_tmp_dir + 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}" @@ -51,10 +53,11 @@ fail() { fi } -make_tmp_dir() { - local suffix="$1" ; shift +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" @@ -62,15 +65,17 @@ make_tmp_dir() { mkdir -p "$tmpdir" - printf '%s' "$tmpdir" + export TEST_ROOT="$tmpdir" } -rm_tmp_dir() { +rm_test_root() { if test -e "$FAILURES_FILE" ; then return 0 fi - if test -d "$TMP_ROOT" ; then - rm -r "$TMP_ROOT" + local suffix="${POWERLINE_CURRENT_SUITE##*/}" + if test -d "$TMP_ROOT/$suffix" ; then + rm -r "$TMP_ROOT/$suffix" + rmdir "$TMP_ROOT" &>/dev/null || true fi } diff --git a/tests/test_awesome/test.sh b/tests/test_awesome/test.sh index 8c883645..eb08f453 100755 --- a/tests/test_awesome/test.sh +++ b/tests/test_awesome/test.sh @@ -3,7 +3,8 @@ enter_suite awesome -TEST_ROOT="$(make_tmp_dir awesome)" +make_test_root + TEST_PATH="$TEST_ROOT/path" TEST_STATIC_ROOT="$ROOT/tests/test_awesome" diff --git a/tests/test_bar/test.sh b/tests/test_bar/test.sh index ef7b546f..88fe57c5 100755 --- a/tests/test_bar/test.sh +++ b/tests/test_bar/test.sh @@ -3,7 +3,7 @@ enter_suite bar -TEST_ROOT="$(make_tmp_dir bar)" +make_test_root TEST_PATH="$TEST_ROOT/path" TEST_STATIC_ROOT="$ROOT/tests/test_bar" diff --git a/tests/test_vim/test.sh b/tests/test_vim/test.sh index 36540454..a522946e 100755 --- a/tests/test_vim/test.sh +++ b/tests/test_vim/test.sh @@ -4,6 +4,8 @@ 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' @@ -28,11 +30,9 @@ test_script() { fi } -TMPDIR="$(make_tmp_dir vim)" - TEST_SCRIPT_ROOT="$ROOT/tests/test_vim/tests" -cd "$TMPDIR" +cd "$TEST_ROOT" for script in "$TEST_SCRIPT_ROOT"/*.vim ; do if test "${script%.old.vim}" = "${script}" ; then From 5a3e19847e458843c54d2073961954cb04c6768a Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 00:00:45 +0300 Subject: [PATCH 16/22] Refactor shells test code Tests passing locally: bash (no)daemon C busybox (no)daemon C fish (no)daemon C mksh (no)daemon C rc (no)daemon C tcsh (no)daemon C zsh (no)daemon C zsh zpython ipython pdf module pdf subclass dash has problems with job control (bgscript.sh not finished by kill) --- tests/test_shells/bash.daemon.ok | 26 +-- tests/test_shells/bash.nodaemon.ok | 20 +-- tests/test_shells/busybox.daemon.ok | 26 +-- tests/test_shells/busybox.nodaemon.ok | 20 +-- tests/test_shells/dash.daemon.ok | 24 +-- tests/test_shells/dash.nodaemon.ok | 18 +- tests/test_shells/fish.ok | 14 +- tests/test_shells/input.bash | 2 +- tests/test_shells/input.busybox | 2 +- tests/test_shells/input.dash | 2 +- tests/test_shells/input.fish | 2 +- tests/test_shells/input.ipython | 2 +- tests/test_shells/input.mksh | 2 +- tests/test_shells/input.rc | 3 +- tests/test_shells/input.tcsh | 2 +- tests/test_shells/input.zsh | 2 +- tests/test_shells/mksh.daemon.ok | 28 +-- tests/test_shells/mksh.nodaemon.ok | 22 +-- tests/test_shells/postproc.py | 9 +- tests/test_shells/rc.daemon.ok | 14 +- tests/test_shells/rc.nodaemon.ok | 14 +- tests/test_shells/run_script.py | 15 +- tests/test_shells/tcsh.ok | 14 +- tests/test_shells/test.sh | 238 ++++++++++++++------------ tests/test_shells/zsh.daemon.ok | 60 +++---- tests/test_shells/zsh.nodaemon.ok | 50 +++--- tests/test_shells/zsh.zpython.ok | 81 +++++---- tests/test_shells/zsh_test_script.zsh | 4 +- 28 files changed, 378 insertions(+), 338 deletions(-) diff --git a/tests/test_shells/bash.daemon.ok b/tests/test_shells/bash.daemon.ok index 50d7d212..a0aba45b 100644 --- a/tests/test_shells/bash.daemon.ok +++ b/tests/test_shells/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/bash.nodaemon.ok index 9571a21c..118dfe50 100644 --- a/tests/test_shells/bash.nodaemon.ok +++ b/tests/test_shells/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/busybox.daemon.ok index a8c3faa5..446d88e8 100644 --- a/tests/test_shells/busybox.daemon.ok +++ b/tests/test_shells/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/busybox.nodaemon.ok index 00b8b7cc..afda9a58 100644 --- a/tests/test_shells/busybox.nodaemon.ok +++ b/tests/test_shells/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/dash.daemon.ok index bfe8fab0..71ca5003 100644 --- a/tests/test_shells/dash.daemon.ok +++ b/tests/test_shells/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/dash.nodaemon.ok index c4f8e567..c289cd2e 100644 --- a/tests/test_shells/dash.nodaemon.ok +++ b/tests/test_shells/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/fish.ok index 973cf05a..4d208bb1 100644 --- a/tests/test_shells/fish.ok +++ b/tests/test_shells/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/input.bash b/tests/test_shells/input.bash index bbd8d0bb..beffd308 100644 --- a/tests/test_shells/input.bash +++ b/tests/test_shells/input.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/input.busybox index 16824d7b..5d1495a0 100644 --- a/tests/test_shells/input.busybox +++ b/tests/test_shells/input.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/input.dash index 16824d7b..5d1495a0 100644 --- a/tests/test_shells/input.dash +++ b/tests/test_shells/input.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/input.fish index 4be37c31..9a20613a 100644 --- a/tests/test_shells/input.fish +++ b/tests/test_shells/input.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/input.ipython b/tests/test_shells/input.ipython index 23b80198..257cba6f 100644 --- a/tests/test_shells/input.ipython +++ b/tests/test_shells/input.ipython @@ -1,4 +1,4 @@ -print ('cd ' + 'tests/shell/3rd') # Start of the test marker +print ('cd ' + '"$TEST_ROOT"/3rd') # Start of the test marker bool 42 bool 44 class Test(object): diff --git a/tests/test_shells/input.mksh b/tests/test_shells/input.mksh index 1656800e..ca457835 100644 --- a/tests/test_shells/input.mksh +++ b/tests/test_shells/input.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.rc b/tests/test_shells/input.rc index 1ae37ff0..c88bcf93 100644 --- a/tests/test_shells/input.rc +++ b/tests/test_shells/input.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/input.tcsh index 509c7ae6..c7d722a6 100644 --- a/tests/test_shells/input.tcsh +++ b/tests/test_shells/input.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/input.zsh index ce29ddce..811684e0 100644 --- a/tests/test_shells/input.zsh +++ b/tests/test_shells/input.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/mksh.daemon.ok b/tests/test_shells/mksh.daemon.ok index 2a367dcf..264dff87 100644 --- a/tests/test_shells/mksh.daemon.ok +++ b/tests/test_shells/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/mksh.nodaemon.ok index 09190f8d..d8d9d705 100644 --- a/tests/test_shells/mksh.nodaemon.ok +++ b/tests/test_shells/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/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/rc.daemon.ok b/tests/test_shells/rc.daemon.ok index 9bbee845..c49b9a32 100644 --- a/tests/test_shells/rc.daemon.ok +++ b/tests/test_shells/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/rc.nodaemon.ok index d45c7bd3..28376cb5 100644 --- a/tests/test_shells/rc.nodaemon.ok +++ b/tests/test_shells/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/run_script.py b/tests/test_shells/run_script.py index 3d5eddd5..90b20f5b 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'] @@ -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/tcsh.ok b/tests/test_shells/tcsh.ok index 3b25f86f..07089bff 100644 --- a/tests/test_shells/tcsh.ok +++ b/tests/test_shells/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/test.sh b/tests/test_shells/test.sh index 590284b8..42bf9d41 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -1,7 +1,7 @@ #!/bin/sh . tests/shlib/common.sh -enter_suite shells +enter_suite shell if test $# -eq 0 ; then FAST=1 @@ -28,14 +28,14 @@ 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/${SH}.${TEST_TYPE}.ok" ; then + diff -a -u "$ROOT/tests/test_shells/${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/${SH}.ok" ; then + diff -a -u "$ROOT/tests/test_shells/${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 } @@ -50,13 +50,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 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 @@ -104,9 +104,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) # ? @@ -115,7 +115,7 @@ do_run_test() { busybox --help ;; *) - ${SH} --version + "$TEST_ROOT/path/${SH}" --version ;; esac if which dpkg >/dev/null ; then @@ -135,82 +135,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 @@ -224,7 +224,7 @@ 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 @@ -256,12 +256,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 @@ -272,7 +272,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" ;; @@ -286,14 +289,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 @@ -305,8 +314,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" @@ -328,17 +337,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" @@ -356,19 +372,19 @@ 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 "$ONLY_SHELL" != "" && test "x$ONLY_SHELL" != "x$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 @@ -376,70 +392,82 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te 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 $ALLOW_FAILURE_ARG "$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' @@ -454,8 +482,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.daemon.ok b/tests/test_shells/zsh.daemon.ok index bea39b96..32e80d8d 100644 --- a/tests/test_shells/zsh.daemon.ok +++ b/tests/test_shells/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/zsh.nodaemon.ok index d6f4d518..3aa285f8 100644 --- a/tests/test_shells/zsh.nodaemon.ok +++ b/tests/test_shells/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/zsh.zpython.ok b/tests/test_shells/zsh.zpython.ok index b19cf390..32e80d8d 100644 --- a/tests/test_shells/zsh.zpython.ok +++ b/tests/test_shells/zsh.zpython.ok @@ -1,41 +1,52 @@ -  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 +  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  …  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  …  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 +  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  …  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  hash -d foo=$PWD:h ; cd . - INSERT  ~foo  3rd  set_theme_option default.dividers.left.hard \$ABC - INSERT $ABC~foo  3rd $ABCtrue + 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/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())' From 225ed1f2300b619aa4485cf46ccbaada991ee065 Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 00:41:14 +0300 Subject: [PATCH 17/22] Do not add fish and dash to $TEST_ROOT/path --- tests/test_shells/test.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 42bf9d41..c267b452 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -227,7 +227,17 @@ if which "$POWERLINE_RC_EXE" >/dev/null ; then 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 -z "$TRAVIS_JOB_NUMBER" ; 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)" From 2fcbd89ef801d2a0ba4ee1328e75914896cc2004 Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 01:16:40 +0300 Subject: [PATCH 18/22] Trace checkout_cached_dir, use rev-parse in place of some hack --- tests/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 } From 4c5b02d236007b04039c32b91fa8b6efee480566 Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 01:28:44 +0300 Subject: [PATCH 19/22] =?UTF-8?q?Remove=20=E2=80=9Ctest=20x=E2=80=9D=20non?= =?UTF-8?q?sense?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/usage/shell-prompts.rst | 2 +- powerline/bindings/bash/powerline.sh | 10 ++++----- powerline/bindings/fish/powerline-setup.fish | 2 +- powerline/bindings/rc/powerline.rc | 10 ++++----- powerline/bindings/shell/powerline.sh | 2 +- tests/shlib/common.sh | 6 +++--- tests/test_awesome/test.sh | 12 +++++------ tests/test_bar/test.sh | 12 +++++------ tests/test_shells/test.sh | 22 +++++++------------- 9 files changed, 36 insertions(+), 42 deletions(-) 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/tests/shlib/common.sh b/tests/shlib/common.sh index ea208ff8..a95d8044 100644 --- a/tests/shlib/common.sh +++ b/tests/shlib/common.sh @@ -30,14 +30,14 @@ exit_suite() { echo "${FAIL_SUMMARY}" fi export POWERLINE_CURRENT_SUITE="${POWERLINE_CURRENT_SUITE%/*}" - if test "x$1" != "x--continue" ; then + if test "$1" != "--continue" ; then exit $FAILED fi } fail() { local allow_failure= - if test "x$1" = "x--allow-failure" ; then + if test "$1" = "--allow-failure" ; then shift allow_failure=A fi @@ -48,7 +48,7 @@ fail() { FAIL_SUMMARY="${FAIL_SUMMARY}${NL}${full_msg}" echo "Failed: $full_msg" echo "$full_msg" >> "$FAILURES_FILE" - if test "x$allow_failure" = "x" ; then + if test -z "$allow_failure" ; then FAILED=1 fi } diff --git a/tests/test_awesome/test.sh b/tests/test_awesome/test.sh index eb08f453..93d50303 100755 --- a/tests/test_awesome/test.sh +++ b/tests/test_awesome/test.sh @@ -30,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 @@ -74,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" @@ -119,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 @@ -153,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 @@ -161,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 diff --git a/tests/test_bar/test.sh b/tests/test_bar/test.sh index 88fe57c5..d6522eed 100755 --- a/tests/test_bar/test.sh +++ b/tests/test_bar/test.sh @@ -49,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" @@ -66,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" @@ -149,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#=}" @@ -166,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" diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index c267b452..1dce46db 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -12,7 +12,7 @@ ONLY_TEST_CLIENT="$3" 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 | "")] @@ -53,7 +53,7 @@ print_full_output() { 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 "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log" @@ -71,9 +71,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 \ @@ -84,7 +84,7 @@ do_run_test() { ) \ ) \ || ( \ - test "x${SH}" = "xipython" \ + test "${SH}" = "ipython" \ && test "$("${PYTHON}" -mIPython --version | head -n1 | cut -d. -f1)" -ge 5 \ ) \ ) ; then @@ -95,7 +95,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 '============================================================' @@ -388,7 +388,7 @@ if ( \ fi fi SH="${TEST_COMMAND%% *}" - if test "$ONLY_SHELL" != "" && test "x$ONLY_SHELL" != "x$SH" ; then + if test -n "$ONLY_SHELL" && test "$ONLY_SHELL" != "$SH" ; then continue fi if ! test -x "$TEST_ROOT/path/$SH" ; then @@ -396,13 +396,7 @@ if ( \ fi 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 \ + fail "$SH-$TEST_TYPE-$TEST_CLIENT:test" F \ "Failed checking $TEST_COMMAND" fi done From 65c6ed1cff96596c4bd30d355d1b80d5a05cfe86 Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 01:45:07 +0300 Subject: [PATCH 20/22] Try setting LD_LIBRARY_PATH Currently zpython test does not work: libzpython could not load libpython. --- tests/test.sh | 4 ++++ tests/test_shells/test.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index 5d86cbca..1c6f9881 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -17,6 +17,10 @@ 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 diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 1dce46db..f3dac6f6 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -229,7 +229,7 @@ fi exes="bash zsh busybox tcsh mksh" -if test -z "$TRAVIS_JOB_NUMBER" ; then +if test "$TRAVIS" != "true" ; then # For some reason fish does not work on travis exes="$exes fish" fi From 2d877c9240a004344083044576dc8b36140ca2b2 Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 01:49:32 +0300 Subject: [PATCH 21/22] Move shell tests inputs and outputs to separate directories --- tests/test_shells/{input.bash => inputs/bash} | 0 tests/test_shells/{input.busybox => inputs/busybox} | 0 tests/test_shells/{input.dash => inputs/dash} | 0 tests/test_shells/{input.fish => inputs/fish} | 0 tests/test_shells/{input.ipython => inputs/ipython} | 0 tests/test_shells/{input.mksh => inputs/mksh} | 0 tests/test_shells/{input.pdb => inputs/pdb} | 0 tests/test_shells/{input.rc => inputs/rc} | 0 tests/test_shells/{input.tcsh => inputs/tcsh} | 0 tests/test_shells/{input.zsh => inputs/zsh} | 0 tests/test_shells/{ => outputs}/bash.daemon.ok | 0 tests/test_shells/{ => outputs}/bash.nodaemon.ok | 0 tests/test_shells/{ => outputs}/busybox.daemon.ok | 0 tests/test_shells/{ => outputs}/busybox.nodaemon.ok | 0 tests/test_shells/{ => outputs}/dash.daemon.ok | 0 tests/test_shells/{ => outputs}/dash.nodaemon.ok | 0 tests/test_shells/{ => outputs}/fish.ok | 0 tests/test_shells/{ => outputs}/ipython.ok | 0 tests/test_shells/{ => outputs}/mksh.daemon.ok | 0 tests/test_shells/{ => outputs}/mksh.nodaemon.ok | 0 tests/test_shells/{ => outputs}/pdb.module.ok | 0 tests/test_shells/{ => outputs}/pdb.subclass.ok | 0 tests/test_shells/{ => outputs}/rc.daemon.ok | 0 tests/test_shells/{ => outputs}/rc.nodaemon.ok | 0 tests/test_shells/{ => outputs}/tcsh.ok | 0 tests/test_shells/{ => outputs}/zsh.daemon.ok | 0 tests/test_shells/{ => outputs}/zsh.nodaemon.ok | 0 tests/test_shells/{ => outputs}/zsh.zpython.ok | 0 tests/test_shells/run_script.py | 2 +- tests/test_shells/test.sh | 10 ++++++---- 30 files changed, 7 insertions(+), 5 deletions(-) rename tests/test_shells/{input.bash => inputs/bash} (100%) rename tests/test_shells/{input.busybox => inputs/busybox} (100%) rename tests/test_shells/{input.dash => inputs/dash} (100%) rename tests/test_shells/{input.fish => inputs/fish} (100%) rename tests/test_shells/{input.ipython => inputs/ipython} (100%) rename tests/test_shells/{input.mksh => inputs/mksh} (100%) rename tests/test_shells/{input.pdb => inputs/pdb} (100%) rename tests/test_shells/{input.rc => inputs/rc} (100%) rename tests/test_shells/{input.tcsh => inputs/tcsh} (100%) rename tests/test_shells/{input.zsh => inputs/zsh} (100%) rename tests/test_shells/{ => outputs}/bash.daemon.ok (100%) rename tests/test_shells/{ => outputs}/bash.nodaemon.ok (100%) rename tests/test_shells/{ => outputs}/busybox.daemon.ok (100%) rename tests/test_shells/{ => outputs}/busybox.nodaemon.ok (100%) rename tests/test_shells/{ => outputs}/dash.daemon.ok (100%) rename tests/test_shells/{ => outputs}/dash.nodaemon.ok (100%) rename tests/test_shells/{ => outputs}/fish.ok (100%) rename tests/test_shells/{ => outputs}/ipython.ok (100%) rename tests/test_shells/{ => outputs}/mksh.daemon.ok (100%) rename tests/test_shells/{ => outputs}/mksh.nodaemon.ok (100%) rename tests/test_shells/{ => outputs}/pdb.module.ok (100%) rename tests/test_shells/{ => outputs}/pdb.subclass.ok (100%) rename tests/test_shells/{ => outputs}/rc.daemon.ok (100%) rename tests/test_shells/{ => outputs}/rc.nodaemon.ok (100%) rename tests/test_shells/{ => outputs}/tcsh.ok (100%) rename tests/test_shells/{ => outputs}/zsh.daemon.ok (100%) rename tests/test_shells/{ => outputs}/zsh.nodaemon.ok (100%) rename tests/test_shells/{ => outputs}/zsh.zpython.ok (100%) diff --git a/tests/test_shells/input.bash b/tests/test_shells/inputs/bash similarity index 100% rename from tests/test_shells/input.bash rename to tests/test_shells/inputs/bash diff --git a/tests/test_shells/input.busybox b/tests/test_shells/inputs/busybox similarity index 100% rename from tests/test_shells/input.busybox rename to tests/test_shells/inputs/busybox diff --git a/tests/test_shells/input.dash b/tests/test_shells/inputs/dash similarity index 100% rename from tests/test_shells/input.dash rename to tests/test_shells/inputs/dash diff --git a/tests/test_shells/input.fish b/tests/test_shells/inputs/fish similarity index 100% rename from tests/test_shells/input.fish rename to tests/test_shells/inputs/fish diff --git a/tests/test_shells/input.ipython b/tests/test_shells/inputs/ipython similarity index 100% rename from tests/test_shells/input.ipython rename to tests/test_shells/inputs/ipython diff --git a/tests/test_shells/input.mksh b/tests/test_shells/inputs/mksh similarity index 100% rename from tests/test_shells/input.mksh rename to tests/test_shells/inputs/mksh 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 100% rename from tests/test_shells/input.rc rename to tests/test_shells/inputs/rc diff --git a/tests/test_shells/input.tcsh b/tests/test_shells/inputs/tcsh similarity index 100% rename from tests/test_shells/input.tcsh rename to tests/test_shells/inputs/tcsh diff --git a/tests/test_shells/input.zsh b/tests/test_shells/inputs/zsh similarity index 100% rename from tests/test_shells/input.zsh rename to tests/test_shells/inputs/zsh diff --git a/tests/test_shells/bash.daemon.ok b/tests/test_shells/outputs/bash.daemon.ok similarity index 100% rename from tests/test_shells/bash.daemon.ok rename to tests/test_shells/outputs/bash.daemon.ok diff --git a/tests/test_shells/bash.nodaemon.ok b/tests/test_shells/outputs/bash.nodaemon.ok similarity index 100% rename from tests/test_shells/bash.nodaemon.ok rename to tests/test_shells/outputs/bash.nodaemon.ok diff --git a/tests/test_shells/busybox.daemon.ok b/tests/test_shells/outputs/busybox.daemon.ok similarity index 100% rename from tests/test_shells/busybox.daemon.ok rename to tests/test_shells/outputs/busybox.daemon.ok diff --git a/tests/test_shells/busybox.nodaemon.ok b/tests/test_shells/outputs/busybox.nodaemon.ok similarity index 100% rename from tests/test_shells/busybox.nodaemon.ok rename to tests/test_shells/outputs/busybox.nodaemon.ok diff --git a/tests/test_shells/dash.daemon.ok b/tests/test_shells/outputs/dash.daemon.ok similarity index 100% rename from tests/test_shells/dash.daemon.ok rename to tests/test_shells/outputs/dash.daemon.ok diff --git a/tests/test_shells/dash.nodaemon.ok b/tests/test_shells/outputs/dash.nodaemon.ok similarity index 100% rename from tests/test_shells/dash.nodaemon.ok rename to tests/test_shells/outputs/dash.nodaemon.ok diff --git a/tests/test_shells/fish.ok b/tests/test_shells/outputs/fish.ok similarity index 100% rename from tests/test_shells/fish.ok rename to tests/test_shells/outputs/fish.ok 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 100% rename from tests/test_shells/mksh.daemon.ok rename to tests/test_shells/outputs/mksh.daemon.ok diff --git a/tests/test_shells/mksh.nodaemon.ok b/tests/test_shells/outputs/mksh.nodaemon.ok similarity index 100% rename from tests/test_shells/mksh.nodaemon.ok rename to tests/test_shells/outputs/mksh.nodaemon.ok 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 100% rename from tests/test_shells/rc.daemon.ok rename to tests/test_shells/outputs/rc.daemon.ok diff --git a/tests/test_shells/rc.nodaemon.ok b/tests/test_shells/outputs/rc.nodaemon.ok similarity index 100% rename from tests/test_shells/rc.nodaemon.ok rename to tests/test_shells/outputs/rc.nodaemon.ok diff --git a/tests/test_shells/tcsh.ok b/tests/test_shells/outputs/tcsh.ok similarity index 100% rename from tests/test_shells/tcsh.ok rename to tests/test_shells/outputs/tcsh.ok diff --git a/tests/test_shells/zsh.daemon.ok b/tests/test_shells/outputs/zsh.daemon.ok similarity index 100% rename from tests/test_shells/zsh.daemon.ok rename to tests/test_shells/outputs/zsh.daemon.ok diff --git a/tests/test_shells/zsh.nodaemon.ok b/tests/test_shells/outputs/zsh.nodaemon.ok similarity index 100% rename from tests/test_shells/zsh.nodaemon.ok rename to tests/test_shells/outputs/zsh.nodaemon.ok diff --git a/tests/test_shells/zsh.zpython.ok b/tests/test_shells/outputs/zsh.zpython.ok similarity index 100% rename from tests/test_shells/zsh.zpython.ok rename to tests/test_shells/outputs/zsh.zpython.ok diff --git a/tests/test_shells/run_script.py b/tests/test_shells/run_script.py index 90b20f5b..2eebca19 100755 --- a/tests/test_shells/run_script.py +++ b/tests/test_shells/run_script.py @@ -89,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: diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index f3dac6f6..d70e8ac8 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -28,11 +28,13 @@ check_screen_log() { TEST_TYPE="$1" TEST_CLIENT="$2" SH="$3" - if test -e "$ROOT/tests/test_shells/${SH}.${TEST_TYPE}.ok" ; then - diff -a -u "$ROOT/tests/test_shells/${SH}.${TEST_TYPE}.ok" "$TEST_ROOT/${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 "$ROOT/tests/test_shells/${SH}.ok" ; then - diff -a -u "$ROOT/tests/test_shells/${SH}.ok" "$TEST_ROOT/${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 "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log" From 343b217cae7a573096f96d186f9e0199914758ab Mon Sep 17 00:00:00 2001 From: Foo Date: Mon, 1 May 2017 02:15:50 +0300 Subject: [PATCH 22/22] Fix warncreateglobal warning from zsh_expand --- powerline/bindings/zsh/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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