From 3aa2b5c8a035ed5cc6351719e14479f5bf71f42b Mon Sep 17 00:00:00 2001 From: Dhruv Govil Date: Sat, 21 Oct 2023 15:22:33 -0700 Subject: [PATCH] Address notes, fix tests Signed-off-by: Dhruv Govil --- src/rez/config.py | 2 +- .../1/package.py | 2 +- src/rez/rezconfig.py | 4 ++-- src/rez/solver.py | 2 +- src/rez/tests/test_completion.py | 2 +- src/rez/tests/test_packages.py | 2 +- src/rez/tests/test_solver.py | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) rename src/rez/data/tests/solver/packages/{missing_variant_package => missing_variant_requires}/1/package.py (71%) diff --git a/src/rez/config.py b/src/rez/config.py index 1f9d56ea5..747b75cc3 100644 --- a/src/rez/config.py +++ b/src/rez/config.py @@ -400,7 +400,7 @@ def _parse_env_var(self, value): "alias_back": OptionalStr, "package_preprocess_function": OptionalStrOrFunction, "package_preprocess_mode": PreprocessMode_, - "error_on_missing_variant_packages": Bool, + "error_on_missing_variant_requires": Bool, "context_tracking_host": OptionalStr, "variant_shortlinks_dirname": OptionalStr, "build_thread_count": BuildThreadCount_, diff --git a/src/rez/data/tests/solver/packages/missing_variant_package/1/package.py b/src/rez/data/tests/solver/packages/missing_variant_requires/1/package.py similarity index 71% rename from src/rez/data/tests/solver/packages/missing_variant_package/1/package.py rename to src/rez/data/tests/solver/packages/missing_variant_requires/1/package.py index 20a06feef..5c505d20d 100644 --- a/src/rez/data/tests/solver/packages/missing_variant_package/1/package.py +++ b/src/rez/data/tests/solver/packages/missing_variant_requires/1/package.py @@ -1,4 +1,4 @@ -name = "missing_variant_package" +name = "missing_variant_requires" version = "1" def commands(): diff --git a/src/rez/rezconfig.py b/src/rez/rezconfig.py index c28fa19ff..8c61661ac 100644 --- a/src/rez/rezconfig.py +++ b/src/rez/rezconfig.py @@ -657,11 +657,11 @@ # - "override": Package's preprocess function completely overrides the global preprocess. package_preprocess_mode = "override" -# Defines whether a resolve should immediately fail if any variants have a package that can't be found. +# Defines whether a resolve should immediately fail if any variants have a required package that can't be found. # It is enabled by default. # If disabled, it will try other variants before giving up. # This can be useful if you have variants that aren't available to all users. -error_on_missing_variant_packages = True +error_on_missing_variant_requires = True ############################################################################### # Context Tracking diff --git a/src/rez/solver.py b/src/rez/solver.py index 9a7c2264b..56830913e 100644 --- a/src/rez/solver.py +++ b/src/rez/solver.py @@ -1385,7 +1385,7 @@ def _create_phase(status=None): requested = ", ".join(requesters) fail_message = "package family not found: {}, was required by: {} (searched: {})".format(req.name, requested, searched) - if not config.error_on_missing_variant_packages: + if not config.error_on_missing_variant_requires: print(fail_message, file=sys.stderr) return _create_phase(SolverStatus.failed) raise PackageFamilyNotFoundError( diff --git a/src/rez/tests/test_completion.py b/src/rez/tests/test_completion.py index f10a976fa..ef8c390c6 100644 --- a/src/rez/tests/test_completion.py +++ b/src/rez/tests/test_completion.py @@ -52,7 +52,7 @@ def _eq(prefix, expected_completions): _eq("", ["bahish", "nada", "nopy", "pybah", "pydad", "pyfoo", "pymum", "pyodd", "pyson", "pysplit", "python", "pyvariants", "test_variant_split_start", "test_variant_split_mid1", - "test_variant_split_mid2", "test_variant_split_end", "missing_variant_package"]) + "test_variant_split_mid2", "test_variant_split_end", "missing_variant_requires"]) _eq("py", ["pybah", "pydad", "pyfoo", "pymum", "pyodd", "pyson", "pysplit", "python", "pyvariants"]) _eq("pys", ["pyson", "pysplit"]) diff --git a/src/rez/tests/test_packages.py b/src/rez/tests/test_packages.py index 40a6dacd4..11dc60c1f 100644 --- a/src/rez/tests/test_packages.py +++ b/src/rez/tests/test_packages.py @@ -58,7 +58,7 @@ 'timestamped-1.0.5', 'timestamped-1.0.6', 'timestamped-1.1.0', 'timestamped-1.1.1', 'timestamped-1.2.0', 'timestamped-2.0.0', 'timestamped-2.1.0', 'timestamped-2.1.5', 'multi-1.0', 'multi-1.1', 'multi-1.2', 'multi-2.0', - 'missing_variant_package-1' + 'missing_variant_requires-1' ]) diff --git a/src/rez/tests/test_solver.py b/src/rez/tests/test_solver.py index 1c229911c..4bfcf5db3 100644 --- a/src/rez/tests/test_solver.py +++ b/src/rez/tests/test_solver.py @@ -249,13 +249,13 @@ def test_11_variant_splitting(self): "test_variant_split_mid2-2.0[0]", "test_variant_split_start-1.0[1]"]) - def test_12_missing_variant_package(self): - config.override("error_on_missing_variant_packages", True) + def test_12_missing_variant_requires(self): + config.override("error_on_missing_variant_requires", True) with self.assertRaises(rez.exceptions.PackageFamilyNotFoundError): - self._solve(["missing_variant_package"], []) + self._solve(["missing_variant_requires"], []) - config.override("error_on_missing_variant_packages", False) - self._solve(["missing_variant_package"], ["nada[]", "missing_variant_package-1[1]"]) + config.override("error_on_missing_variant_requires", False) + self._solve(["missing_variant_requires"], ["nada[]", "missing_variant_requires-1[1]"]) if __name__ == '__main__': unittest.main()