mirror of
https://github.com/powerline/powerline.git
synced 2025-07-25 14:54:54 +02:00
Modify postproc to make pypy tests work
Note: modification to test.sh is there because if running test outside of a virtualenv postproc.py will behave incorrectly.
This commit is contained in:
parent
3f0d538584
commit
1707f083e9
@ -6,6 +6,8 @@ import os
|
|||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import codecs
|
import codecs
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
test_type = sys.argv[1]
|
test_type = sys.argv[1]
|
||||||
@ -15,6 +17,8 @@ fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client,
|
|||||||
new_fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client, 'log')))
|
new_fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client, 'log')))
|
||||||
pid_fname = os.path.join('tests', 'shell', '3rd', 'pid')
|
pid_fname = os.path.join('tests', 'shell', '3rd', 'pid')
|
||||||
|
|
||||||
|
is_pypy = platform.python_implementation() == 'PyPy'
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(pid_fname, 'r') as P:
|
with open(pid_fname, 'r') as P:
|
||||||
@ -24,6 +28,8 @@ except IOError:
|
|||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
user = os.environ['USER']
|
user = os.environ['USER']
|
||||||
|
|
||||||
|
IPYPY_DEANSI_RE = re.compile(r'\033(?:\[(?:\?\d+[lh]|[^a-zA-Z]+[a-ln-zA-Z])|[=>])')
|
||||||
|
|
||||||
with codecs.open(fname, 'r', encoding='utf-8') as R:
|
with codecs.open(fname, 'r', encoding='utf-8') as R:
|
||||||
with codecs.open(new_fname, 'w', encoding='utf-8') as W:
|
with codecs.open(new_fname, 'w', encoding='utf-8') as W:
|
||||||
found_cd = False
|
found_cd = False
|
||||||
@ -68,4 +74,25 @@ with codecs.open(fname, 'r', encoding='utf-8') as R:
|
|||||||
# after the next line
|
# after the next line
|
||||||
if line.startswith('[1] + Terminated'):
|
if line.startswith('[1] + Terminated'):
|
||||||
continue
|
continue
|
||||||
|
elif shell == 'ipython' and is_pypy:
|
||||||
|
try:
|
||||||
|
end_idx = line.rindex('\033[0m')
|
||||||
|
try:
|
||||||
|
idx = line[:end_idx].rindex('\033[1;1H')
|
||||||
|
except ValueError:
|
||||||
|
idx = line[:end_idx].rindex('\033[?25h')
|
||||||
|
line = line[idx + len('\033[1;1H'):]
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
data_end_idx = line.rindex('\033[1;1H')
|
||||||
|
line = line[:data_end_idx] + '\n'
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if line == '\033[1;1H\n':
|
||||||
|
continue
|
||||||
|
was_empty = line == '\n'
|
||||||
|
line = IPYPY_DEANSI_RE.subn('', line)[0]
|
||||||
|
if line == '\n' and not was_empty:
|
||||||
|
line = ''
|
||||||
W.write(line)
|
W.write(line)
|
||||||
|
@ -127,7 +127,7 @@ run_test() {
|
|||||||
while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do
|
while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do
|
||||||
sleep 0.1s
|
sleep 0.1s
|
||||||
done
|
done
|
||||||
./tests/test_shells/postproc.py ${TEST_TYPE} ${TEST_CLIENT} ${SH}
|
${PYTHON} ./tests/test_shells/postproc.py ${TEST_TYPE} ${TEST_CLIENT} ${SH}
|
||||||
rm -f tests/shell/3rd/pid
|
rm -f tests/shell/3rd/pid
|
||||||
if ! check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} ; then
|
if ! check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} ; then
|
||||||
echo '____________________________________________________________'
|
echo '____________________________________________________________'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user