From 3baab7344be1b872ad57892f5128fdb819c6d56c Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 15 Aug 2014 13:52:18 +0900 Subject: [PATCH] Bug 1053140 part 2 - Add a test for exported variable override. r=gps --- .../inheriting-variables/foo/baz/moz.build | 2 ++ .../mozbuild/test/frontend/test_reader.py | 2 +- .../mozbuild/test/frontend/test_sandbox.py | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/foo/baz/moz.build b/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/foo/baz/moz.build index c271ec3908ce6..9cc068caaa795 100644 --- a/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/foo/baz/moz.build +++ b/python/mozbuild/mozbuild/test/frontend/data/inheriting-variables/foo/baz/moz.build @@ -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' diff --git a/python/mozbuild/mozbuild/test/frontend/test_reader.py b/python/mozbuild/mozbuild/test/frontend/test_reader.py index 80163d95089fb..8474aa1a211b3 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_reader.py +++ b/python/mozbuild/mozbuild/test/frontend/test_reader.py @@ -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): diff --git a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py index 8ece42d44005f..7a3a09a6ab7a2 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py +++ b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py @@ -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()