diff --git a/ynh-dev b/ynh-dev index 8f2c50c..4c17186 100755 --- a/ynh-dev +++ b/ynh-dev @@ -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