Merge pull request #1312 from ZyX-I/stabilize-vterm-tests
Stabilize vterm tests
This commit is contained in:
commit
ecc160cf92
|
@ -125,6 +125,7 @@ def _get_battery(pl):
|
||||||
pl.debug('Using windll to communicate with kernel32 (Windows)')
|
pl.debug('Using windll to communicate with kernel32 (Windows)')
|
||||||
from ctypes import windll
|
from ctypes import windll
|
||||||
library_loader = windll
|
library_loader = windll
|
||||||
|
|
||||||
class PowerClass(Structure):
|
class PowerClass(Structure):
|
||||||
_fields_ = [
|
_fields_ = [
|
||||||
('ACLineStatus', c_byte),
|
('ACLineStatus', c_byte),
|
||||||
|
|
|
@ -32,24 +32,12 @@ test_tmux() {
|
||||||
echo "Failed vterm test $f"
|
echo "Failed vterm test $f"
|
||||||
FAILED=1
|
FAILED=1
|
||||||
FAIL_SUMMARY="$FAIL_SUMMARY${NL}F $POWERLINE_TMUX_EXE $f"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -z "$POWERLINE_TMUX_EXE" && test -d tests/bot-ci/deps/tmux ; then
|
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
|
for tmux in tests/bot-ci/deps/tmux/tmux-*/tmux ; do
|
||||||
export POWERLINE_TMUX_EXE="$PWD/$tmux"
|
export POWERLINE_TMUX_EXE="$PWD/$tmux"
|
||||||
if test_tmux ; then
|
|
||||||
rm -f tests/vterm/*.log
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
test_tmux || true
|
test_tmux || true
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from difflib import ndiff
|
from difflib import ndiff
|
||||||
|
from glob import glob1
|
||||||
|
|
||||||
from powerline.lib.unicode import u
|
from powerline.lib.unicode import u
|
||||||
from powerline.bindings.tmux import get_tmux_version
|
from powerline.bindings.tmux import get_tmux_version
|
||||||
|
@ -16,6 +18,9 @@ from powerline import get_fallback_logger
|
||||||
from tests.lib.terminal import ExpectProcess
|
from tests.lib.terminal import ExpectProcess
|
||||||
|
|
||||||
|
|
||||||
|
VTERM_TEST_DIR = os.path.abspath('tests/vterm')
|
||||||
|
|
||||||
|
|
||||||
def cell_properties_key_to_shell_escape(cell_properties_key):
|
def cell_properties_key_to_shell_escape(cell_properties_key):
|
||||||
fg, bg, bold, underline, italic = cell_properties_key
|
fg, bg, bold, underline, italic = cell_properties_key
|
||||||
return('\x1b[38;2;{0};48;2;{1}{bold}{underline}{italic}m'.format(
|
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 = []
|
last_line = []
|
||||||
for col in range(cols):
|
for col in range(cols):
|
||||||
last_line.append(p[rows - 1, col])
|
last_line.append(p[rows - 1, col])
|
||||||
|
@ -78,11 +83,19 @@ def test_expected_result(p, expected_result, cols, rows):
|
||||||
print('Diff:')
|
print('Diff:')
|
||||||
print('=' * 80)
|
print('=' * 80)
|
||||||
print(''.join((u(line) for line in ndiff([a], [b]))))
|
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
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(attempts=3):
|
||||||
VTERM_TEST_DIR = os.path.abspath('tests/vterm')
|
|
||||||
vterm_path = os.path.join(VTERM_TEST_DIR, 'path')
|
vterm_path = os.path.join(VTERM_TEST_DIR, 'path')
|
||||||
socket_path = os.path.join(VTERM_TEST_DIR, 'tmux-socket')
|
socket_path = os.path.join(VTERM_TEST_DIR, 'tmux-socket')
|
||||||
rows = 50
|
rows = 50
|
||||||
|
@ -203,7 +216,13 @@ def main():
|
||||||
expected_result = expected_result_old
|
expected_result = expected_result_old
|
||||||
else:
|
else:
|
||||||
expected_result = expected_result_new
|
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:
|
finally:
|
||||||
check_call([tmux_exe, '-S', socket_path, 'kill-server'], env={
|
check_call([tmux_exe, '-S', socket_path, 'kill-server'], env={
|
||||||
'PATH': vterm_path,
|
'PATH': vterm_path,
|
||||||
|
|
Loading…
Reference in New Issue