2014-08-23 13:18:00 +02:00
|
|
|
|
#!/bin/sh
|
2017-04-30 14:49:46 +02:00
|
|
|
|
. tests/shlib/common.sh
|
2015-08-22 16:18:35 +02:00
|
|
|
|
|
2018-02-25 20:16:05 +01:00
|
|
|
|
enter_suite shell final
|
2015-01-31 15:58:14 +01:00
|
|
|
|
|
2017-04-30 21:36:00 +02:00
|
|
|
|
if test $# -eq 0 ; then
|
2014-08-23 13:16:30 +02:00
|
|
|
|
FAST=1
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
export PYTHON
|
|
|
|
|
|
2017-05-01 00:28:44 +02:00
|
|
|
|
if test "$ONLY_SHELL" = "--help" ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
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"
|
2017-05-01 00:49:32 +02:00
|
|
|
|
if test -e "$ROOT/tests/test_shells/outputs/${SH}.${TEST_TYPE}.ok" ; then
|
|
|
|
|
diff -a -u "$ROOT/tests/test_shells/outputs/${SH}.${TEST_TYPE}.ok" \
|
|
|
|
|
"$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log"
|
2014-08-02 19:02:26 +02:00
|
|
|
|
return $?
|
2017-05-01 00:49:32 +02:00
|
|
|
|
elif test -e "$ROOT/tests/test_shells/outputs/${SH}.ok" ; then
|
|
|
|
|
diff -a -u "$ROOT/tests/test_shells/outputs/${SH}.ok" \
|
|
|
|
|
"$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log"
|
2014-01-22 05:33:43 +01:00
|
|
|
|
return $?
|
|
|
|
|
else
|
2017-04-30 23:00:45 +02:00
|
|
|
|
cat "$TEST_ROOT/${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-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-02-20 23:29:10 +01:00
|
|
|
|
print_full_output() {
|
|
|
|
|
TEST_TYPE="$1"
|
|
|
|
|
TEST_CLIENT="$2"
|
|
|
|
|
SH="$3"
|
|
|
|
|
echo "Full output:"
|
|
|
|
|
echo '============================================================'
|
2017-04-30 23:00:45 +02:00
|
|
|
|
cat "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log"
|
2015-02-21 00:21:11 +01:00
|
|
|
|
echo
|
2015-02-20 23:29:10 +01:00
|
|
|
|
echo '____________________________________________________________'
|
2017-05-01 00:28:44 +02:00
|
|
|
|
if test "$POWERLINE_TEST_NO_CAT_V" != "1" ; then
|
2015-02-20 23:29:10 +01:00
|
|
|
|
echo "Full output (cat -v):"
|
|
|
|
|
echo '============================================================'
|
2017-04-30 23:00:45 +02:00
|
|
|
|
cat -v "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.full.log"
|
2015-02-21 00:21:11 +01:00
|
|
|
|
echo
|
2015-02-20 23:29:10 +01:00
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2015-02-21 11:56:25 +01:00
|
|
|
|
local wait_for_echo_arg=
|
2014-11-29 19:40:06 +01:00
|
|
|
|
if ( \
|
2017-05-01 00:28:44 +02:00
|
|
|
|
test "${SH}" = "dash" \
|
2015-01-31 15:58:14 +01:00
|
|
|
|
|| ( \
|
2017-05-01 00:28:44 +02:00
|
|
|
|
test "${SH}" = "pdb" \
|
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
|
|
|
|
) \
|
2016-07-09 04:22:16 +02:00
|
|
|
|
|| ( \
|
2017-05-01 00:28:44 +02:00
|
|
|
|
test "${SH}" = "ipython" \
|
2016-07-09 04:22:16 +02:00
|
|
|
|
&& test "$("${PYTHON}" -mIPython --version | head -n1 | cut -d. -f1)" -ge 5 \
|
|
|
|
|
) \
|
2014-11-29 19:40:06 +01:00
|
|
|
|
) ; then
|
2015-02-21 11:56:25 +01:00
|
|
|
|
wait_for_echo_arg="--wait-for-echo"
|
2014-07-19 23:49:30 +02:00
|
|
|
|
fi
|
2015-02-21 11:56:25 +01:00
|
|
|
|
"${PYTHON}" tests/test_shells/run_script.py \
|
|
|
|
|
$wait_for_echo_arg --type=${TEST_TYPE} --client=${TEST_CLIENT} --shell=${SH} \
|
|
|
|
|
"$@"
|
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 '____________________________________________________________'
|
2017-05-01 00:28:44 +02:00
|
|
|
|
if test "$POWERLINE_TEST_NO_CAT_V" != "1" ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
# 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
|
2015-02-20 23:29:10 +01:00
|
|
|
|
echo -n "Failed ${SH}. "
|
|
|
|
|
print_full_output ${TEST_TYPE} ${TEST_CLIENT} ${SH}
|
2017-04-30 23:00:45 +02:00
|
|
|
|
case "${SH}" in
|
2014-07-19 23:49:30 +02:00
|
|
|
|
*ksh)
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"$TEST_ROOT/path/${SH}" -c 'echo ${KSH_VERSION}'
|
2014-07-19 23:49:30 +02:00
|
|
|
|
;;
|
|
|
|
|
dash)
|
|
|
|
|
# ?
|
|
|
|
|
;;
|
2014-07-28 01:15:36 +02:00
|
|
|
|
busybox)
|
|
|
|
|
busybox --help
|
2014-07-19 23:49:30 +02:00
|
|
|
|
;;
|
|
|
|
|
*)
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"$TEST_ROOT/path/${SH}" --version
|
2014-07-19 23:49:30 +02:00
|
|
|
|
;;
|
|
|
|
|
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
|
2017-04-30 23:00:45 +02:00
|
|
|
|
rm -f "$TEST_ROOT/${SH}.${TEST_TYPE}.${TEST_CLIENT}.log"
|
|
|
|
|
rm -f "$TEST_ROOT/${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
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
make_test_root
|
|
|
|
|
|
|
|
|
|
git init "$TEST_ROOT/3rd"
|
|
|
|
|
git --git-dir="$TEST_ROOT/3rd/.git" checkout -b BRANCH
|
2014-01-26 18:59:33 +01:00
|
|
|
|
export DIR1="[32m"
|
|
|
|
|
export DIR2=""
|
2017-04-30 23:00:45 +02:00
|
|
|
|
mkdir "$TEST_ROOT/3rd/$DIR1"
|
|
|
|
|
mkdir "$TEST_ROOT/3rd/$DIR2"
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'\[\]'
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'%%'
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'#[bold]'
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'(echo)'
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'$(echo)'
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'`echo`'
|
|
|
|
|
mkdir "$TEST_ROOT"/3rd/'«Unicode!»'
|
|
|
|
|
|
|
|
|
|
mkdir "$TEST_ROOT/fish_home"
|
|
|
|
|
mkdir "$TEST_ROOT/fish_home/fish"
|
|
|
|
|
mkdir "$TEST_ROOT/fish_home/fish/generated_completions"
|
|
|
|
|
cp -r "$ROOT/tests/test_shells/ipython_home" "$TEST_ROOT"
|
|
|
|
|
|
|
|
|
|
mkdir "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which "${PYTHON}")" "$TEST_ROOT/path/python"
|
|
|
|
|
ln -s "$(which env)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which git)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which sleep)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which cat)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which false)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which true)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which kill)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which echo)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which which)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which dirname)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which wc)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which stty)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which cut)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which bc)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which expr)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which mktemp)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which grep)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which sed)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which rm)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which tr)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which uname)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which test)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which pwd)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$(which hostname)" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$ROOT/tests/test_shells/bgscript.sh" "$TEST_ROOT/path"
|
|
|
|
|
ln -s "$ROOT/tests/test_shells/waitpid.sh" "$TEST_ROOT/path"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if which socat ; then
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s "$(which socat)" "$TEST_ROOT/path"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
fi
|
2015-02-14 23:25:25 +01:00
|
|
|
|
for pexe in powerline powerline-config powerline-render powerline.sh powerline.py ; do
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test -e "$ROOT/scripts/$pexe" ; then
|
|
|
|
|
ln -s "$ROOT/scripts/$pexe" "$TEST_ROOT/path"
|
2015-02-14 23:25:25 +01:00
|
|
|
|
elif test -e client/$pexe ; then
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s "$ROOT/client/$pexe" "$TEST_ROOT/path"
|
2014-08-10 14:01:03 +02:00
|
|
|
|
elif which $pexe ; then
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s "$(which $pexe)" "$TEST_ROOT/path"
|
2014-08-10 14:01:03 +02:00
|
|
|
|
else
|
|
|
|
|
echo "Executable $pexe was not found"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s python "$TEST_ROOT/path/pdb"
|
2015-01-31 15:58:14 +01:00
|
|
|
|
PDB_PYTHON=pdb
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s python "$TEST_ROOT/path/ipython"
|
2015-02-21 13:54:44 +01:00
|
|
|
|
IPYTHON_PYTHON=ipython
|
2015-01-31 15:58:14 +01:00
|
|
|
|
|
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
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s "$(which $POWERLINE_RC_EXE)" "$TEST_ROOT/path/rc"
|
2015-01-07 23:46:16 +01:00
|
|
|
|
fi
|
|
|
|
|
|
2017-04-30 23:41:14 +02:00
|
|
|
|
exes="bash zsh busybox tcsh mksh"
|
|
|
|
|
|
2017-05-01 00:45:07 +02:00
|
|
|
|
if test "$TRAVIS" != "true" ; then
|
2017-04-30 23:41:14 +02:00
|
|
|
|
# For some reason fish does not work on travis
|
|
|
|
|
exes="$exes fish"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# dash has some problems with job control
|
|
|
|
|
#exes="$exes dash"
|
|
|
|
|
|
|
|
|
|
for exe in $exes ; 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%%.*}"
|
2015-02-20 22:08:12 +01:00
|
|
|
|
if test "$fish_version_major" != "$fish_version" ; then
|
|
|
|
|
# No dot is in development version compiled by bot-ci
|
|
|
|
|
fish_version_minor="${fish_version#*.}"
|
|
|
|
|
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
|
|
|
|
|
fish_version_minor="${fish_version_minor%%.*}"
|
|
|
|
|
fish_version_patch="${fish_version_patch%%-*}"
|
|
|
|
|
if test $fish_version_major -lt 2 || ( \
|
|
|
|
|
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:37:13 +01:00
|
|
|
|
) \
|
2015-02-20 22:08:12 +01:00
|
|
|
|
) ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
2015-02-20 21:16:01 +01:00
|
|
|
|
fi
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
ln -s "$(which $exe)" "$TEST_ROOT/path"
|
2014-08-10 14:01:03 +02:00
|
|
|
|
fi
|
|
|
|
|
done
|
2014-01-13 16:47:58 +01:00
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
mkdir "$TEST_ROOT/home"
|
|
|
|
|
export HOME="$TEST_ROOT/home"
|
2015-02-21 01:32:26 +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"
|
2017-04-30 23:00:45 +02:00
|
|
|
|
local actual_mime_type="$(
|
|
|
|
|
file --mime-type --brief --dereference "$TEST_ROOT/path/$executable" \
|
|
|
|
|
| cut -d/ -f1
|
|
|
|
|
)"
|
2015-02-14 23:25:25 +01:00
|
|
|
|
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
|
2015-08-22 16:18:35 +02:00
|
|
|
|
fail "MIME-$executable" "M" "Expected $executable to have MIME type $expected_mime_type, but got $actual_mime_type"
|
2015-02-14 23:25:25 +01:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ( \
|
|
|
|
|
test -z "${ONLY_SHELL}" \
|
|
|
|
|
|| test "${ONLY_SHELL%sh}" != "${ONLY_SHELL}" \
|
|
|
|
|
|| test "${ONLY_SHELL}" = "busybox" \
|
|
|
|
|
|| test "${ONLY_SHELL}" = "rc" \
|
|
|
|
|
) ; 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
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test -n "$ONLY_TEST_TYPE" && test "$ONLY_TEST_TYPE" != "$TEST_TYPE"
|
|
|
|
|
then
|
2014-08-29 20:36:32 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test "$FAST" = 1 ; then
|
2014-08-23 13:16:30 +02:00
|
|
|
|
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 '
|
2017-04-30 23:00:45 +02:00
|
|
|
|
echo $$ > "$TEST_ROOT/daemon_pid"
|
|
|
|
|
exec "$PYTHON" ./scripts/powerline-daemon -s"$ADDRESS" -f >"$TEST_ROOT/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 ))"
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test "$TEST_CLIENT" = "C" && ! test -x "$ROOT/scripts/powerline"
|
|
|
|
|
then
|
2014-08-23 02:43:17 +02:00
|
|
|
|
if which powerline >/dev/null ; then
|
|
|
|
|
POWERLINE_COMMAND=powerline
|
|
|
|
|
else
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ( \
|
|
|
|
|
test "$TEST_CLIENT" = "shell" \
|
|
|
|
|
&& ! test -x "$TEST_ROOT/path/socat" \
|
|
|
|
|
) ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ( \
|
|
|
|
|
test -n "$ONLY_TEST_CLIENT" \
|
|
|
|
|
&& test "$TEST_CLIENT" != "$ONLY_TEST_CLIENT" \
|
|
|
|
|
) ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2015-02-21 12:03:34 +01:00
|
|
|
|
export POWERLINE_COMMAND_ARGS="--socket $ADDRESS"
|
|
|
|
|
export POWERLINE_COMMAND="$POWERLINE_COMMAND"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
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 ))"
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test "$FAST" = 1 ; then
|
2014-08-23 13:16:30 +02:00
|
|
|
|
if test $(( (I + J) % $VARIANTS )) -ne $EXETEST ; then
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2014-08-23 01:28:51 +02:00
|
|
|
|
SH="${TEST_COMMAND%% *}"
|
2017-05-01 00:28:44 +02:00
|
|
|
|
if test -n "$ONLY_SHELL" && test "$ONLY_SHELL" != "$SH" ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ! test -x "$TEST_ROOT/path/$SH" ; then
|
2014-08-23 01:28:51 +02:00
|
|
|
|
continue
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
echo ">>> $(readlink "$TEST_ROOT/path/$SH")"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
if ! run_test $TEST_TYPE $TEST_CLIENT $TEST_COMMAND ; then
|
2017-05-01 00:28:44 +02:00
|
|
|
|
fail "$SH-$TEST_TYPE-$TEST_CLIENT:test" F \
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"Failed checking $TEST_COMMAND"
|
2014-08-23 01:28:51 +02:00
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
if test $TEST_TYPE = daemon ; then
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"$PYTHON" ./scripts/powerline-daemon -s"$ADDRESS" -k
|
|
|
|
|
wait $(cat "$TEST_ROOT/daemon_pid")
|
|
|
|
|
if ! test -z "$(cat "$TEST_ROOT/daemon_log")" ; then
|
2014-08-06 15:18:42 +02:00
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
echo "Daemon log:"
|
|
|
|
|
echo '============================================================'
|
2017-04-30 23:00:45 +02:00
|
|
|
|
cat "$TEST_ROOT/daemon_log"
|
|
|
|
|
fail "$SH-$TEST_TYPE-$TEST_CLIENT:log" E \
|
|
|
|
|
"Non-empty daemon log for ${TEST_COMMAND}"
|
2014-08-06 15:18:42 +02:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if "$PYTHON" scripts/powerline-daemon -s"$ADDRESS" \
|
|
|
|
|
> "$TEST_ROOT/daemon_log_2" 2>&1
|
|
|
|
|
then
|
2014-08-23 01:52:09 +02:00
|
|
|
|
sleep 1
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"$PYTHON" scripts/powerline-daemon -s"$ADDRESS" -k
|
2014-09-08 21:53:05 +02:00
|
|
|
|
else
|
2015-08-22 16:18:35 +02:00
|
|
|
|
fail "daemon:run" F "Daemon exited with status $?"
|
2014-08-23 01:52:09 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ! test -z "$(cat "$TEST_ROOT/daemon_log_2")" ; then
|
2014-08-23 01:52:09 +02:00
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
echo "Daemon log (2nd):"
|
|
|
|
|
echo '============================================================'
|
2017-04-30 23:00:45 +02:00
|
|
|
|
cat "$TEST_ROOT/daemon_log_2"
|
2015-08-22 16:18:35 +02:00
|
|
|
|
fail "daemon:log" E "Daemon run with non-empty log"
|
2014-08-23 01:52:09 +02:00
|
|
|
|
fi
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ( test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "zsh" ) \
|
|
|
|
|
&& ( test -z "${ONLY_TEST_TYPE}" || test "${ONLY_TEST_TYPE}" = "zpython" ) \
|
|
|
|
|
&& "$TEST_ROOT/path/zsh" "$ROOT/tests/test_shells/zsh_test_script.zsh"
|
|
|
|
|
then
|
2015-01-02 01:43:57 +01:00
|
|
|
|
echo "> zpython"
|
|
|
|
|
if ! run_test zpython zpython zsh -f -i ; then
|
2015-08-22 16:18:35 +02:00
|
|
|
|
fail "zsh-zpython:test" F "Failed checking zsh -f -i"
|
2015-01-02 01:43:57 +01:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "pdb" ; then
|
2015-02-21 16:53:32 +01:00
|
|
|
|
if test "$PYTHON_IMPLEMENTATION" != "PyPy" ; then
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test -z "${ONLY_TEST_TYPE}" || test "${ONLY_TEST_TYPE}" = "subclass"
|
|
|
|
|
then
|
2015-01-31 16:10:19 +01:00
|
|
|
|
echo "> pdb subclass"
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ! run_test subclass python $PDB_PYTHON \
|
|
|
|
|
"$ROOT/tests/test_shells/pdb-main.py"
|
|
|
|
|
then
|
2017-08-05 13:13:59 +02:00
|
|
|
|
fail --allow-failure "pdb-subclass:test" F \
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"Failed checking $PDB_PYTHON $ROOT/tests/test_shells/pdb-main.py"
|
2015-01-31 16:10:19 +01:00
|
|
|
|
fi
|
|
|
|
|
fi
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test -z "${ONLY_TEST_TYPE}" || test "${ONLY_TEST_TYPE}" = "module" ; then
|
2015-01-31 16:10:19 +01:00
|
|
|
|
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
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if ! run_test module python "$PDB_PYTHON" -m"$MODULE" \
|
|
|
|
|
"$ROOT/tests/test_shells/pdb-script.py"
|
|
|
|
|
then
|
2017-08-05 13:13:59 +02:00
|
|
|
|
fail --allow-failure "pdb-module:test" F \
|
2017-04-30 23:00:45 +02:00
|
|
|
|
"Failed checking $PDB_PYTHON -m$MODULE $ROOT/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
|
|
|
|
|
|
2017-04-30 23:00:45 +02:00
|
|
|
|
if test -z "${ONLY_SHELL}" || test "${ONLY_SHELL}" = "ipython" ; then
|
2015-02-21 13:54:44 +01:00
|
|
|
|
if "${PYTHON}" -c "try: import IPython${NL}except ImportError: raise SystemExit(1)" ; then
|
2015-01-07 14:24:48 +01:00
|
|
|
|
# Define some overrides which should be ignored by IPython.
|
2015-02-21 12:03:34 +01:00
|
|
|
|
export POWERLINE_CONFIG_OVERRIDES='common.term_escape_style=fbterm'
|
|
|
|
|
export POWERLINE_THEME_OVERRIDES='in.segments.left=[]'
|
2015-02-21 15:55:49 +01:00
|
|
|
|
echo "> ipython"
|
2015-02-21 13:54:44 +01:00
|
|
|
|
if ! run_test ipython ipython ${IPYTHON_PYTHON} -mIPython ; then
|
2016-07-09 15:52:54 +02:00
|
|
|
|
# Do not allow ipython tests to spoil the build
|
|
|
|
|
fail --allow-failure "ipython:test" F "Failed checking ${IPYTHON_PYTHON} -mIPython"
|
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
|
|
|
|
|
2015-08-22 16:18:35 +02:00
|
|
|
|
exit_suite
|