Move tests/run_*_tests.sh to tests/test_*/test.sh

Warning: this also makes shell tests run.
This commit is contained in:
Foo 2017-04-30 22:36:00 +03:00
parent 0fc96abce2
commit 1303cd1b04
12 changed files with 60 additions and 85 deletions

View File

@ -1,40 +0,0 @@
#!/bin/sh
. tests/shlib/common.sh
enter_suite daemon
export ADDRESS="powerline-ipc-test-$$"
echo "Powerline address: $ADDRESS"
if $PYTHON scripts/powerline-daemon -s$ADDRESS ; then
sleep 1
if ! ( \
$PYTHON client/powerline.py --socket $ADDRESS -p/dev/null shell left | \
grep 'file not found'
) ; then
fail "devnull" F "-p/dev/null argument ignored or not treated properly"
fi
if ( \
$PYTHON client/powerline.py --socket $ADDRESS \
-p$PWD/powerline/config_files shell left | \
grep 'file not found'
) ; then
fail "nodevnull" F "-p/dev/null argument remembered while it should not"
fi
if ! ( \
cd tests && \
$PYTHON ../client/powerline.py --socket $ADDRESS \
-p$PWD/../powerline/config_files shell left | \
grep 'tests'
) ; then
fail "segment" F "Output lacks string “tests”"
fi
else
fail "exitcode" E "Daemon exited with status $?"
fi
if $PYTHON scripts/powerline-daemon -s$ADDRESS -k ; then
:
else
fail "-k" F "powerline-daemon -k failed with exit code $?"
fi
exit_suite

View File

@ -1,8 +0,0 @@
#!/bin/sh
exit 0
FAILED=0
if ! sh tests/test_shells/test.sh --fast ; then
echo "Failed shells"
FAILED=1
fi
exit $FAILED

View File

@ -2,6 +2,10 @@
set +x
: ${PYTHON:=python}
: ${USER:=`id -un`}
: ${HOME:=`getent passwd $USER | cut -d: -f6`}
export USER HOME
if test -z "$FAILED" ; then
FAILED=0
@ -69,3 +73,9 @@ rm_tmp_dir() {
rm -r "$TMP_ROOT"
fi
}
if ! which realpath ; then
realpath() {
$PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
}
fi

View File

@ -3,11 +3,6 @@
enter_suite root
: ${USER:=`id -un`}
: ${HOME:=`getent passwd $USER | cut -d: -f6`}
export USER HOME
if test "$TRAVIS" = true ; then
export PATH="$HOME/opt/fish/bin:${PATH}"
export PATH="$PWD/tests/bot-ci/deps/rc:$PATH"
@ -25,15 +20,9 @@ if test "$TRAVIS" = true ; then
fi
fi
if ! which realpath ; then
realpath() {
$PYTHON -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "$1"
}
fi
export PYTHON="${PYTHON:=python}"
export PYTHONPATH="${PYTHONPATH}${PYTHONPATH:+:}`realpath .`"
for script in tests/run_*_tests.sh ; do
for script in "$ROOT"/tests/test_*/test.sh ; do
test_name="${script##*/run_}"
if ! sh $script ; then
fail "${test_name%_tests.sh}" F "Failed $script"

View File

@ -3,12 +3,10 @@
enter_suite awesome
TEST_ROOT="$ROOT/tests/awesome"
TEST_ROOT="$(make_tmp_dir awesome)"
TEST_PATH="$TEST_ROOT/path"
TEST_STATIC_ROOT="$ROOT/tests/test_awesome"
test -d "$TEST_ROOT" && rm -r "$TEST_ROOT"
mkdir "$TEST_ROOT"
cp -r "$TEST_STATIC_ROOT/path" "$TEST_ROOT"
cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT"
@ -186,8 +184,4 @@ then
fail "lint" F "Checking test config failed"
fi
if test $FAILED -eq 0 ; then
rm -r "$TEST_ROOT"
fi
exit_suite

