From 7de1bc750da2096e2b01ebd1fd305b59afafc30e Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 18 2024 23:23:59 +0000 Subject: tests: Add argument --toxenv to run-tests-container.py. Run tests with tox against all environments defined in tox.ini by default. Customizable by the new argument. Passes the value to the '-e' argument of 'tox'. --- diff --git a/dev/containers/tox_py3.sh b/dev/containers/tox_py3.sh index 68755b0..291a930 100644 --- a/dev/containers/tox_py3.sh +++ b/dev/containers/tox_py3.sh @@ -23,4 +23,10 @@ git --no-pager log -2 fi export LANG="en_US.UTF-8" -tox -v -e "${PYVER:-py39}" -- ${TESTCASE:-tests/} + +echo TOXENV: "${TOXENV}" +if [ -z "${TOXENV}" ]; then + tox -v -- ${TESTCASE:-tests/} +else + tox -v -e "${TOXENV}" -- ${TESTCASE:-tests/} +fi diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 29ace6c..3b5ab22 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -112,6 +112,13 @@ def setup_parser(): "test_case", nargs="?", default="", help="Run the given test case" ) parser.add_argument( + "--toxenv", + default="", + help="Pass a custom value for the target python environment to tox tests. " + "Only used by the pip test container. " + "Default: Use all Environments defined in tox.ini", + ) + parser.add_argument( "--fedora", action="store_true", help="Run the tests in fedora environment (DEFAULT)", @@ -145,7 +152,6 @@ def setup_parser(): help="Gives you a shell into the container instead " "of running the tests", ) - parser.add_argument( "--repo", dest="repo", @@ -301,6 +307,8 @@ if __name__ == "__main__": "REPO={}".format(os.environ.get("REPO") or args.repo), "-e", "TESTCASE={}".format(args.test_case or ""), + "-e", + "TOXENV={}".format(os.environ.get("TOXENV") or args.toxenv), ] if args.shell: