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:
ZyX 2014-11-30 00:30:35 +03:00
parent 3f0d538584
commit 1707f083e9
2 changed files with 28 additions and 1 deletions

View File

@ -6,6 +6,8 @@ import os
import socket
import sys
import codecs
import platform
import re
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')))
pid_fname = os.path.join('tests', 'shell', '3rd', 'pid')
is_pypy = platform.python_implementation() == 'PyPy'
try:
with open(pid_fname, 'r') as P:
@ -24,6 +28,8 @@ except IOError:
hostname = socket.gethostname()
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(new_fname, 'w', encoding='utf-8') as W:
found_cd = False
@ -68,4 +74,25 @@ with codecs.open(fname, 'r', encoding='utf-8') as R:
# after the next line
if line.startswith('[1] + Terminated'):
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)

View File

@ -127,7 +127,7 @@ run_test() {
while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do
sleep 0.1s
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
if ! check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} ; then
echo '____________________________________________________________'