2014-07-19 23:49:30 +02:00
|
|
|
|
#!/bin/bash
|
2014-01-11 10:16:25 +01:00
|
|
|
|
FAILED=0
|
2014-01-23 04:36:08 +01:00
|
|
|
|
ONLY_SHELL="$1"
|
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"
|
|
|
|
|
SH="$2"
|
|
|
|
|
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
|
|
|
|
|
return $?
|
|
|
|
|
elif test -e tests/test_shells/${SH}.ok ; then
|
|
|
|
|
diff -a -u tests/test_shells/${SH}.ok tests/shell/${SH}.${TEST_TYPE}.log
|
2014-01-22 05:33:43 +01:00
|
|
|
|
return $?
|
|
|
|
|
else
|
2014-08-02 19:02:26 +02:00
|
|
|
|
cat tests/shell/${SH}.${TEST_TYPE}.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() {
|
|
|
|
|
local local_path="$PWD/tests/shell/path:$PWD/scripts"
|
|
|
|
|
if test "x$SH" = "xfish" ; then
|
|
|
|
|
local_path="${local_path}:/usr/bin:/bin"
|
|
|
|
|
fi
|
|
|
|
|
env -i \
|
|
|
|
|
PATH="$local_path" \
|
|
|
|
|
TERM="${TERM}" \
|
|
|
|
|
COLUMNS="${COLUMNS}" \
|
|
|
|
|
LINES="${LINES}" \
|
|
|
|
|
TEST_TYPE="${TEST_TYPE}" \
|
|
|
|
|
SH="${SH}" \
|
|
|
|
|
DIR1="${DIR1}" \
|
|
|
|
|
DIR2="${DIR2}" \
|
|
|
|
|
XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \
|
|
|
|
|
IPYTHONDIR="$PWD/tests/shell/ipython_home" \
|
|
|
|
|
"$@"
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-12 21:53:38 +01:00
|
|
|
|
run_test() {
|
2014-08-02 19:02:26 +02:00
|
|
|
|
TEST_TYPE="$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-07-19 23:49:30 +02:00
|
|
|
|
ARGS=( "$@" )
|
2014-01-23 04:36:08 +01:00
|
|
|
|
|
|
|
|
|
test "x$ONLY_SHELL" = "x" || test "x$ONLY_SHELL" = "x$SH" || return 0
|
|
|
|
|
|
2014-07-19 23:49:30 +02:00
|
|
|
|
if ! which "${SH}" ; then
|
|
|
|
|
if test "x${SH}" = "xbb" ; then
|
|
|
|
|
if ! which busybox ; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
shift
|
|
|
|
|
ARGS=( busybox ash "$@" )
|
|
|
|
|
else
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2014-01-23 15:33:33 +01:00
|
|
|
|
|
2014-08-02 19:02:26 +02:00
|
|
|
|
export TEST_TYPE
|
2014-01-26 18:30:01 +01:00
|
|
|
|
export SH
|
|
|
|
|
|
2014-08-10 14:01:03 +02:00
|
|
|
|
run screen -L -c tests/test_shells/screenrc -d -m -S "$SESNAME" \
|
2014-07-19 23:49:30 +02:00
|
|
|
|
env LANG=en_US.UTF-8 BINDFILE="$BINDFILE" "${ARGS[@]}"
|
2014-01-12 22:07:13 +01:00
|
|
|
|
screen -S "$SESNAME" -X readreg a tests/test_shells/input.$SH
|
2014-01-17 18:34:18 +01:00
|
|
|
|
# Wait for screen to initialize
|
2014-07-19 23:49:30 +02:00
|
|
|
|
sleep 1
|
2014-01-12 21:53:38 +01:00
|
|
|
|
screen -S "$SESNAME" -p 0 -X width 300 1
|
2014-07-19 23:49:30 +02:00
|
|
|
|
if test "x${SH}" = "xdash" ; 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
|
|
|
|
|
screen -S "$SESNAME" -p 0 -X stuff "$line"$'\n'
|
|
|
|
|
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-08-02 19:02:26 +02:00
|
|
|
|
./tests/test_shells/postproc.py ${TEST_TYPE} ${SH}
|
|
|
|
|
if ! check_screen_log ${TEST_TYPE} ${SH} ; then
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo '____________________________________________________________'
|
2014-01-17 18:34:18 +01:00
|
|
|
|
# Repeat the diff to make it better viewable in travis output
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo "Diff (cat -v):"
|
|
|
|
|
echo '============================================================'
|
2014-08-02 19:02:26 +02:00
|
|
|
|
check_screen_log ${TEST_TYPE} ${SH} | cat -v
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
echo "Failed ${SH}. Full output:"
|
|
|
|
|
echo '============================================================'
|
2014-08-02 19:02:26 +02:00
|
|
|
|
cat tests/shell/${SH}.${TEST_TYPE}.full.log
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo '____________________________________________________________'
|
|
|
|
|
echo "Full output (cat -v):"
|
|
|
|
|
echo '============================================================'
|
2014-08-02 19:02:26 +02:00
|
|
|
|
cat -v tests/shell/${SH}.${TEST_TYPE}.full.log
|
2014-01-23 12:58:52 +01:00
|
|
|
|
echo '____________________________________________________________'
|
2014-07-19 23:49:30 +02:00
|
|
|
|
case ${SH} in
|
|
|
|
|
*ksh)
|
|
|
|
|
${SH} -c 'echo ${KSH_VERSION}'
|
|
|
|
|
;;
|
|
|
|
|
dash)
|
|
|
|
|
# ?
|
|
|
|
|
;;
|
|
|
|
|
bb)
|
|
|
|
|
bb --help
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
${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
|
|
|
|
}
|
|
|
|
|
|
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-01-11 10:31:57 +01:00
|
|
|
|
|
2014-01-23 13:14:32 +01:00
|
|
|
|
mkdir tests/shell/fish_home
|
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
|
|
|
|
|
ln -s "$(which "${PYTHON:-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
|
|
|
|
|
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
|
|
|
|
|
for pexe in powerline powerline-config ; do
|
|
|
|
|
if test -e scripts/$pexe ; then
|
|
|
|
|
ln -s "$PWD/scripts/$pexe" tests/shell/path
|
|
|
|
|
elif which $pexe ; then
|
|
|
|
|
ln -s "$(which $pexe)" tests/shell/path
|
|
|
|
|
else
|
|
|
|
|
echo "Executable $pexe was not found"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
for exe in bash zsh bb busybox fish tcsh mksh dash ipython ; do
|
|
|
|
|
if which $exe >/dev/null ; then
|
|
|
|
|
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-10 13:59:32 +02:00
|
|
|
|
if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || test "x${ONLY_SHELL}" = xbb ; then
|
2014-08-06 15:18:42 +02:00
|
|
|
|
powerline-daemon -k || true
|
|
|
|
|
sleep 1s
|
2014-07-19 23:49:30 +02:00
|
|
|
|
|
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
|
|
|
|
|
if test $TEST_TYPE == daemon ; then
|
|
|
|
|
sh -c 'echo $$ > tests/shell/daemon_pid; ./scripts/powerline-daemon -f &>tests/shell/daemon_log' &
|
|
|
|
|
fi
|
|
|
|
|
if ! run_test $TEST_TYPE bash --norc --noprofile -i ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-07-19 23:49:30 +02:00
|
|
|
|
|
2014-08-06 15:18:42 +02:00
|
|
|
|
if ! run_test $TEST_TYPE zsh -f -i ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-08-02 19:02:26 +02:00
|
|
|
|
|
2014-08-06 15:18:42 +02:00
|
|
|
|
if ! run_test $TEST_TYPE fish -i ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-08-02 19:02:26 +02:00
|
|
|
|
|
2014-08-06 15:18:42 +02:00
|
|
|
|
if ! run_test $TEST_TYPE tcsh -f -i ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-08-02 19:02:26 +02:00
|
|
|
|
|
2014-08-06 15:18:42 +02:00
|
|
|
|
if ! run_test $TEST_TYPE bb -i ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-08-02 19:02:26 +02:00
|
|
|
|
|
2014-08-06 15:18:42 +02:00
|
|
|
|
if ! run_test $TEST_TYPE mksh -i ; then
|
2014-08-02 20:03:22 +02:00
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-08-06 15:18:42 +02:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! run_test ipython ipython ; then
|
|
|
|
|
FAILED=1
|
|
|
|
|
fi
|
2014-07-19 23:49:30 +02:00
|
|
|
|
|
2014-08-10 14:00:00 +02:00
|
|
|
|
test $FAILED -eq 0 && rm -r tests/shell
|
2014-01-11 10:16:25 +01:00
|
|
|
|
exit $FAILED
|