@@ -820,22 +820,29 @@ unit-tests: requirements .unit-tests
820820 @echo
821821 @echo " ----- Dropping st2-test db -----"
822822 @mongosh st2-test --eval " db.dropDatabase();"
823- @failed=0 ; \
823+ @failed=() ; \
824824 for component in $( COMPONENTS_TEST) ; do\
825- echo " ===========================================================" ; \
826- echo " Running tests in" $$ component; \
827- echo " -----------------------------------------------------------" ; \
828- . $(VIRTUALENV_DIR ) /bin/activate; \
829- ST2TESTS_REDIS_HOST=$(ST2TESTS_REDIS_HOST ) \
830- ST2TESTS_REDIS_PORT=$(ST2TESTS_REDIS_PORT ) \
831- pytest -rx --verbose \
832- $$ component/tests/unit || (( failed+= 1 )) ; \
833- echo " -----------------------------------------------------------" ; \
834- echo " Done running tests in" $$ component; \
835- echo " ===========================================================" ; \
825+ if ls $$ component/tests/unit/test_* .py 2> /dev/null > /dev/null; then \
826+ echo " ===========================================================" ; \
827+ echo " Running tests in" $$ component; \
828+ echo " -----------------------------------------------------------" ; \
829+ . $(VIRTUALENV_DIR ) /bin/activate; \
830+ ST2TESTS_REDIS_HOST=$(ST2TESTS_REDIS_HOST ) \
831+ ST2TESTS_REDIS_PORT=$(ST2TESTS_REDIS_PORT ) \
832+ pytest -rx --verbose $$ component/tests/unit; \
833+ RET=$$? ; \
834+ test $$ RET -eq 0 || failed+=($$ component); \
835+ echo " -----------------------------------------------------------" ; \
836+ echo " Done running tests in $$ component ($$ RET)" ; \
837+ echo " ===========================================================" ; \
838+ else \
839+ echo " ===========================================================" ; \
840+ echo " Skip: no test files for $$ component" ; \
841+ echo " ===========================================================" ; \
842+ fi ; \
836843 done ; \
837- echo pytest runs failed=$$ failed; \
838- if [ $$ failed -gt 0 ]; then exit 1; fi
844+ echo " pytest runs failed=$$ { failed[@]} " ; \
845+ if [[ $$ { # failed[@]} -gt 0 ] ]; then exit 1; fi
839846
840847.PHONY : .run-unit-tests-coverage
841848ifdef INCLUDE_TESTS_IN_COVERAGE
0 commit comments