Skip to content

Commit

Permalink
Support for environment variables 'TESTCASES' and 'TESTOPTS'
Browse files Browse the repository at this point in the history
Details:

* Added support for environment variables 'TESTCASES' for specifying testcases
  for the unit test, and 'TESTOPTS' for specifying pytest options. (issue #461)

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Feb 22, 2024
1 parent dcfc5eb commit 262177f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ endif
safety_install_policy_file := .safety-policy-install.yml
safety_all_policy_file := .safety-policy-all.yml

ifdef TESTCASES
pytest_opts := $(TESTOPTS) -k "$(TESTCASES)"
else
pytest_opts := $(TESTOPTS)
endif

pytest_cov_opts := --cov $(package_name) --cov-config .coveragerc --cov-append --cov-report=html:htmlcov
pytest_cov_files := .coveragerc

Expand Down Expand Up @@ -183,6 +189,8 @@ help:
@echo " platform - Display the information about the platform as seen by make"
@echo " env - Display the environment as seen by make"
@echo 'Environment variables:'
@echo " TESTCASES=... - Testcase filter for pytest -k"
@echo " TESTOPTS=... - Additional options for pytest"
@echo " PACKAGE_LEVEL - Package level to be used for installing dependent Python"
@echo " packages in 'install' and 'develop' targets:"
@echo " latest - Latest package versions available on Pypi"
Expand Down Expand Up @@ -285,7 +293,7 @@ endif
test: $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(pytest_cov_files)
@echo "Makefile: Performing unit tests and coverage with PACKAGE_LEVEL=$(PACKAGE_LEVEL)"
@echo "Makefile: Note that the warning about an unknown metric is part of the tests"
pytest $(pytest_cov_opts) -s $(test_dir)
pytest $(pytest_cov_opts) -s $(test_dir) $(pytest_opts)
@echo "Makefile: Done performing unit tests and coverage"
@echo "Makefile: $@ done."

Expand Down
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ will also work with the prior version of the file (but not vice versa).
and 'logical-partition-resource' (only returned for SE versions between
2.14.0+MCLs and 2.15.0)

* Added support for environment variables 'TESTCASES' for specifying testcases
for the unit test, and 'TESTOPTS' for specifying pytest options. (issue #461)

**Cleanup:**

* Increased versions of GitHub Actions plugins to increase node.js runtime
Expand Down
3 changes: 3 additions & 0 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ You can perform unit tests with:
$ make test
The environment variables ``TESTCASES`` and ``TESTOPTS`` can be specified for
unit tests. Invoke ``make help`` for details.

You can perform a flake8 check with:

.. code-block:: bash
Expand Down

0 comments on commit 262177f

Please sign in to comment.