From 7b0cd76b2e2e36e41464f43e4b77e022238068db Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 12 Dec 2018 18:23:55 +0000 Subject: [PATCH 1/3] Be able to selects which tests to run --- ynh-dev | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ynh-dev b/ynh-dev index db693be..1e92cef 100755 --- a/ynh-dev +++ b/ynh-dev @@ -270,10 +270,17 @@ function run_tests() local PACKAGES="$@" for PACKAGE in "$PACKAGES"; do + local TEST_MODULE="" + if [[ "$PACKAGE" == *"/"* ]] + then + TEST_MODULE=$(echo "$PACKAGE" | awk -F'/' '{print $2}') + PACKAGE=$(echo "$PACKAGE" | awk -F'/' '{print $1}') + fi + 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 @@ -294,10 +301,16 @@ function run_tests() # Run tests echo "Running tests for YunoHost" - 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 + py.test tests/test_"$TEST_MODULE".py + fi ;; esac done From 19e7fae061b7df4f5f17d573e253d406758092a3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 15 Dec 2018 16:13:22 +0000 Subject: [PATCH 2/3] Be able to test specific functions --- ynh-dev | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ynh-dev b/ynh-dev index 6287767..9ff6142 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,12 +272,9 @@ function run_tests() local PACKAGES="$@" for PACKAGE in "$PACKAGES"; do - local TEST_MODULE="" - if [[ "$PACKAGE" == *"/"* ]] - then - TEST_MODULE=$(echo "$PACKAGE" | awk -F'/' '{print $2}') - PACKAGE=$(echo "$PACKAGE" | awk -F'/' '{print $1}') - fi + 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) @@ -310,7 +309,12 @@ function run_tests() py.test tests else cd /ynh-dev/yunohost/src/yunohost - py.test tests/test_"$TEST_MODULE".py + 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 From 56b5fbcaedb4bcedcfad8b88815656e735805791 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Sat, 15 Dec 2018 17:24:38 +0100 Subject: [PATCH 3/3] Update ynh-dev --- ynh-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ynh-dev b/ynh-dev index 9ff6142..853a38c 100755 --- a/ynh-dev +++ b/ynh-dev @@ -299,7 +299,7 @@ function run_tests() git pull > /dev/null 2>&1 # Run tests - echo "Running tests for YunoHost" + info "Running tests for YunoHost" [ -e "/etc/yunohost/installed" ] || critical "You should run postinstallation before running tests :s." if [[ -z "$TEST_MODULE" ]] then