diff --git a/test/unit/test_input_recipe.py b/test/unit/test_input_recipe.py index 21140d1a..7c74512d 100644 --- a/test/unit/test_input_recipe.py +++ b/test/unit/test_input_recipe.py @@ -194,13 +194,13 @@ def applyRecipeDefaults(self, recipe): r.setdefault("checkoutUpdateIf", False) return r - def parseAndPrepare(self, recipe, classes={}, name="foo", env={}): + def parseAndPrepare(self, recipe, classes={}, name="foo", env={}, policies={}): cwd = os.getcwd() recipeSet = MagicMock() recipeSet.loadBinary = MagicMock() recipeSet.scriptLanguage = self.SCRIPT_LANGUAGE - recipeSet.getPolicy = lambda x: True if x == "substituteMetaEnv" else None + recipeSet.getPolicy = lambda x: policies.get(x) cc = { n : Recipe(recipeSet, self.applyRecipeDefaults(r), "", n+".yaml", cwd, n, n, {}, False) @@ -691,6 +691,20 @@ def testMergeEnvironment(self): "C" : "", }) + def testMetaEnvironmentLegacy(self): + """Pre 0.25 versions did not apply substitution in metaEnvironment""" + recipe = { + "metaEnvironment" : { + "A" : "$A", + "B" : "$B'", + }, + } + pkg = self.parseAndPrepare(recipe) + self.assertEqual(pkg.getMetaEnv(), { + "A" : "$A", + "B" : "$B'", + }) + def testMetaEnvrionmentSubstitution(self): """metaEnvironment is substituted and merged on a key-by-key basis""" recipe = { @@ -719,7 +733,10 @@ def testMetaEnvrionmentSubstitution(self): "A" : "a", "B" : "b", } - p = self.parseAndPrepare(recipe, classes, env=env).getPackageStep() + policies = { + "substituteMetaEnv" : True, + } + p = self.parseAndPrepare(recipe, classes, env=env, policies=policies).getPackageStep() self.assertEqual(p.getEnv(), { "A" : "a", "B" : "b",