Make tests test powerline daemon with valid python and all clients
This commit is contained in:
parent
03c22e94a7
commit
b9360a083a
|
@ -22,7 +22,7 @@ else
|
|||
pip install ipython
|
||||
fi
|
||||
fi
|
||||
sudo apt-get install -qq screen zsh tcsh mksh busybox
|
||||
sudo apt-get install -qq screen zsh tcsh mksh busybox socat
|
||||
# Travis has too outdated fish. It cannot be used for tests.
|
||||
# sudo apt-get install fish
|
||||
true
|
||||
|
|
|
@ -9,9 +9,10 @@ import codecs
|
|||
|
||||
|
||||
test_type = sys.argv[1]
|
||||
shell = sys.argv[2]
|
||||
fname = os.path.join('tests', 'shell', shell + '.' + test_type + '.full.log')
|
||||
new_fname = os.path.join('tests', 'shell', shell + '.' + test_type + '.log')
|
||||
test_client = sys.argv[2]
|
||||
shell = sys.argv[3]
|
||||
fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client, 'full.log')))
|
||||
new_fname = os.path.join('tests', 'shell', '.'.join((shell, test_type, test_client, 'log')))
|
||||
pid_fname = os.path.join('tests', 'shell', '3rd', 'pid')
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
width 1024
|
||||
height 1
|
||||
logfile "tests/shell/${SH}.${TEST_TYPE}.full.log"
|
||||
logfile "tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log"
|
||||
|
|
|
@ -1,23 +1,46 @@
|
|||
#!/bin/bash
|
||||
: ${PYTHON:=python}
|
||||
FAILED=0
|
||||
ONLY_SHELL="$1"
|
||||
ONLY_TEST_TYPE="$2"
|
||||
COMMAND_PATTERN="$3"
|
||||
|
||||
export PYTHON
|
||||
|
||||
if test "x$ONLY_SHELL" = "x--help" ; then
|
||||
cat << EOF
|
||||
Usage:
|
||||
$0 [[[ONLY_SHELL | ""] (ONLY_TEST_TYPE | "")] (COMMAND_PATTERN | "")]
|
||||
|
||||
ONLY_SHELL: execute only tests for given shell
|
||||
ONLY_TEST_TYPE: execute only "daemon" or "nodaemon" tests
|
||||
COMMAND_PATTERN: use only commands that match given pattern for testing
|
||||
EOF
|
||||
fi
|
||||
|
||||
check_screen_log() {
|
||||
TEST_TYPE="$1"
|
||||
SH="$2"
|
||||
TEST_CLIENT="$2"
|
||||
SH="$3"
|
||||
if test -e tests/test_shells/${SH}.${TEST_TYPE}.ok ; then
|
||||
diff -a -u tests/test_shells/${SH}.${TEST_TYPE}.ok tests/shell/${SH}.${TEST_TYPE}.log
|
||||
diff -a -u tests/test_shells/${SH}.${TEST_TYPE}.ok tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
||||
return $?
|
||||
elif test -e tests/test_shells/${SH}.ok ; then
|
||||
diff -a -u tests/test_shells/${SH}.ok tests/shell/${SH}.${TEST_TYPE}.log
|
||||
diff -a -u tests/test_shells/${SH}.ok tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
||||
return $?
|
||||
else
|
||||
cat tests/shell/${SH}.${TEST_TYPE}.log
|
||||
cat tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
run() {
|
||||
TEST_TYPE="$1"
|
||||
shift
|
||||
TEST_CLIENT="$1"
|
||||
shift
|
||||
SH="$1"
|
||||
shift
|
||||
local local_path="$PWD/tests/shell/path:$PWD/scripts"
|
||||
if test "x$SH" = "xfish" ; then
|
||||
local_path="${local_path}:/usr/bin:/bin"
|
||||
|
@ -33,6 +56,7 @@ run() {
|
|||
COLUMNS="${COLUMNS}" \
|
||||
LINES="${LINES}" \
|
||||
TEST_TYPE="${TEST_TYPE}" \
|
||||
TEST_CLIENT="${TEST_CLIENT}" \
|
||||
SH="${SH}" \
|
||||
DIR1="${DIR1}" \
|
||||
DIR2="${DIR2}" \
|
||||
|
@ -40,27 +64,22 @@ run() {
|
|||
IPYTHONDIR="$PWD/tests/shell/ipython_home" \
|
||||
POWERLINE_SHELL_CONTINUATION=$additional_prompts \
|
||||
POWERLINE_SHELL_SELECT=$additional_prompts \
|
||||
POWERLINE_COMMAND="${POWERLINE_COMMAND}" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
run_test() {
|
||||
TEST_TYPE="$1"
|
||||
shift
|
||||
TEST_CLIENT="$1"
|
||||
shift
|
||||
SH="$1"
|
||||
SESNAME="powerline-shell-test-${SH}-$$"
|
||||
ARGS=( "$@" )
|
||||
|
||||
test "x$ONLY_SHELL" = "x" || test "x$ONLY_SHELL" = "x$SH" || return 0
|
||||
|
||||
if ! which "${SH}" ; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
export TEST_TYPE
|
||||
export SH
|
||||
|
||||
run screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \
|
||||
env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "${ARGS[@]}"
|
||||
run "${TEST_TYPE}" "${TEST_CLIENT}" "${SH}" \
|
||||
screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \
|
||||
env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "${ARGS[@]}"
|
||||
while ! screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH ; do
|
||||
sleep 0.1s
|
||||
done
|
||||
|
@ -88,23 +107,27 @@ run_test() {
|
|||
while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do
|
||||
sleep 0.1s
|
||||
done
|
||||
./tests/test_shells/postproc.py ${TEST_TYPE} ${SH}
|
||||
./tests/test_shells/postproc.py ${TEST_TYPE} ${TEST_CLIENT} ${SH}
|
||||
rm -f tests/shell/3rd/pid
|
||||
if ! check_screen_log ${TEST_TYPE} ${SH} ; then
|
||||
echo '____________________________________________________________'
|
||||
# Repeat the diff to make it better viewable in travis output
|
||||
echo "Diff (cat -v):"
|
||||
echo '============================================================'
|
||||
check_screen_log ${TEST_TYPE} ${SH} | cat -v
|
||||
if ! check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} ; then
|
||||
echo '____________________________________________________________'
|
||||
if test "x$POWERLINE_TEST_NO_CAT_V" != "x1" ; then
|
||||
# Repeat the diff to make it better viewable in travis output
|
||||
echo "Diff (cat -v):"
|
||||
echo '============================================================'
|
||||
check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} | cat -v
|
||||
echo '____________________________________________________________'
|
||||
fi
|
||||
echo "Failed ${SH}. Full output:"
|
||||
echo '============================================================'
|
||||
cat tests/shell/${SH}.${TEST_TYPE}.full.log
|
||||
echo '____________________________________________________________'
|
||||
echo "Full output (cat -v):"
|
||||
echo '============================================================'
|
||||
cat -v tests/shell/${SH}.${TEST_TYPE}.full.log
|
||||
cat tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log
|
||||
echo '____________________________________________________________'
|
||||
if test "x$POWERLINE_TEST_NO_CAT_V" != "x1" ; then
|
||||
echo "Full output (cat -v):"
|
||||
echo '============================================================'
|
||||
cat -v tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log
|
||||
echo '____________________________________________________________'
|
||||
fi
|
||||
case ${SH} in
|
||||
*ksh)
|
||||
${SH} -c 'echo ${KSH_VERSION}'
|
||||
|
@ -146,7 +169,7 @@ mkdir tests/shell/fish_home
|
|||
cp -r tests/test_shells/ipython_home tests/shell
|
||||
|
||||
mkdir tests/shell/path
|
||||
ln -s "$(which "${PYTHON:-python}")" tests/shell/path/python
|
||||
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 sleep)" tests/shell/path
|
||||
|
@ -168,6 +191,9 @@ ln -s "$(which sed)" tests/shell/path
|
|||
ln -s "$(which rm)" tests/shell/path
|
||||
ln -s ../../test_shells/bgscript.sh tests/shell/path
|
||||
ln -s ../../test_shells/waitpid.sh tests/shell/path
|
||||
if which socat ; then
|
||||
ln -s "$(which socat)" tests/shell/path
|
||||
fi
|
||||
for pexe in powerline powerline-config ; do
|
||||
if test -e scripts/$pexe ; then
|
||||
ln -s "$PWD/scripts/$pexe" tests/shell/path
|
||||
|
@ -194,40 +220,66 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te
|
|||
scripts/powerline-config shell command
|
||||
|
||||
for TEST_TYPE in "daemon" "nodaemon" ; do
|
||||
if test $TEST_TYPE == daemon ; then
|
||||
sh -c 'echo $$ > tests/shell/daemon_pid; ./scripts/powerline-daemon -f &>tests/shell/daemon_log' &
|
||||
if test $TEST_TYPE = daemon ; then
|
||||
sh -c 'echo $$ > tests/shell/daemon_pid; $PYTHON ./scripts/powerline-daemon -f &>tests/shell/daemon_log' &
|
||||
fi
|
||||
if ! run_test $TEST_TYPE bash --norc --noprofile -i ; then
|
||||
FAILED=1
|
||||
if test "x$ONLY_TEST_TYPE" != "x" && test "x$ONLY_TEST_TYPE" != "x$TEST_TYPE" ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if ! run_test $TEST_TYPE zsh -f -i ; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if ! run_test $TEST_TYPE fish -i ; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if ! run_test $TEST_TYPE tcsh -f -i ; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if ! run_test $TEST_TYPE busybox ash -i ; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if ! run_test $TEST_TYPE mksh -i ; then
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
if ! run_test $TEST_TYPE dash -i ; then
|
||||
# dash tests are not stable, see #931
|
||||
# FAILED=1
|
||||
true
|
||||
fi
|
||||
if test $TEST_TYPE == daemon ; then
|
||||
./scripts/powerline-daemon -k
|
||||
echo "> Testing $TEST_TYPE"
|
||||
for POWERLINE_COMMAND in "" \
|
||||
$PWD/scripts/powerline \
|
||||
$PWD/scripts/powerline-render \
|
||||
"$PYTHON $PWD/client/powerline.py" \
|
||||
$PWD/client/powerline.sh
|
||||
do
|
||||
case "$POWERLINE_COMMAND" in
|
||||
*powerline) TEST_CLIENT=C ;;
|
||||
*powerline-render) TEST_CLIENT=render ;;
|
||||
*powerline.py) TEST_CLIENT=python ;;
|
||||
*powerline.sh) TEST_CLIENT=shell ;;
|
||||
"") TEST_CLIENT=auto ;;
|
||||
esac
|
||||
if test "$TEST_CLIENT" = "shell" && ! which socat >/dev/null ; then
|
||||
continue
|
||||
fi
|
||||
if test "$TEST_CLIENT" = render && test "$TEST_TYPE" = daemon ; then
|
||||
continue
|
||||
fi
|
||||
if test "x$COMMAND_PATTERN" != "x" && ! (
|
||||
echo "$POWERLINE_COMMAND" | grep -e"$COMMAND_PATTERN" &>/dev/null)
|
||||
then
|
||||
continue
|
||||
fi
|
||||
export POWERLINE_COMMAND
|
||||
echo ">> powerline command is ${POWERLINE_COMMAND:-empty}"
|
||||
for TEST_COMMAND in \
|
||||
"bash --norc --noprofile -i" \
|
||||
"zsh -f -i" \
|
||||
"fish -i" \
|
||||
"tcsh -f -i" \
|
||||
"busybox ash -i" \
|
||||
"mksh -i" \
|
||||
"dash -i"
|
||||
do
|
||||
SH="${TEST_COMMAND%% *}"
|
||||
if test "x$ONLY_SHELL" != "x" && test "x$ONLY_SHELL" != "x$SH" ; then
|
||||
continue
|
||||
fi
|
||||
if ! which $SH >/dev/null ; then
|
||||
continue
|
||||
fi
|
||||
echo ">>> $(which $SH)"
|
||||
if ! run_test $TEST_TYPE $TEST_CLIENT $TEST_COMMAND ; then
|
||||
# dash tests are not stable, see #931
|
||||
if test "x$SH" != "xdash" ; then
|
||||
FAILED=1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
if test $TEST_TYPE = daemon ; then
|
||||
$PYTHON ./scripts/powerline-daemon -k
|
||||
wait $(cat tests/shell/daemon_pid)
|
||||
if ! test -z "$(cat tests/shell/daemon_log)" ; then
|
||||
echo '____________________________________________________________'
|
||||
|
@ -240,8 +292,11 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te
|
|||
done
|
||||
fi
|
||||
|
||||
if ! run_test ipython ipython ; then
|
||||
FAILED=1
|
||||
if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then
|
||||
echo "> $(which ipython)"
|
||||
if ! run_test ipython ipython ipython ; then
|
||||
FAILED=1
|
||||
fi
|
||||
fi
|
||||
|
||||
test $FAILED -eq 0 && rm -r tests/shell
|
||||
|
|
Loading…
Reference in New Issue