Replace screen-based tests with pexpect-based tests

Currently works for all tests, but dash ones. Not much of a problem since dash
tests were disabled for being unstable.
This commit is contained in:
ZyX 2015-02-21 14:03:34 +03:00
parent 8524ee35e7
commit 22162a9656
4 changed files with 21 additions and 19 deletions

View File

@ -5,7 +5,7 @@ git clone --depth=1 git://github.com/powerline/deps tests/bot-ci/deps
. tests/bot-ci/scripts/common/main.sh
sudo apt-get install -qq libssl1.0.0
sudo apt-get install -qq screen zsh tcsh mksh busybox socat realpath bc rc tmux
sudo apt-get install -qq zsh tcsh mksh busybox socat realpath bc rc tmux
if test -n "$USE_UCS2_PYTHON" ; then
pip install virtualenvwrapper

View File

@ -8,6 +8,7 @@ import re
from time import sleep
from subprocess import check_call
from io import BytesIO
import pexpect
@ -18,7 +19,7 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
parser.add_argument('--type', metavar='TYPE', help='Test type (daemon, nodaemon, …).')
parser.add_argument('--client', metavar='CLIENT', help='Type of the client used (C, shell, zpython, …).')
parser.add_argument('--shell', metavar='SHELL', help='Shell name.')
parser.add_argument('command', required=True, nargs=argparse.REMAINDER, metavar='COMMAND',
parser.add_argument('command', nargs=argparse.REMAINDER, metavar='COMMAND',
help='Command to run and its argument.')
return parser
@ -28,8 +29,8 @@ def main():
args = parser.parse_args()
shell = args.shell or args.command[0]
test_type = args.test_type or shell
test_client = args.test_client or test_type
test_type = args.type or shell
test_client = args.client or test_type
log_file_base = '{0}.{1}.{2}'.format(shell, test_type, test_client)
full_log_file_name = os.path.join('tests', 'shell', '{0}.full.log'.format(log_file_base))
@ -65,17 +66,24 @@ def main():
'LD_LIBRARY_PATH': os.environ.get('LD_LIBRARY_PATH', ''),
}
os.environ['PATH'] = environ['PATH']
if test_type == 'daemon':
environ['POWERLINE_SHELL_CONTINUATION'] = '1'
environ['POWERLINE_SHELL_SELECT'] = '1'
if test_type != 'zpython' and shell == 'zsh':
environ['POWERLINE_NO_ZSH_ZPYTHON'] = '1'
sio = BytesIO()
child = pexpect.spawn(
args.command[0],
args.command[1:],
logfile=open(full_log_file_name),
env=environ,
logfile=sio,
)
child.expect(re.compile('.*'))
child.expect(re.compile(b'.*'))
sleep(0.5)
child.setwinsize(1, 300)
@ -90,6 +98,9 @@ def main():
child.wait()
with open(full_log_file_name, 'w') as LF:
LF.write(child.read())
check_call([
os.path.join('tests', 'shell', 'path', 'python'),
os.path.join('tests', 'test_shells', 'postproc.py'),

View File

@ -1,7 +0,0 @@
width 1024
height 1
logfile "tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log"
# Having utf8 setting on causes screen to recode file passed to readreg. Adding
# `-e utf8` just after `readreg` causes screen to fail with `-X: copyreg:
# character, ^x, or (octal) \032 expected.` in place of fixing the issue.
defutf8 off

View File

@ -173,7 +173,6 @@ cp -r tests/test_shells/ipython_home tests/shell
mkdir tests/shell/path
ln -s "$(which "${PYTHON}")" tests/shell/path/python
ln -s "$(which screen)" tests/shell/path
ln -s "$(which env)" tests/shell/path
ln -s "$(which git)" tests/shell/path
ln -s "$(which sleep)" tests/shell/path
@ -347,9 +346,8 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te
if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then
continue
fi
POWERLINE_COMMAND_ARGS="--socket $ADDRESS"
POWERLINE_COMMAND="$POWERLINE_COMMAND"
export POWERLINE_COMMAND
export POWERLINE_COMMAND_ARGS="--socket $ADDRESS"
export POWERLINE_COMMAND="$POWERLINE_COMMAND"
echo ">> powerline command is ${POWERLINE_COMMAND:-empty}"
J=-1
for TEST_COMMAND in \
@ -455,8 +453,8 @@ fi
if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then
if which ipython >/dev/null ; then
# Define some overrides which should be ignored by IPython.
POWERLINE_CONFIG_OVERRIDES='common.term_escape_style=fbterm'
POWERLINE_THEME_OVERRIDES='in.segments.left=[]'
export POWERLINE_CONFIG_OVERRIDES='common.term_escape_style=fbterm'
export POWERLINE_THEME_OVERRIDES='in.segments.left=[]'
echo "> $(which ipython)"
if ! run_test ipython ipython ipython ; then
FAILED=1