View File

@ -3,12 +3,10 @@
enter_suite bar
TEST_ROOT="$ROOT/tests/bar"
TEST_ROOT="$(make_tmp_dir bar)"
TEST_PATH="$TEST_ROOT/path"
TEST_STATIC_ROOT="$ROOT/tests/test_bar"
test -d "$TEST_ROOT" && rm -r "$TEST_ROOT"
mkdir "$TEST_ROOT"
cp -r "$TEST_STATIC_ROOT/path" "$TEST_ROOT"
cp -r "$TEST_STATIC_ROOT/powerline" "$TEST_ROOT"
@ -194,8 +192,4 @@ then
fail "lint" F "Checking test config failed"
fi
if test $FAILED -eq 0 ; then
rm -r "$TEST_ROOT"
fi
exit_suite

41
tests/test_daemon/test.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
. tests/shlib/common.sh
enter_suite daemon
export ADDRESS="powerline-ipc-test-$$"
echo "Powerline address: $ADDRESS"
if "$PYTHON" "$ROOT/scripts/powerline-daemon" -s"$ADDRESS" ; then
sleep 1
if ! ( \
"$PYTHON" "$ROOT/client/powerline.py" \
--socket "$ADDRESS" -p/dev/null shell left \
| grep "file not found"
) ; then
fail "devnull" F "-p/dev/null argument ignored or not treated properly"
fi
if ( \
"$PYTHON" "$ROOT/client/powerline.py" --socket "$ADDRESS" \
-p"$ROOT/powerline/config_files" shell left \
| grep "file not found"
) ; then
fail "nodevnull" F "-p/dev/null argument remembered while it should not"
fi
if ! ( \
cd "$ROOT/tests/test_daemon" \
&& "$PYTHON" "$ROOT/client/powerline.py" --socket "$ADDRESS" \
-p"$ROOT/powerline/config_files" shell left \
| grep "test_daemon"
) ; then
fail "segment" F "Output lacks string “tests”"
fi
else
fail "exitcode" E "Daemon exited with status $?"
fi
if "$PYTHON" "$ROOT/scripts/powerline-daemon" -s"$ADDRESS" -k ; then
:
else
fail "-k" F "powerline-daemon -k failed with exit code $?"
fi
exit_suite

View File

@ -3,9 +3,9 @@
enter_suite vterm
for t in tests/test_in_vterm/test_*.sh ; do
for t in "$ROOT"/tests/test_in_vterm/test_*.sh ; do
test_name="${t##*/test_}"
if ! sh "$t" ; then
if ! "$t" ; then
fail "${test_name%.sh}" F "Failed running $t"
fi
done

View File

@ -3,7 +3,7 @@
enter_suite lint
if ! ${PYTHON} scripts/powerline-lint -p powerline/config_files ; then
if ! "$PYTHON" "$ROOT/scripts/powerline-lint" -p "$ROOT/powerline/config_files" ; then
fail "test" F "Running powerline-lint failed"
fi

View File

@ -3,9 +3,9 @@
enter_suite python
for file in tests/test_python/test_*.py ; do
for file in "$ROOT"/tests/test_python/test_*.py ; do
test_name="${file##*/test_}"
if ! ${PYTHON} $file --verbose --catch ; then
if ! "$PYTHON" "$file" --verbose --catch ; then
fail "${test_name%.py}" F "Failed test(s) from $file"
fi
done

View File

@ -3,18 +3,13 @@
enter_suite shells
if test "x$1" = "x--fast" ; then
if test $# -eq 0 ; then
FAST=1
shift
fi
ONLY_SHELL="$1"
ONLY_TEST_TYPE="$2"
ONLY_TEST_CLIENT="$3"
if ! test -z "$ONLY_SHELL$ONLY_TEST_TYPE$ONLY_TEST_CLIENT" ; then
FAST=
fi
export PYTHON
if test "x$ONLY_SHELL" = "x--help" ; then