tests/Makefile: allow control over tags during check-acceptance

Although it is possible to run a specific test using the avocado
command-line, a user may want to use a specific tag while running the
``make check-acceptance`` during the development or debugging.

This allows using the AVOCADO_TAGS environment variable where the user
takes total control of which tests should run based on the tags defined.

This also makes the check-acceptance command flexible to restrict tests
based on tags while running on CI.

e.g.:

AVOCADO_TAGS="foo bar baz" make check-acceptance

Signed-off-by: Willian Rampazzo <willianr@redhat.com>
Tested-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210923161141.232208-2-willianr@redhat.com>
This commit is contained in:
Willian Rampazzo 2021-09-23 13:11:39 -03:00 committed by Philippe Mathieu-Daudé
parent e519df437a
commit 23022794de
2 changed files with 23 additions and 3 deletions

View File

@ -732,6 +732,20 @@ available. On Debian and Ubuntu based systems, depending on the
specific version, they may be on packages named ``python3-venv`` and specific version, they may be on packages named ``python3-venv`` and
``python3-pip``. ``python3-pip``.
It is also possible to run tests based on tags using the
``make check-acceptance`` command and the ``AVOCADO_TAGS`` environment
variable:
.. code::
make check-acceptance AVOCADO_TAGS=quick
Note that tags separated with commas have an AND behavior, while tags
separated by spaces have an OR behavior. For more information on Avocado
tags, see:
https://avocado-framework.readthedocs.io/en/latest/guides/user/chapters/tags.html
The scripts installed inside the virtual environment may be used The scripts installed inside the virtual environment may be used
without an "activation". For instance, the Avocado test runner without an "activation". For instance, the Avocado test runner
may be invoked by running: may be invoked by running:

View File

@ -92,7 +92,12 @@ TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
# Any number of command separated loggers are accepted. For more # Any number of command separated loggers are accepted. For more
# information please refer to "avocado --help". # information please refer to "avocado --help".
AVOCADO_SHOW=app AVOCADO_SHOW=app
AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) ifndef AVOCADO_TAGS
AVOCADO_CMDLINE_TAGS=$(patsubst %-softmmu,-t arch:%, \
$(filter %-softmmu,$(TARGETS)))
else
AVOCADO_CMDLINE_TAGS=$(addprefix -t , $(AVOCADO_TAGS))
endif
$(TESTS_VENV_DIR): $(TESTS_VENV_REQ) $(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
$(call quiet-command, \ $(call quiet-command, \
@ -128,8 +133,9 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
$(call quiet-command, \ $(call quiet-command, \
$(TESTS_VENV_DIR)/bin/python -m avocado \ $(TESTS_VENV_DIR)/bin/python -m avocado \
--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
--filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \
$(AVOCADO_TAGS) \ --filter-by-tags-include-empty-key) \
$(AVOCADO_CMDLINE_TAGS) \
$(if $(GITLAB_CI),,--failfast) tests/acceptance, \ $(if $(GITLAB_CI),,--failfast) tests/acceptance, \
"AVOCADO", "tests/acceptance") "AVOCADO", "tests/acceptance")