Merge pull request #1312 from ZyX-I/stabilize-vterm-tests

Stabilize vterm tests
This commit is contained in:
ZyX 2015-02-19 12:25:42 +03:00
commit ecc160cf92
3 changed files with 24 additions and 16 deletions

View File

@ -125,6 +125,7 @@ def _get_battery(pl):
pl.debug('Using windll to communicate with kernel32 (Windows)')
from ctypes import windll
library_loader = windll
class PowerClass(Structure):
_fields_ = [
('ACLineStatus', c_byte),

View File

@ -32,24 +32,12 @@ test_tmux() {
echo "Failed vterm test $f"
FAILED=1
FAIL_SUMMARY="$FAIL_SUMMARY${NL}F $POWERLINE_TMUX_EXE $f"
for file in tests/vterm/*.log ; do
if ! test -e "$file" ; then
break
fi
echo '____________________________________________________________'
echo "$file:"
echo '============================================================'
cat -v $file
done
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_tmux ; then
rm -f tests/vterm/*.log
fi
done
else
test_tmux || true

View File

@ -3,11 +3,13 @@
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
import sys
from time import sleep
from subprocess import check_call
from itertools import groupby
from difflib import ndiff
from glob import glob1
from powerline.lib.unicode import u
from powerline.bindings.tmux import get_tmux_version
@ -16,6 +18,9 @@ from powerline import get_fallback_logger
from tests.lib.terminal import ExpectProcess
VTERM_TEST_DIR = os.path.abspath('tests/vterm')
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(
@ -27,7 +32,7 @@ def cell_properties_key_to_shell_escape(cell_properties_key):
))
def test_expected_result(p, expected_result, cols, rows):
def test_expected_result(p, expected_result, cols, rows, print_logs):
last_line = []
for col in range(cols):
last_line.append(p[rows - 1, col])
@ -78,11 +83,19 @@ def test_expected_result(p, expected_result, cols, rows):
print('Diff:')
print('=' * 80)
print(''.join((u(line) for line in ndiff([a], [b]))))
if print_logs:
for f in glob1(VTERM_TEST_DIR, '*.log'):
print('_' * 80)
print(os.path.basename(f) + ':')
print('=' * 80)
with open(f, 'r') as F:
for line in F:
sys.stdout.write(line)
os.unlink(f)
return False
def main():
VTERM_TEST_DIR = os.path.abspath('tests/vterm')
def main(attempts=3):
vterm_path = os.path.join(VTERM_TEST_DIR, 'path')
socket_path = os.path.join(VTERM_TEST_DIR, 'tmux-socket')
rows = 50
@ -203,7 +216,13 @@ def main():
expected_result = expected_result_old
else:
expected_result = expected_result_new
return test_expected_result(p, expected_result, cols, rows)
if not test_expected_result(p, expected_result, cols, rows, not attempts):
if attempts:
return main(attempts=(attempts - 1))
else:
return False
else:
return True
finally:
check_call([tmux_exe, '-S', socket_path, 'kill-server'], env={
'PATH': vterm_path,