Skip to content

Commit

Permalink
test: check old behaviour of substituteMetaEnv policy
Browse files Browse the repository at this point in the history
  • Loading branch information
jkloetzke committed Oct 24, 2024
1 parent 9420d3b commit 3834cfb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions test/unit/test_input_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -691,6 +691,20 @@ def testMergeEnvironment(self):
"C" : "<lib><b>",
})

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 = {
Expand Down Expand Up @@ -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" : "<lib>a",
"B" : "<lib>b",
Expand Down

0 comments on commit 3834cfb

Please sign in to comment.