Skip to content

Commit

Permalink
Bug 1053140 part 2 - Add a test for exported variable override. r=gps
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Aug 15, 2014
1 parent a165981 commit 3baab73
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/test/frontend/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def test_inheriting_variables(self):
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):
Expand Down
22 changes: 22 additions & 0 deletions python/mozbuild/mozbuild/test/frontend/test_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ def test_exec_source_reassign(self):
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()

Expand Down

0 comments on commit 3baab73

Please sign in to comment.