docs/devel/testing: improvements on make check-acceptance
cover docs/devel/testing: improvements on make check-acceptance
Improve the documentation about how to run a single test within a file or all the tests from a file using the standalone avocado command.
Add a way to run specific tests using the make check-acceptance command.
GitLab pipeline: https://gitlab.com/willianrampazzo/qemu/-/pipelines/375486996
Willian Rampazzo (2):
docs/devel/testing: add instruction to run a single acceptance test tests/Makefile: add TESTFILES option to make check-acceptance
docs/devel/testing.rst | 41 +++++++++++++++++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 45 insertions(+), 1 deletion(-)
Signature · 1 line
2.31.1
PATCH 1/2 docs/devel/testing: add instruction to run a single acceptance test
Add instructions to the Acceptance tests section about running a single test file or a test within the test file.
--- docs/devel/testing.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
docs/devel/testing.rst +14 -0
@@ -740,6 +740,20 @@ may be invoked by running: tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/acceptance/ +It is also possible to run tests from a single file or a single test +within a test file. To run tests from a single file within the build +tree, use: + + .. code:: + + tests/venv/bin/avocado run tests/acceptance/$TESTFILE + +To run a single test within a test file, use: + + .. code:: + + tests/venv/bin/avocado run tests/acceptance/$TESTFILE:$TESTCLASS.$TESTNAME + Manual Installation -------------------
Signature · 1 line
2.31.1
Re: [PATCH 1/2] docs/devel/testing: add instruction to run a single acceptance test
Quoted 13 lines · Willian Rampazzo
Add instructions to the Acceptance tests section about running a single test file or a test within the test file.
Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+)docs/devel/testing.rst +0
-0
docs/devel/testing.rst may be invoked by running: · line 749
Quoted 10 lines
docs/devel/testing.rst +7
-0@@ -740,6 +740,20 @@ may be invoked by running: tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/acceptance/ +It is also possible to run tests from a single file or a single test +within a test file. To run tests from a single file within the build +tree, use: + + .. code:: + + tests/venv/bin/avocado run tests/acceptance/$TESTFILE
Before running this users may well need to run
make check-venv
we can't assume they have previously done "make check-acceptance" as they're possibly just reproducing a failure from gitlab CI locally, not running the whole suite.
docs/devel/testing.rst may be invoked by running: · line 756
Quoted 7 lines
docs/devel/testing.rst +7
-0+ +To run a single test within a test file, use: + + .. code:: + + tests/venv/bin/avocado run tests/acceptance/$TESTFILE:$TESTCLASS.$TESTNAME +
Valid test names are visible in the output from any previous execution of avocado, and can also be queried using
tests/venv/bin/avocado list tests/acceptance
Quoted 6 lines
docs/devel/testing.rst +0
-0Manual Installation -------------------Signature · 1 line
2.31.1
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/2] docs/devel/testing: add instruction to run a single acceptance test
Quoted 28 lines · Daniel P. Berrangé
Quoted 13 lines · Willian Rampazzo
Add instructions to the Acceptance tests section about running a single test file or a test within the test file.
Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+)docs/devel/testing.rst +0
-0docs/devel/testing.rst may be invoked by running: · line 749
Quoted 10 lines
docs/devel/testing.rst +7
-0@@ -740,6 +740,20 @@ may be invoked by running: tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/acceptance/ +It is also possible to run tests from a single file or a single test +within a test file. To run tests from a single file within the build +tree, use: + + .. code:: + + tests/venv/bin/avocado run tests/acceptance/$TESTFILEBefore running this users may well need to run
Quoted 5 lines
make check-venv
we can't assume they have previously done "make check-acceptance" as they're possibly just reproducing a failure from gitlab CI locally, not running the whole suite.
Indeed!
Quoted 12 lines
docs/devel/testing.rst may be invoked by running: · line 756
Quoted 8 lines
docs/devel/testing.rst +7
-0+ +To run a single test within a test file, use: + + .. code:: + + tests/venv/bin/avocado run tests/acceptance/$TESTFILE:$TESTCLASS.$TESTNAME +Valid test names are visible in the output from any previous execution of avocado, and can also be queried using
Quoted 2 lines
tests/venv/bin/avocado list tests/acceptance
Ack.
Quoted 14 lines
Quoted 6 lines
docs/devel/testing.rst +0
-1Manual Installation ------------------- --2.31.1
Regards,
Daniel
--|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 2/2 tests/Makefile: add TESTFILES option to make check-acceptance
In reply to Willian RampazzoAdd the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using make check-acceptance and the TESTFILES environment variable.
--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)
docs/devel/testing.rst +27 -0
@@ -732,6 +732,33 @@ available. On Debian and Ubuntu based systems, depending on the specific version, they may be on packages named ``python3-venv`` and ``python3-pip``. +To run a single test file, a couple of them, or a test within a file +using the ``make check-acceptance`` command, set the ``TESTFILES`` +environment variable with the test files or test names. To run all +tests from a single file, use: + + .. code:: + + make check-acceptance TESTFILES=$FILEPATH + +The same is valid to run tests from multiple test files: + + .. code:: + + make check-acceptance TESTFILES='$FILEPATH1 $FILEPATH2' + +To run a single test within a file, use: + + .. code:: + + make check-acceptance TESTFILES=$FILEPATH:$TESTCLASS.$TESTNAME + +The same is valid to run single tests from multiple test files: + + .. code:: + + make check-acceptance TESTFILES='$FILEPATH1:$TESTCLASS1.$TESTNAME1 $FILEPATH2:$TESTCLASS2.$TESTNAME2' + The scripts installed inside the virtual environment may be used without an "activation". For instance, the Avocado test runner may be invoked by running:
tests/Makefile.include +4 -1
@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".
@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \ "AVOCADO", "tests/acceptance") # Consolidated targets
Signature · 1 line
2.31.1
Re: [PATCH 2/2] tests/Makefile: add TESTFILES option to make check-acceptance
Quoted 26 lines · Willian Rampazzo
Add the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using
make check-acceptanceand the TESTFILES environment variable.Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)tests/Makefile.include +3
-0@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".
tests/Makefile.include check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images · line 136
Quoted 5 lines
tests/Makefile.include +1
-1@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \
Since this is Avocado specific, maybe call the variable AVOCADO_TESTFILES (similar to AVOCADO_TAGS)?
Quoted 4 lines
tests/Makefile.include +0
-0"AVOCADO", "tests/acceptance") # Consolidated targets
Re: [PATCH 2/2] tests/Makefile: add TESTFILES option to make check-acceptance
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Willian Rampazzo
Add the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using
make check-acceptanceand the TESTFILES environment variable.Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)tests/Makefile.include +3
-0@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
Quoted 8 lines
tests/Makefile.include check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images · line 136
Quoted 5 lines
tests/Makefile.include +1
-1--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \Since this is Avocado specific, maybe call the variable
AVOCADO_TESTFILES(similar toAVOCADO_TAGS)?
I don't see a problem with changing that to AVOCADO_TESTFILES. I was trying to make things shorter and easy to remember. If the too-long variable name is not a problem, I can change that.
Quoted 6 lines
Quoted 5 lines
tests/Makefile.include +0
-0"AVOCADO", "tests/acceptance") # Consolidated targets
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH 2/2] tests/Makefile: add TESTFILES option to make check-acceptance
Quoted 39 lines · Willian Rampazzo
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Willian Rampazzo
Add the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using
make check-acceptanceand the TESTFILES environment variable.Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)tests/Makefile.include +3
-0@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-imagesQuoted 8 lines
tests/Makefile.include check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images · line 136
Quoted 5 lines
tests/Makefile.include +1
-1--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \Since this is Avocado specific, maybe call the variable
AVOCADO_TESTFILES(similar toAVOCADO_TAGS)?
Quoted 3 lines
I don't see a problem with changing that to
AVOCADO_TESTFILES. I was trying to make things shorter and easy to remember. If the too-long variable name is not a problem, I can change that.
This is the generic tests/Makefile, so $TESTFILES might be confusing, which is why I prefer the explicit AVOCADO_ prefix (AVOCADO_SHOW, AVOCADO_TAGS).
Thomas, do you have a preference?
Otherwise:
Re: [PATCH 2/2] tests/Makefile: add TESTFILES option to make check-acceptance
Quoted 40 lines · Philippe Mathieu-Daudé
Quoted 39 lines · Willian Rampazzo
Quoted 36 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Willian Rampazzo
Add the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using
make check-acceptanceand the TESTFILES environment variable.Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)tests/Makefile.include +3
-0@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".tests/Makefile.include check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images · line 136
Quoted 5 lines
tests/Makefile.include +1
-1@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \Since this is Avocado specific, maybe call the variable
AVOCADO_TESTFILES(similar toAVOCADO_TAGS)?
Quoted 7 lines
Quoted 3 lines
I don't see a problem with changing that to
AVOCADO_TESTFILES. I was trying to make things shorter and easy to remember. If the too-long variable name is not a problem, I can change that.This is the generic tests/Makefile, so $TESTFILES might be confusing, which is why I prefer the explicit
AVOCADO_prefix (AVOCADO_SHOW,AVOCADO_TAGS).
IIUC, this is not actually just test files - it is test files plus the test names. So better just $(AVOCADO_TESTS)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 2/2] tests/Makefile: add TESTFILES option to make check-acceptance
Quoted 45 lines · Daniel P. Berrangé
Quoted 44 lines · Philippe Mathieu-Daudé
Quoted 42 lines · Willian Rampazzo
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Willian Rampazzo
Add the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using
make check-acceptanceand the TESTFILES environment variable.Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)tests/Makefile.include +3
-0@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-imagesQuoted 8 lines
tests/Makefile.include check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images · line 136
Quoted 5 lines
tests/Makefile.include +1
-1--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \Since this is Avocado specific, maybe call the variable
AVOCADO_TESTFILES(similar toAVOCADO_TAGS)?I don't see a problem with changing that to
AVOCADO_TESTFILES. I was trying to make things shorter and easy to remember. If the too-long variable name is not a problem, I can change that.
Quoted 6 lines
Quoted 3 lines
This is the generic tests/Makefile, so $TESTFILES might be confusing, which is why I prefer the explicit
AVOCADO_prefix (AVOCADO_SHOW,AVOCADO_TAGS).IIUC, this is not actually just test files - it is test files plus the test names. So better just $(AVOCADO_TESTS)
Good point, I agree.
Re: [PATCH 2/2] tests/Makefile: add TESTFILES option to make check-acceptance
In reply to Daniel P. BerrangéQuoted 46 lines · Daniel P. Berrangé
Quoted 44 lines · Philippe Mathieu-Daudé
Quoted 42 lines · Willian Rampazzo
Quoted 28 lines · Philippe Mathieu-Daudé
Quoted 26 lines · Willian Rampazzo
Add the possibility of running all the tests from a single file, or multiple files, running a single test within a file or multiple tests within multiple files using
make check-acceptanceand the TESTFILES environment variable.Signed-off-by Willian Rampazzo <[email protected]>--- docs/devel/testing.rst | 27 +++++++++++++++++++++++++++ tests/Makefile.include | 5 ++++- 2 files changed, 31 insertions(+), 1 deletion(-)tests/Makefile.include +3
-0@@ -88,6 +88,9 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES) TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results +ifndef TESTFILES + TESTFILES=tests/acceptance +endif # Controls the output generated by Avocado when running tests. # Any number of command separated loggers are accepted. For more # information please refer to "avocado --help".@@ -130,7 +133,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-imagesQuoted 8 lines
tests/Makefile.include check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images · line 136
Quoted 5 lines
tests/Makefile.include +1
-1--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \ $(AVOCADO_TAGS) \ - $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ + $(if $(GITLAB_CI),,--failfast) $(TESTFILES), \Since this is Avocado specific, maybe call the variable
AVOCADO_TESTFILES(similar toAVOCADO_TAGS)?I don't see a problem with changing that to
AVOCADO_TESTFILES. I was trying to make things shorter and easy to remember. If the too-long variable name is not a problem, I can change that.
Quoted 7 lines
Quoted 3 lines
This is the generic tests/Makefile, so $TESTFILES might be confusing, which is why I prefer the explicit
AVOCADO_prefix (AVOCADO_SHOW,AVOCADO_TAGS).IIUC, this is not actually just test files - it is test files plus the test names. So better just $(AVOCADO_TESTS)
Ack. I'll send another version soon.
Quoted 8 lines
Regards,
Daniel
--|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|