Bug 1053140 part 2 - Add a test for exported variable override. r=gps

This commit is contained in:
Mike Hommey 2014-08-15 13:52:18 +09:00
parent 0d730f6233
commit 6b73ef1b8c
3 changed files with 25 additions and 1 deletions

View File

@ -3,3 +3,5 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_MODULE = 'baz'

View File

@ -242,7 +242,7 @@ class TestBuildReader(unittest.TestCase):
self.assertEqual([sandbox['RELATIVEDIR'] for sandbox in sandboxes],
['', 'foo', 'foo/baz', 'bar'])
self.assertEqual([sandbox['XPIDL_MODULE'] for sandbox in sandboxes],
['foobar', 'foobar', 'foobar', 'foobar'])
['foobar', 'foobar', 'baz', 'foobar'])
def test_process_eval_callback(self):
def strip_dirs(sandbox):

View File

@ -180,6 +180,28 @@ class TestSandbox(unittest.TestCase):
self.assertEqual(e.args[1], 'reassign')
self.assertEqual(e.args[2], 'DIRS')
def test_exec_source_reassign_exported(self):
config = MockConfig()
exports = {'DIST_SUBDIR': 'browser'}
sandbox = MozbuildSandbox(config, '', metadata={'exports': exports})
self.assertEqual(sandbox['DIST_SUBDIR'], 'browser')
sandbox.exec_source('DIST_SUBDIR = "foo"', 'foo.py')
with self.assertRaises(SandboxExecutionError) as se:
sandbox.exec_source('DIST_SUBDIR = "bar"', 'foo.py')
self.assertEqual(sandbox['DIST_SUBDIR'], 'foo')
e = se.exception
self.assertIsInstance(e.exc_value, KeyError)
e = se.exception.exc_value
self.assertEqual(e.args[0], 'global_ns')
self.assertEqual(e.args[1], 'reassign')
self.assertEqual(e.args[2], 'DIST_SUBDIR')
def test_add_tier_dir_regular_str(self):
sandbox = self.sandbox()