1
0
Fork 0
mirror of https://github.com/YunoHost/ynh-dev.git synced 2024-09-03 20:05:59 +02:00

Merge pull request from alexAubin/select-tests

Be able to selects which tests to run
This commit is contained in:
ljf (zamentur) 2018-12-15 17:26:42 +01:00 committed by GitHub
commit 09457ad9dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

29
ynh-dev
View file

@ -17,6 +17,8 @@ function show_usage() {
ip Give the ip of the guest container
use-git [PKG] Use Git repositories from dev environment path
test [PKG] Deploy, update and run tests for some packages
Tests for single modules and functions can ran with
e.g. ./ynh-dev test yunohost/appurl:urlavailable
EOF
}
@ -270,10 +272,14 @@ function run_tests()
local PACKAGES="$@"
for PACKAGE in "$PACKAGES";
do
TEST_FUNCTION=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $3}')
TEST_MODULE=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $2}')
PACKAGE=$(echo "$PACKAGE" | tr '/:' ' ' | awk '{print $1}')
case $PACKAGE in
yunohost)
# Pytest and tests dependencies
if ! type "pytest" > /dev/null; then
if ! type "pytest" > /dev/null 2>&1; then
info "> Installing pytest ..."
apt-get install python-pip -y
pip2 install pytest
@ -293,12 +299,23 @@ function run_tests()
git pull > /dev/null 2>&1
# Run tests
info "Running tests for YunoHost ..."
info "Running tests for YunoHost"
[ -e "/etc/yunohost/installed" ] || critical "You should run postinstallation before running tests :s."
cd /ynh-dev/yunohost/
py.test tests
cd /ynh-dev/yunohost/src/yunohost
py.test tests
if [[ -z "$TEST_MODULE" ]]
then
cd /ynh-dev/yunohost/
py.test tests
cd /ynh-dev/yunohost/src/yunohost
py.test tests
else
cd /ynh-dev/yunohost/src/yunohost
if [[ -z "$TEST_FUNCTION" ]]
then
py.test tests/test_"$TEST_MODULE".py
else
py.test tests/test_"$TEST_MODULE".py::test_"$TEST_FUNCTION"
fi
fi
;;
esac
done