mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1071568 - Only pass down templates to the sandbox context when calling moz.build templates. r=mshal
It's not entirely clear passing down all the metadata makes sense. On the other hand, when creating the template execution sandbox, passing down exports does assign the value for the exported variable in that execution context. When that context is merged with the caller sandbox context, the exported variable is reassigned, even if the value is not modified. Then, if the caller sandbox itself reassigns the exported variable, it fails because calling a template already did it once, unexpectedly. Not passing down exported variables makes the template execution sandbox never set those exported variables, so that they are not merged back. The caller sandbox can then properly reassign the exported variable.
This commit is contained in:
parent
c72cb48004
commit
139046d56b
@ -350,7 +350,9 @@ class MozbuildSandbox(Sandbox):
|
||||
for p in self._context.all_paths:
|
||||
context.add_source(p)
|
||||
|
||||
sandbox = MozbuildSandbox(context, self.metadata)
|
||||
sandbox = MozbuildSandbox(context, {
|
||||
'templates': self.metadata.get('templates', {})
|
||||
})
|
||||
for k, v in inspect.getcallargs(func, *args, **kwargs).items():
|
||||
sandbox[k] = v
|
||||
|
||||
|
@ -211,15 +211,26 @@ class TestMozbuildSandbox(unittest.TestCase):
|
||||
sandbox[k] = 0
|
||||
|
||||
def test_exec_source_reassign_exported(self):
|
||||
template_sandbox = self.sandbox(data_path='templates')
|
||||
|
||||
# Templates need to be defined in actual files because of
|
||||
# inspect.getsourcelines.
|
||||
template_sandbox.exec_file('templates.mozbuild')
|
||||
|
||||
config = MockConfig()
|
||||
|
||||
exports = {'DIST_SUBDIR': 'browser'}
|
||||
|
||||
sandbox = MozbuildSandbox(Context(VARIABLES, config),
|
||||
metadata={'exports': exports})
|
||||
sandbox = TestedSandbox(Context(VARIABLES, config), metadata={
|
||||
'exports': exports,
|
||||
'templates': template_sandbox.templates,
|
||||
})
|
||||
|
||||
self.assertEqual(sandbox['DIST_SUBDIR'], 'browser')
|
||||
|
||||
# Templates should not interfere
|
||||
sandbox.exec_source('Template([])', 'foo.mozbuild')
|
||||
|
||||
sandbox.exec_source('DIST_SUBDIR = "foo"')
|
||||
with self.assertRaises(SandboxExecutionError) as se:
|
||||
sandbox.exec_source('DIST_SUBDIR = "bar"')
|
||||
|
Loading…
Reference in New Issue
Block a user