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