tests/acceptance: allow control over tags during check-acceptance
PATCH 1/1 tests/acceptance: 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 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.:
TAGS="foo bar baz" make check-acceptance
--- docs/devel/testing.rst | 7 +++++++ tests/Makefile.include | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
docs/devel/testing.rst +7 -0
@@ -760,6 +760,13 @@ in the current directory, tagged as "quick", run: avocado run -t quick . +It is also possible to run tests based on tags using the +``make check-acceptance`` command and the ``TAGS`` environment variable: + +.. code:: + + TAGS=quick make check-acceptance + The ``avocado_qemu.Test`` base test class -----------------------------------------
tests/Makefile.include +8 -2
@@ -92,7 +92,11 @@ TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help". AVOCADO_SHOW=app -AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) +ifndef TAGS + AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) +else + AVOCADO_TAGS=$(addprefix -t , $(TAGS)) +endif $(TESTS_VENV_DIR): $(TESTS_VENV_REQ) $(call quiet-command, \
@@ -125,10 +129,12 @@ get-vm-image-fedora-31-%: check-venv get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD)) check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images + @echo "AVOCADO_TAGS $(AVOCADO_TAGS)" $(call quiet-command, \ $(TESTS_VENV_DIR)/bin/python -m avocado \ --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ - --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ + $(if $(TAGS),, --filter-by-tags-include-empty \ + --filter-by-tags-include-empty-key) \ $(AVOCADO_TAGS) \ $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ "AVOCADO", "tests/acceptance")
Signature · 1 line
2.31.1
Quoted 7 lines · Willian Rampazzo
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 TAGS environment variable where the user takes total control of which tests should run based on the tags defined.
Quoted 6 lines
This also makes the check-acceptance command flexible to restrict tests based on tags while running on CI.
e.g.:
TAGS="foo bar baz" make check-acceptance
I'm worried 'TAGS' is a bit too generic... Maybe rename AVOCADO_TAGS -> AVOCADO_CMDLINE_TAGS and TAGS -> AVOCADO_TAGS?
Quoted 56 lines
Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 7 +++++++ tests/Makefile.include | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)docs/devel/testing.rst +7
-0@@ -760,6 +760,13 @@ in the current directory, tagged as "quick", run: avocado run -t quick . +It is also possible to run tests based on tags using the +``make check-acceptance`` command and the ``TAGS`` environment variable: + +.. code:: + + TAGS=quick make check-acceptance + The ``avocado_qemu.Test`` base test class -----------------------------------------tests/Makefile.include +8
-2@@ -92,7 +92,11 @@ TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help". AVOCADO_SHOW=app -AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) +ifndef TAGS + AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) +else + AVOCADO_TAGS=$(addprefix -t , $(TAGS)) +endif $(TESTS_VENV_DIR): $(TESTS_VENV_REQ) $(call quiet-command, \@@ -125,10 +129,12 @@ get-vm-image-fedora-31-%: check-venv get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD)) check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images + @echo "AVOCADO_TAGS $(AVOCADO_TAGS)" $(call quiet-command, \ $(TESTS_VENV_DIR)/bin/python -m avocado \ --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ - --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ + $(if $(TAGS),, --filter-by-tags-include-empty \ + --filter-by-tags-include-empty-key) \ $(AVOCADO_TAGS) \ $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ "AVOCADO", "tests/acceptance")
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Willian Rampazzo
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 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.
Quoted 7 lines
Quoted 3 lines
e.g.:
TAGS="foo bar baz" make check-acceptance
I'm worried 'TAGS' is a bit too generic... Maybe rename
AVOCADO_TAGS->AVOCADO_CMDLINE_TAGSand TAGS ->AVOCADO_TAGS?
I'm fine with those changes.
Quoted 58 lines
Quoted 57 lines
Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 7 +++++++ tests/Makefile.include | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)docs/devel/testing.rst +7
-0@@ -760,6 +760,13 @@ in the current directory, tagged as "quick", run: avocado run -t quick . +It is also possible to run tests based on tags using the +``make check-acceptance`` command and the ``TAGS`` environment variable: + +.. code:: + + TAGS=quick make check-acceptance + The ``avocado_qemu.Test`` base test class -----------------------------------------tests/Makefile.include +8
-2@@ -92,7 +92,11 @@ TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help". AVOCADO_SHOW=app -AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) +ifndef TAGS + AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) +else + AVOCADO_TAGS=$(addprefix -t , $(TAGS)) +endif $(TESTS_VENV_DIR): $(TESTS_VENV_REQ) $(call quiet-command, \@@ -125,10 +129,12 @@ get-vm-image-fedora-31-%: check-venv get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD)) check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images + @echo "AVOCADO_TAGS $(AVOCADO_TAGS)" $(call quiet-command, \ $(TESTS_VENV_DIR)/bin/python -m avocado \ --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ - --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ + $(if $(TAGS),, --filter-by-tags-include-empty \ + --filter-by-tags-include-empty-key) \ $(AVOCADO_TAGS) \ $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ "AVOCADO", "tests/acceptance")