From 484d62549fb94750bf2ff4d9a3c9984ca011d8f3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 14 Oct 2024 13:01:33 -0400 Subject: [PATCH] Fix test commands defined as list that result in an empty command when verbosity is enabled Signed-off-by: Jean-Christophe Morin --- docs/source/package_definition.rst | 3 ++- src/rez/package_test.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/source/package_definition.rst b/docs/source/package_definition.rst index b4ad4ab3d..80e2cb8d1 100644 --- a/docs/source/package_definition.rst +++ b/docs/source/package_definition.rst @@ -854,13 +854,14 @@ the data type, and includes a code snippet. tests = { "unit": "python -m unittest discover -s {root}/python/tests", + "unit-as-list": ["python", "-m", "unittest", "discover", "-s", "{root}/python/tests"], "lint": { "command": "pylint mymodule", "requires": ["pylint"], "run_on": ["default", "pre_release"] }, "maya_CI": { - "command": "python {root}/ci_tests/maya.py", + "command": ["python", "{root}/ci_tests/maya.py"], "on_variants": { "type": "requires", "value": ["maya"] diff --git a/src/rez/package_test.py b/src/rez/package_test.py index 3c85882d1..f0ad9d133 100644 --- a/src/rez/package_test.py +++ b/src/rez/package_test.py @@ -394,7 +394,9 @@ def run_test(self, test_name, extra_test_args=None): if isinstance(command, str): command = variant.format(command) else: - command = map(variant.format, command) + # Note that we convert the iterator to a list to + # make sure that we can consume the variable more than once. + command = [x for x in map(variant.format, command)] if extra_test_args: if isinstance(command, str):