@@ -19,6 +19,12 @@ COLLECTION_VERSION ?= $(shell $(PYTHON) tools/scripts/scm_version.py | cut -d .
1919COLLECTION_SANITY_ARGS ?= --docker
2020# collection unit testing directories
2121COLLECTION_TEST_DIRS ?= awx_collection/test/awx
22+ # pytest added args to collect coverage
23+ COVERAGE_ARGS ?= --cov=awx --cov-report=xml --junitxml=reports/junit.xml --no-cov-on-fail
24+ # pytest test directories
25+ TEST_DIRS ?= awx/main/tests/unit awx/main/tests/functional awx/conf/tests
26+ # pytest args to run tests in parallel
27+ PARALLEL_TESTS ?= -n auto
2228# collection integration test directories (defaults to all)
2329COLLECTION_TEST_TARGET ?=
2430# args for collection install
@@ -316,7 +322,7 @@ swagger: reports
316322 @if [ " $( VENV_BASE) " ]; then \
317323 . $(VENV_BASE ) /awx/bin/activate; \
318324 fi ; \
319- (set -o pipefail && py.test --cov --cov-report=xml --junitxml=reports/junit.xml $( PYTEST_ARGS ) awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs | tee reports/$@ .report)
325+ (set -o pipefail && py.test $( COVERAGE_ARGS ) $( PARALLEL_TESTS ) awx/conf/tests/functional awx/main/tests/functional/api awx/main/tests/docs | tee reports/$@ .report)
320326 @if [ " ${GITHUB_ACTIONS} " = " true" ]; \
321327 then \
322328 echo ' cov-report-files=reports/coverage.xml' >> " ${GITHUB_OUTPUT} " ; \
@@ -334,14 +340,12 @@ api-lint:
334340awx-link :
335341 [ -d " /awx_devel/awx.egg-info" ] || $(PYTHON ) /awx_devel/tools/scripts/egg_info_dev
336342
337- TEST_DIRS ?= awx/main/tests/unit awx/main/tests/functional awx/conf/tests
338- PYTEST_ARGS ?= -n auto
339343# # Run all API unit tests.
340344test :
341345 if [ " $( VENV_BASE) " ]; then \
342346 . $(VENV_BASE ) /awx/bin/activate; \
343347 fi ; \
344- PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider $(PYTEST_ARGS ) $(TEST_DIRS )
348+ PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider $(PARALLEL_TESTS ) $(TEST_DIRS )
345349 cd awxkit && $(VENV_BASE ) /awx/bin/tox -re py3
346350 awx-manage check_migrations --dry-run --check -n ' missing_migration_file'
347351
@@ -350,15 +354,15 @@ live_test:
350354
351355# # Run all API unit tests with coverage enabled.
352356test_coverage :
353- $(MAKE ) test PYTEST_ARGS=" --create-db --cov --cov-report=xml --junitxml=reports/junit.xml "
357+ $(MAKE ) test PYTEST_ARGS=" --create-db $( COVERAGE_ARGS ) "
354358 @if [ " ${GITHUB_ACTIONS} " = " true" ]; \
355359 then \
356360 echo ' cov-report-files=awxkit/coverage.xml,reports/coverage.xml' >> " ${GITHUB_OUTPUT} " ; \
357361 echo ' test-result-files=awxkit/report.xml,reports/junit.xml' >> " ${GITHUB_OUTPUT} " ; \
358362 fi
359363
360364test_migrations :
361- PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider --migrations -m migration_test --create-db --cov=awx --cov-report=xml --junitxml=reports/junit.xml $( PYTEST_ARGS ) $(TEST_DIRS )
365+ PYTHONDONTWRITEBYTECODE=1 py.test -p no:cacheprovider --migrations -m migration_test --create-db $( PARALLEL_TESTS ) $( COVERAGE_ARGS ) $(TEST_DIRS )
362366 @if [ " ${GITHUB_ACTIONS} " = " true" ]; \
363367 then \
364368 echo ' cov-report-files=reports/coverage.xml' >> " ${GITHUB_OUTPUT} " ; \
@@ -376,7 +380,7 @@ test_collection:
376380 fi && \
377381 if ! [ -x " $( shell command -v ansible-playbook) " ]; then pip install ansible-core; fi
378382 ansible --version
379- py.test $(COLLECTION_TEST_DIRS ) --cov --cov-report=xml --junitxml=reports/junit.xml -v
383+ py.test $(COLLECTION_TEST_DIRS ) $( COVERAGE_ARGS ) -v
380384 @if [ " ${GITHUB_ACTIONS} " = " true" ]; \
381385 then \
382386 echo ' cov-report-files=reports/coverage.xml' >> " ${GITHUB_OUTPUT} " ; \
0 commit comments