2014-08-23 13:18:00 +02:00
|
|
|
|
#!/bin/sh
|
2015-01-31 15:58:14 +01:00
|
|
|
|
. tests/bot-ci/scripts/common/main.sh
|
|
|
|
|
set +x
|
|
|
|
|
|
2014-08-23 01:28:51 +02:00
|
|
|
|
: ${PYTHON:=python}
|
2014-11-28 21:02:12 +01:00
|
|
|
|
FAIL_SUMMARY=""
|
2014-01-11 10:16:25 +01:00
|
|
|
|
FAILED=0
|
2014-08-23 13:16:30 +02:00
|
|
|
|
if test "x$1" = "x--fast" ; then
|
|
|
|
|
FAST=1
|
|
|
|
|
shift
|
|
|
|
|
fi
|
2014-01-23 04:36:08 +01:00
|
|
|
|
ONLY_SHELL="$1"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
ONLY_TEST_TYPE="$2"
|
2014-08-24 14:59:03 +02:00
|
|
|
|
ONLY_TEST_CLIENT="$3"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
|
2014-08-24 14:59:03 +02:00
|
|
|
|
if ! test -z "$ONLY_SHELL$ONLY_TEST_TYPE$ONLY_TEST_CLIENT" ; then
|
2014-08-23 13:16:30 +02:00
|
|
|
|
FAST=
|
|
|
|
|
fi
|
|
|
|
|
|
2014-08-23 01:28:51 +02:00
|
|
|
|
export PYTHON
|
|
|
|
|
|
|
|
|
|
if test "x$ONLY_SHELL" = "x--help" ; then
|
|
|
|
|
cat << EOF
|
|
|
|
|
Usage:
|
2014-08-24 14:59:03 +02:00
|
|
|
|
$0 [[[ONLY_SHELL | ""] (ONLY_TEST_TYPE | "")] (ONLY_TEST_CLIENT | "")]
|
2014-08-23 01:28:51 +02:00
|
|
|
|
|
|
|
|
|
ONLY_SHELL: execute only tests for given shell
|
|
|
|
|
ONLY_TEST_TYPE: execute only "daemon" or "nodaemon" tests
|
2014-08-24 14:59:03 +02:00
|
|
|
|
ONLY_TEST_CLIENT: use only given test client (one of C, python, render, shell)
|
2014-08-23 01:28:51 +02:00
|
|
|
|
EOF
|
2014-08-23 12:55:59 +02:00
|
|
|
|
exit 0
|
2014-08-23 01:28:51 +02:00
|
|
|
|
fi
|
2014-01-11 10:31:57 +01:00
|
|
|
|
|
2014-01-17 18:34:18 +01:00
|
|
|
|
check_screen_log() {
|
2014-08-02 19:02:26 +02:00
|
|
|
|
TEST_TYPE="$1"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
TEST_CLIENT="$2"
|
|
|
|
|
SH="$3"
|
2014-08-02 19:02:26 +02:00
|
|
|
|
if test -e tests/test_shells/${SH}.${TEST_TYPE}.ok ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
diff -a -u tests/test_shells/${SH}.${TEST_TYPE}.ok tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
2014-08-02 19:02:26 +02:00
|
|
|
|
return $?
|
|
|
|
|
elif test -e tests/test_shells/${SH}.ok ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
diff -a -u tests/test_shells/${SH}.ok tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
2014-01-22 05:33:43 +01:00
|
|
|
|
return $?
|
|
|
|
|
else
|
2014-08-23 01:28:51 +02:00
|
|
|
|
cat tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
2014-01-22 05:33:43 +01:00
|
|
|
|
return 1
|
|
|
|
|
fi
|
2014-01-17 18:34:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-10 14:01:03 +02:00
|
|
|
|
run() {
|
2014-08-23 01:28:51 +02:00
|
|
|
|
TEST_TYPE="$1"
|
|
|
|
|
shift
|
|
|
|
|
TEST_CLIENT="$1"
|
|
|
|
|
shift
|
|
|
|
|
SH="$1"
|
|
|
|
|
shift
|
2014-08-10 14:01:03 +02:00
|
|
|
|
local local_path="$PWD/tests/shell/path:$PWD/scripts"
|
|
|
|
|
if test "x$SH" = "xfish" ; then
|
|
|
|
|
local_path="${local_path}:/usr/bin:/bin"
|
|
|
|
|
fi
|
2014-08-12 05:54:34 +02:00
|
|
|
|
if test $TEST_TYPE = daemon ; then
|
|
|
|
|
local additional_prompts=1
|
|
|
|
|
else
|
|
|
|
|
local additional_prompts=
|
|
|
|
|
fi
|
2014-08-10 14:01:03 +02:00
|
|
|
|
env -i \
|
2014-08-27 20:30:59 +02:00
|
|
|
|
LANG=en_US.UTF-8 \
|
2014-08-10 14:01:03 +02:00
|
|
|
|
PATH="$local_path" \
|
2014-10-11 22:41:06 +02:00
|
|
|
|
TERM="screen-256color" \
|
2014-08-10 14:01:03 +02:00
|
|
|
|
COLUMNS="${COLUMNS}" \
|
|
|
|
|
LINES="${LINES}" \
|
|
|
|
|
TEST_TYPE="${TEST_TYPE}" \
|
2014-08-23 01:28:51 +02:00
|
|
|
|
TEST_CLIENT="${TEST_CLIENT}" \
|
2014-08-10 14:01:03 +02:00
|
|
|
|
SH="${SH}" \
|
|
|
|
|
DIR1="${DIR1}" \
|
2015-01-02 01:43:57 +01:00
|
|
|
|
POWERLINE_NO_ZSH_ZPYTHON="$(test $TEST_TYPE = zpython || echo 1)" \
|
2014-08-10 14:01:03 +02:00
|
|
|
|
DIR2="${DIR2}" \
|
|
|
|
|
XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \
|
|
|
|
|
IPYTHONDIR="$PWD/tests/shell/ipython_home" \
|
2014-12-10 06:36:27 +01:00
|
|
|
|
PYTHONPATH="${PWD}${PYTHONPATH:+:}$PYTHONPATH" \
|
2015-01-07 14:24:48 +01:00
|
|
|
|
POWERLINE_CONFIG_OVERRIDES="${POWERLINE_CONFIG_OVERRIDES}" \
|
|
|
|
|
POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES}" \
|
2014-08-12 05:54:34 +02:00
|
|
|
|
POWERLINE_SHELL_CONTINUATION=$additional_prompts \
|
|
|
|
|
POWERLINE_SHELL_SELECT=$additional_prompts \
|
2015-01-06 22:17:56 +01:00
|
|
|
|
POWERLINE_CONFIG_PATHS="$PWD/powerline/config_files" \
|
2015-01-07 13:07:27 +01:00
|
|
|
|
POWERLINE_COMMAND_ARGS="${POWERLINE_COMMAND_ARGS}" \
|
2015-01-06 22:17:56 +01:00
|
|
|
|
POWERLINE_COMMAND="${POWERLINE_COMMAND}" \
|
2014-08-10 14:01:03 +02:00
|
|
|
|
"$@"
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-28 21:01:19 +01:00
|
|
|
|
# HACK: get newline for use in strings given that "\n" and $'' do not work.
|
|
|
|
|
NL="$(printf '\nE')"
|
|
|
|
|
NL="${NL%E}"
|
|
|
|
|
|
2015-01-08 00:30:03 +01:00
|
|
|
|
do_run_test() {
|
2014-08-02 19:02:26 +02:00
|
|
|
|
TEST_TYPE="$1"
|
|
|
|
|
shift
|
2014-08-23 01:28:51 +02:00
|
|
|
|
TEST_CLIENT="$1"
|
|
|
|
|
shift
|
2014-01-12 22:07:13 +01:00
|
|
|
|
SH="$1"
|
2014-01-23 04:36:08 +01:00
|
|
|
|
SESNAME="powerline-shell-test-${SH}-$$"
|
|
|
|
|
|
2014-12-05 21:09:21 +01:00
|
|
|
|
# Note: when running screen with setuid libc unsets LD_LIBRARY_PATH, so it
|
|
|
|
|
# cannot be added to the `env -i` call above.
|
2014-08-23 01:28:51 +02:00
|
|
|
|
run "${TEST_TYPE}" "${TEST_CLIENT}" "${SH}" \
|
|
|
|
|
screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \
|
2014-12-05 21:09:21 +01:00
|
|
|
|
env LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" \
|
2014-08-27 20:30:59 +02:00
|
|
|
|
"$@"
|
2014-08-10 16:19:48 +02:00
|
|
|
|
while ! screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH ; do
|
|
|
|
|
sleep 0.1s
|
|
|
|
|
done
|
2014-01-17 18:34:18 +01:00
|
|
|
|
# Wait for screen to initialize
|
2014-07-19 23:49:30 +02:00
|
|
|
|
sleep 1
|
2015-01-31 18:25:40 +01:00
|
|
|
|
local attempts=100
|
|
|
|
|
while ! screen -S "$SESNAME" -p 0 -X width 300 1 >/dev/null ; do
|
2014-08-10 16:19:48 +02:00
|
|
|
|
sleep 0.1s
|
2015-01-31 18:25:40 +01:00
|
|
|
|
attempts=$(( attempts - 1 ))
|
|
|
|
|
if test $attempts -eq 0 ; then
|
|
|
|
|
echo "Waiting for too long: assuming test failed"
|
2015-01-31 19:18:06 +01:00
|
|
|
|
echo "Failed ${SH}. Full output:"
|
|
|
|
|
echo '============================================================'
|
|
|
|
|
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
|
2015-01-31 18:25:40 +01:00
|
|
|
|
return 1
|
|
|
|
|
fi
|
2014-08-10 16:19:48 +02:00
|
|
|
|
done
|
2014-11-29 19:40:06 +01:00
|
|
|
|
if ( \
|
2015-01-31 15:58:14 +01:00
|
|
|
|
test "x${SH}" = "xdash" \
|
|
|
|
|
|| ( \
|
2014-11-29 19:40:06 +01:00
|
|
|
|
test "x${SH}" = "xipython" \
|
2015-01-31 15:58:14 +01:00
|
|
|
|
&& test "$PYTHON_IMPLEMENTATION" = "PyPy" \
|
|
|
|
|
) \
|
|
|
|
|
|| ( \
|
|
|
|
|
test "x${SH}" = "xpdb" \
|
2015-01-31 16:10:19 +01:00
|
|
|
|
&& ( \
|
2015-02-01 22:12:06 +01:00
|
|
|
|
( \
|
|
|
|
|
test "$PYTHON_VERSION_MAJOR" -eq 3 \
|
|
|
|
|
&& test "$PYTHON_VERSION_MINOR" -eq 2 \
|
|
|
|
|
&& test "$PYTHON_IMPLEMENTATION" = "CPython" \
|
|
|
|
|
) \
|
|
|
|
|
|| test "$PYTHON_IMPLEMENTATION" = "PyPy" \
|
2015-01-31 15:58:14 +01:00
|
|
|
|
) \
|
2014-11-29 19:40:06 +01:00
|
|
|
|
) \
|
|
|
|
|
) ; then
|
2014-07-20 00:04:44 +02:00
|
|
|
|
# If I do not use this hack for dash then output will look like
|
|
|
|
|
#
|
|
|
|
|
# command1
|
|
|
|
|
# command2
|
|
|
|
|
# …
|
|
|
|
|
# prompt1> prompt2> …
|
2014-07-19 23:49:30 +02:00
|
|
|
|
while read -r line ; do
|
2015-01-31 15:58:14 +01:00
|
|
|
|
if test "$(screen -S "$SESNAME" -p 0 -X stuff "$line$NL")" = "No screen session found." ; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
2014-07-19 23:49:30 +02:00
|
|
|
|
sleep 1
|
|
|
|
|
done < tests/test_shells/input.$SH
|
|
|
|
|
else
|
|
|
|
|
screen -S "$SESNAME" -p 0 -X paste a
|
|
|
|
|
fi
|
2014-01-17 18:34:18 +01:00
|
|
|
|
# Wait for screen to exit (sending command to non-existing screen session
|
|
|
|
|
# fails; when launched instance exits corresponding session is deleted)
|
2014-01-12 21:53:38 +01:00
|
|
|
|
while screen -S "$SESNAME" -X blankerprg "" > /dev/null ; do
|
2014-01-17 18:34:18 +01:00
|
|
|
|
sleep 0.1s
|
2014-01-12 21:53:38 +01:00
|
|
|
|
done
|
2014-11-29 22:30:35 +01:00
|
|
|
|
${PYTHON} ./tests/test_shells/postproc.py ${TEST_TYPE} ${TEST_CLIENT} ${SH}
|
2014-08-10 15:10:35 +02:00
|
|
|
|
rm -f tests/shell/3rd/pid
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if ! check_screen_log ${TEST_TYPE} ${TEST_CLIENT} ${SH} ; then
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo '____________________________________________________________'
|
2014-08-23 01:28:51 +02:00
|
|
|
|
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
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo "Failed ${SH}. Full output:"
|
|
|
|
|
echo '============================================================'
|
2014-08-23 01:28:51 +02:00
|
|
|
|
cat tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo '____________________________________________________________'
|
2014-08-23 01:28:51 +02:00
|
|
|
|
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
|
2014-07-19 23:49:30 +02:00
|
|
|
|
case ${SH} in
|
|
|
|
|
*ksh)
|
|
|
|
|
${SH} -c 'echo ${KSH_VERSION}'
|
|
|
|
|
;;
|
|
|
|
|
dash)
|
|
|
|
|
# ?
|
|
|
|
|
;;
|
2014-07-28 01:15:36 +02:00
|
|
|
|
busybox)
|
|
|
|
|
busybox --help
|
2014-07-19 23:49:30 +02:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
${SH} --version
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
if which dpkg >/dev/null ; then
|
|
|
|
|
dpkg -s ${SH}
|
|
|
|
|
fi
|
2014-01-12 21:53:38 +01:00
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
2014-01-11 10:36:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-08 00:30:03 +01:00
|
|
|
|
run_test() {
|
2015-01-09 15:42:20 +01:00
|
|
|
|
TEST_TYPE="$1"
|
|
|
|
|
TEST_CLIENT="$2"
|
|
|
|
|
SH="$3"
|
2015-01-08 00:30:03 +01:00
|
|
|
|
local attempts=3
|
2015-01-31 15:58:14 +01:00
|
|
|
|
if test -n "$ONLY_SHELL$ONLY_TEST_TYPE$ONLY_TEST_CLIENT" ; then
|
|
|
|
|
attempts=1
|
|
|
|
|
fi
|
2015-01-08 00:30:03 +01:00
|
|
|
|
while test $attempts -gt 0 ; do
|
2015-01-09 15:42:20 +01:00
|
|
|
|
rm -f tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log
|
|
|
|
|
rm -f tests/shell/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log
|
2015-01-08 00:30:03 +01:00
|
|
|
|
do_run_test "$@" && return 0
|
|
|
|
|
attempts=$(( attempts - 1 ))
|
|
|
|
|
done
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-23 04:36:08 +01:00
|
|
|
|
test -d tests/shell && rm -r tests/shell
|
2014-01-11 10:16:25 +01:00
|
|
|
|
mkdir tests/shell
|
2014-01-11 10:31:57 +01:00
|
|
|
|
git init tests/shell/3rd
|
|
|
|
|
git --git-dir=tests/shell/3rd/.git checkout -b BRANCH
|
2014-01-26 18:59:33 +01:00
|
|
|
|
export DIR1="[32m"
|
|
|
|
|
export DIR2=""
|
|
|
|
|
mkdir tests/shell/3rd/"$DIR1"
|
|
|
|
|
mkdir tests/shell/3rd/"$DIR2"
|
2014-01-26 18:45:02 +01:00
|
|
|
|
mkdir tests/shell/3rd/'\[\]'
|
|
|
|
|
mkdir tests/shell/3rd/'%%'
|
|
|
|
|
mkdir tests/shell/3rd/'#[bold]'
|
|
|
|
|
mkdir tests/shell/3rd/'(echo)'
|
|
|
|
|
mkdir tests/shell/3rd/'$(echo)'
|
|
|
|
|
mkdir tests/shell/3rd/'`echo`'
|
2014-11-28 20:58:53 +01:00
|
|
|
|
mkdir tests/shell/3rd/'«Unicode!»'
|
2014-01-11 10:31:57 +01:00
|
|
|
|
|
2014-01-23 13:14:32 +01:00
|
|
|
|
mkdir tests/shell/fish_home
|
2014-08-24 15:13:00 +02:00
|
|
|
|
mkdir tests/shell/fish_home/fish
|
|
|
|
|
mkdir tests/shell/fish_home/fish/generated_completions
|
2014-08-06 15:18:42 +02:00
|
|
|
|
cp -r tests/test_shells/ipython_home tests/shell
|
2014-08-10 14:01:03 +02:00
|
|
|
|
|
|
|
|
|
mkdir tests/shell/path
|
2014-08-23 01:28:51 +02:00
|
|
|
|
ln -s "$(which "${PYTHON}")" tests/shell/path/python
|
2014-08-10 14:01:03 +02:00
|
|
|
|
ln -s "$(which screen)" tests/shell/path
|
|
|
|
|
ln -s "$(which env)" tests/shell/path
|
2014-09-20 12:43:45 +02:00
|
|
|
|
ln -s "$(which git)" tests/shell/path
|
2014-08-10 14:01:03 +02:00
|
|
|
|
ln -s "$(which sleep)" tests/shell/path
|
|
|
|
|
ln -s "$(which cat)" tests/shell/path
|
|
|
|
|
ln -s "$(which false)" tests/shell/path
|
|
|
|
|
ln -s "$(which true)" tests/shell/path
|
|
|
|
|
ln -s "$(which kill)" tests/shell/path
|
|
|
|
|
ln -s "$(which echo)" tests/shell/path
|
|
|
|
|
ln -s "$(which which)" tests/shell/path
|
|
|
|
|
ln -s "$(which dirname)" tests/shell/path
|
|
|
|
|
ln -s "$(which wc)" tests/shell/path
|
|
|
|
|
ln -s "$(which stty)" tests/shell/path
|
|
|
|
|
ln -s "$(which cut)" tests/shell/path
|
|
|
|
|
ln -s "$(which bc)" tests/shell/path
|
|
|
|
|
ln -s "$(which expr)" tests/shell/path
|
|
|
|
|
ln -s "$(which mktemp)" tests/shell/path
|
2014-08-12 05:54:34 +02:00
|
|
|
|
ln -s "$(which grep)" tests/shell/path
|
|
|
|
|
ln -s "$(which sed)" tests/shell/path
|
|
|
|
|
ln -s "$(which rm)" tests/shell/path
|
2014-12-05 22:52:17 +01:00
|
|
|
|
ln -s "$(which uname)" tests/shell/path
|
2015-01-07 23:46:16 +01:00
|
|
|
|
ln -s "$(which test)" tests/shell/path
|
|
|
|
|
ln -s "$(which pwd)" tests/shell/path
|
2014-08-10 14:58:55 +02:00
|
|
|
|
ln -s ../../test_shells/bgscript.sh tests/shell/path
|
2014-08-10 15:10:35 +02:00
|
|
|
|
ln -s ../../test_shells/waitpid.sh tests/shell/path
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if which socat ; then
|
|
|
|
|
ln -s "$(which socat)" tests/shell/path
|
|
|
|
|
fi
|
2015-02-14 23:25:25 +01:00
|
|
|
|
for pexe in powerline powerline-config powerline-render powerline.sh powerline.py ; do
|
2014-08-10 14:01:03 +02:00
|
|
|
|
if test -e scripts/$pexe ; then
|
|
|
|
|
ln -s "$PWD/scripts/$pexe" tests/shell/path
|
2015-02-14 23:25:25 +01:00
|
|
|
|
elif test -e client/$pexe ; then
|
|
|
|
|
ln -s "$PWD/client/$pexe" tests/shell/path
|
2014-08-10 14:01:03 +02:00
|
|
|
|
elif which $pexe ; then
|
|
|
|
|
ln -s "$(which $pexe)" tests/shell/path
|
|
|
|
|
else
|
|
|
|
|
echo "Executable $pexe was not found"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2015-01-31 15:58:14 +01:00
|
|
|
|
ln -s python tests/shell/path/pdb
|
|
|
|
|
PDB_PYTHON=pdb
|
|
|
|
|
|
2015-01-07 23:46:16 +01:00
|
|
|
|
if test -z "$POWERLINE_RC_EXE" ; then
|
|
|
|
|
if which rc-status >/dev/null ; then
|
|
|
|
|
# On Gentoo `rc` executable is from OpenRC. Thus app-shells/rc instals
|
|
|
|
|
# `rcsh` executable.
|
|
|
|
|
POWERLINE_RC_EXE=rcsh
|
|
|
|
|
else
|
|
|
|
|
POWERLINE_RC_EXE=rc
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if which "$POWERLINE_RC_EXE" >/dev/null ; then
|
|
|
|
|
ln -s "$(which $POWERLINE_RC_EXE)" tests/shell/path/rc
|
|
|
|
|
fi
|
|
|
|
|
|
2014-08-12 05:54:34 +02:00
|
|
|
|
for exe in bash zsh busybox fish tcsh mksh dash ipython ; do
|
2014-08-10 14:01:03 +02:00
|
|
|
|
if which $exe >/dev/null ; then
|
2015-02-20 21:16:01 +01:00
|
|
|
|
if test "$exe" = "fish" ; then
|
|
|
|
|
fish_version="$(fish --version 2>&1)"
|
|
|
|
|
fish_version="${fish_version##* }"
|
|
|
|
|
fish_version_major="${fish_version%%.*}"
|
|
|
|
|
fish_version_minor="${fish_version#*.}"
|
2015-02-20 21:37:13 +01:00
|
|
|
|
fish_version_patch="${fish_version_minor#*.}"
|
|
|
|
|
fish_version_dev="${fish_version_patch#*-}"
|
|
|
|
|
if test "$fish_version_dev" = "$fish_version_patch" ; then
|
|
|
|
|
fish_version_dev=""
|
|
|
|
|
fi
|
2015-02-20 21:16:01 +01:00
|
|
|
|
fish_version_minor="${fish_version_minor%%.*}"
|
2015-02-20 21:37:13 +01:00
|
|
|
|
fish_version_patch="${fish_version_patch%%-*}"
|
2015-02-20 21:16:01 +01:00
|
|
|
|
if test $fish_version_major -lt 2 || ( \
|
2015-02-20 21:37:13 +01:00
|
|
|
|
test $fish_version_major -eq 2 && (\
|
|
|
|
|
test $fish_version_minor -lt 1 || (\
|
|
|
|
|
test $fish_version_minor -eq 1 &&
|
|
|
|
|
test $fish_version_patch -lt 2 && \
|
|
|
|
|
test -z "$fish_version_dev"
|
|
|
|
|
) \
|
|
|
|
|
) \
|
2015-02-20 21:16:01 +01:00
|
|
|
|
) ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2014-08-10 14:01:03 +02:00
|
|
|
|
ln -s "$(which $exe)" tests/shell/path
|
|
|
|
|
fi
|
|
|
|
|
done
|
2014-01-13 16:47:58 +01:00
|
|
|
|
|
2014-08-02 19:02:26 +02:00
|
|
|
|
unset ENV
|
2014-01-26 20:52:06 +01:00
|
|
|
|
|
2014-08-23 13:18:00 +02:00
|
|
|
|
export ADDRESS="powerline-ipc-test-$$"
|
2014-08-23 12:55:59 +02:00
|
|
|
|
export PYTHON
|
|
|
|
|
echo "Powerline address: $ADDRESS"
|
2014-07-19 23:49:30 +02:00
|
|
|
|
|
2015-02-14 23:25:25 +01:00
|
|
|
|
check_test_client() {
|
|
|
|
|
local executable="$1"
|
|
|
|
|
local client_type="$2"
|
|
|
|
|
local actual_mime_type="$(file --mime-type --brief --dereference "tests/shell/path/$executable" | cut -d/ -f1)"
|
|
|
|
|
local expected_mime_type
|
|
|
|
|
case "$client_type" in
|
|
|
|
|
C) expected_mime_type="application/x-executable" ;;
|
|
|
|
|
python) expected_mime_type="text/x-python" ;;
|
|
|
|
|
render) expected_mime_type="text/x-python" ;;
|
|
|
|
|
shell) expected_mime_type="text/x-shellscript" ;;
|
|
|
|
|
esac
|
|
|
|
|
expected_mime_type="${expected_mime_type%/*}"
|
|
|
|
|
if test "$expected_mime_type" != "$actual_mime_type" ; then
|
|
|
|
|
echo "Expected $executable to have MIME type $expected_mime_type, but got $actual_mime_type"
|
|
|
|
|
FAILED=1
|
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}M ${executable}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-07 23:46:16 +01:00
|
|
|
|
if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbusybox || test "x${ONLY_SHELL}" = xrc ; then
|
2014-08-06 15:18:42 +02:00
|
|
|
|
scripts/powerline-config shell command
|
2014-08-02 19:27:31 +02:00
|
|
|
|
|
2014-08-06 15:18:42 +02:00
|
|
|
|
for TEST_TYPE in "daemon" "nodaemon" ; do
|
2014-08-29 20:36:32 +02:00
|
|
|
|
if test "x$ONLY_TEST_TYPE" != "x" && test "x$ONLY_TEST_TYPE" != "x$TEST_TYPE" ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
2014-08-23 13:16:30 +02:00
|
|
|
|
if test x$FAST = x1 ; then
|
|
|
|
|
if test $TEST_TYPE = daemon ; then
|
|
|
|
|
VARIANTS=3
|
|
|
|
|
else
|
|
|
|
|
VARIANTS=4
|
|
|
|
|
fi
|
|
|
|
|
EXETEST="$(( ${RANDOM:-`date +%N | sed s/^0*//`} % $VARIANTS ))"
|
|
|
|
|
echo "Execute tests: $EXETEST"
|
|
|
|
|
fi
|
|
|
|
|
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if test $TEST_TYPE = daemon ; then
|
2014-08-23 12:55:59 +02:00
|
|
|
|
sh -c '
|
|
|
|
|
echo $$ > tests/shell/daemon_pid
|
2014-08-29 21:21:19 +02:00
|
|
|
|
$PYTHON ./scripts/powerline-daemon -s$ADDRESS -f >tests/shell/daemon_log 2>&1
|
2014-08-23 12:55:59 +02:00
|
|
|
|
' &
|
2014-08-06 15:18:42 +02:00
|
|
|
|
fi
|
2014-08-23 01:28:51 +02:00
|
|
|
|
echo "> Testing $TEST_TYPE"
|
2014-08-23 13:16:30 +02:00
|
|
|
|
I=-1
|
2014-08-23 12:55:59 +02:00
|
|
|
|
for POWERLINE_COMMAND in \
|
2015-02-14 23:25:25 +01:00
|
|
|
|
powerline \
|
|
|
|
|
powerline-render \
|
|
|
|
|
powerline.py \
|
|
|
|
|
powerline.sh
|
2014-08-23 01:28:51 +02:00
|
|
|
|
do
|
|
|
|
|
case "$POWERLINE_COMMAND" in
|
2015-02-14 23:25:25 +01:00
|
|
|
|
powerline) TEST_CLIENT=C ;;
|
|
|
|
|
powerline-render) TEST_CLIENT=render ;;
|
|
|
|
|
powerline.py) TEST_CLIENT=python ;;
|
|
|
|
|
powerline.sh) TEST_CLIENT=shell ;;
|
2014-08-23 01:28:51 +02:00
|
|
|
|
esac
|
2015-02-14 23:25:25 +01:00
|
|
|
|
check_test_client "$POWERLINE_COMMAND" $TEST_CLIENT
|
2014-08-23 13:16:30 +02:00
|
|
|
|
if test "$TEST_CLIENT" = render && test "$TEST_TYPE" = daemon ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
I="$(( I + 1 ))"
|
2014-08-23 02:43:17 +02:00
|
|
|
|
if test "$TEST_CLIENT" = "C" && ! test -x scripts/powerline ; then
|
|
|
|
|
if which powerline >/dev/null ; then
|
|
|
|
|
POWERLINE_COMMAND=powerline
|
|
|
|
|
else
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2015-02-20 21:16:01 +01:00
|
|
|
|
if test "$TEST_CLIENT" = "shell" && ! test -x tests/shell/path/socat ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2014-08-24 14:59:03 +02:00
|
|
|
|
if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2015-01-07 13:07:27 +01:00
|
|
|
|
POWERLINE_COMMAND_ARGS="--socket $ADDRESS"
|
|
|
|
|
POWERLINE_COMMAND="$POWERLINE_COMMAND"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
export POWERLINE_COMMAND
|
|
|
|
|
echo ">> powerline command is ${POWERLINE_COMMAND:-empty}"
|
2014-08-23 13:16:30 +02:00
|
|
|
|
J=-1
|
2014-08-23 01:28:51 +02:00
|
|
|
|
for TEST_COMMAND in \
|
|
|
|
|
"bash --norc --noprofile -i" \
|
|
|
|
|
"zsh -f -i" \
|
|
|
|
|
"fish -i" \
|
|
|
|
|
"tcsh -f -i" \
|
|
|
|
|
"busybox ash -i" \
|
|
|
|
|
"mksh -i" \
|
2015-01-07 23:46:16 +01:00
|
|
|
|
"dash -i" \
|
|
|
|
|
"rc -i -p"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
do
|
2014-08-23 13:16:30 +02:00
|
|
|
|
J="$(( J + 1 ))"
|
|
|
|
|
if test x$FAST = x1 ; then
|
|
|
|
|
if test $(( (I + J) % $VARIANTS )) -ne $EXETEST ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2014-08-23 01:28:51 +02:00
|
|
|
|
SH="${TEST_COMMAND%% *}"
|
2014-08-23 14:02:04 +02:00
|
|
|
|
# dash tests are not stable, see #931
|
|
|
|
|
if test x$FAST$SH = x1dash ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if test "x$ONLY_SHELL" != "x" && test "x$ONLY_SHELL" != "x$SH" ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
2015-01-07 23:46:16 +01:00
|
|
|
|
if ! test -x tests/shell/path/$SH ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2015-01-07 23:46:16 +01:00
|
|
|
|
echo ">>> $(readlink "tests/shell/path/$SH")"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if ! run_test $TEST_TYPE $TEST_CLIENT $TEST_COMMAND ; then
|
2014-08-23 14:02:04 +02:00
|
|
|
|
FAILED=1
|
2014-11-28 21:02:12 +01:00
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T ${TEST_TYPE} ${TEST_CLIENT} ${TEST_COMMAND}"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
if test $TEST_TYPE = daemon ; then
|
2014-08-23 12:55:59 +02:00
|
|
|
|
$PYTHON ./scripts/powerline-daemon -s$ADDRESS -k
|
2014-08-06 15:18:42 +02:00
|
|
|
|
wait $(cat tests/shell/daemon_pid)
|
|
|
|
|
if ! test -z "$(cat tests/shell/daemon_log)" ; then
|
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
echo "Daemon log:"
|
|
|
|
|
echo '============================================================'
|
|
|
|
|
cat tests/shell/daemon_log
|
|
|
|
|
FAILED=1
|
2014-11-28 21:02:12 +01:00
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}L ${TEST_TYPE} ${TEST_CLIENT} ${TEST_COMMAND}"
|
2014-08-06 15:18:42 +02:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2014-09-08 21:53:05 +02:00
|
|
|
|
if $PYTHON scripts/powerline-daemon -s$ADDRESS > tests/shell/daemon_log_2 2>&1 ; then
|
2014-08-23 01:52:09 +02:00
|
|
|
|
sleep 1
|
2014-08-23 12:55:59 +02:00
|
|
|
|
$PYTHON scripts/powerline-daemon -s$ADDRESS -k
|
2014-09-08 21:53:05 +02:00
|
|
|
|
else
|
|
|
|
|
echo "Daemon exited with status $?"
|
|
|
|
|
FAILED=1
|
2014-11-28 21:02:12 +01:00
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}D"
|
2014-08-23 01:52:09 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! test -z "$(cat tests/shell/daemon_log_2)" ; then
|
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
echo "Daemon log (2nd):"
|
|
|
|
|
echo '============================================================'
|
|
|
|
|
cat tests/shell/daemon_log_2
|
|
|
|
|
FAILED=1
|
2014-11-28 21:02:12 +01:00
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}L"
|
2014-08-23 01:52:09 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2015-01-02 01:43:57 +01:00
|
|
|
|
if ( test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xzsh" ) \
|
|
|
|
|
&& ( test "x${ONLY_TEST_TYPE}" = "x" || test "x${ONLY_TEST_TYPE}" = "xzpython" ) \
|
|
|
|
|
&& zsh -f -c 'zmodload libzpython' 2>/dev/null; then
|
|
|
|
|
echo "> zpython"
|
|
|
|
|
if ! run_test zpython zpython zsh -f -i ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T zpython zsh -f -i"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2015-01-31 16:10:19 +01:00
|
|
|
|
if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xpdb" ; then
|
2015-01-31 15:58:14 +01:00
|
|
|
|
if ! ( test "$PYTHON_IMPLEMENTATION" = "PyPy" && test "$PYTHON_VERSION_MAJOR" = 2 ) ; then
|
2015-01-31 16:10:19 +01:00
|
|
|
|
if test "x${ONLY_TEST_TYPE}" = "x" || test "x${ONLY_TEST_TYPE}" = "xsubclass" ; then
|
|
|
|
|
echo "> pdb subclass"
|
|
|
|
|
if ! run_test subclass python $PDB_PYTHON "$PWD/tests/test_shells/pdb-main.py" ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T pdb $PDB_PYTHON $PWD/tests/test_shells/pdb-main.py"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if test "x${ONLY_TEST_TYPE}" = "x" || test "x${ONLY_TEST_TYPE}" = "xmodule" ; then
|
|
|
|
|
echo "> pdb module"
|
2015-01-31 19:32:16 +01:00
|
|
|
|
MODULE="powerline.bindings.pdb"
|
|
|
|
|
if test "$PYTHON_MM" = "2.6" ; then
|
|
|
|
|
MODULE="powerline.bindings.pdb.__main__"
|
|
|
|
|
fi
|
|
|
|
|
if ! run_test module python $PDB_PYTHON -m$MODULE "$PWD/tests/test_shells/pdb-script.py" ; then
|
2015-01-31 16:10:19 +01:00
|
|
|
|
FAILED=1
|
2015-01-31 19:32:16 +01:00
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T pdb $PDB_PYTHON -m$MODULE $PWD/tests/test_shells/pdb-script"
|
2015-01-31 16:10:19 +01:00
|
|
|
|
fi
|
2015-01-31 15:58:14 +01:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then
|
2014-08-23 14:24:16 +02:00
|
|
|
|
if which ipython >/dev/null ; then
|
2015-01-07 14:24:48 +01:00
|
|
|
|
# Define some overrides which should be ignored by IPython.
|
|
|
|
|
POWERLINE_CONFIG_OVERRIDES='common.term_escape_style=fbterm'
|
|
|
|
|
POWERLINE_THEME_OVERRIDES='in.segments.left=[]'
|
2014-08-23 14:24:16 +02:00
|
|
|
|
echo "> $(which ipython)"
|
|
|
|
|
if ! run_test ipython ipython ipython ; then
|
|
|
|
|
FAILED=1
|
2014-11-28 21:02:12 +01:00
|
|
|
|
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T ipython"
|
2014-08-23 14:24:16 +02:00
|
|
|
|
fi
|
2015-01-07 14:24:48 +01:00
|
|
|
|
unset POWERLINE_THEME_OVERRIDES
|
|
|
|
|
unset POWERLINE_CONFIG_OVERRIDES
|
2014-08-23 01:28:51 +02:00
|
|
|
|
fi
|
2014-08-06 15:18:42 +02:00
|
|
|
|
fi
|
2014-07-19 23:49:30 +02:00
|
|
|
|
|
2014-11-28 21:02:12 +01:00
|
|
|
|
if test $FAILED -eq 0 ; then
|
|
|
|
|
rm -r tests/shell
|
|
|
|
|
else
|
|
|
|
|
echo "${FAIL_SUMMARY}"
|
|
|
|
|
fi
|
2014-01-11 10:16:25 +01:00
|
|
|
|
exit $FAILED
|