diff --git a/tests/test_shells/postproc.py b/tests/test_shells/postproc.py index 71e79f9e..3ef35972 100755 --- a/tests/test_shells/postproc.py +++ b/tests/test_shells/postproc.py @@ -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) diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index db95f1bf..275fa9c5 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -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 '____________________________________________________________'