Ejemplo n.º 1
0
    def sandbox(self, relpath='moz.build', data_path=None):
        config = None

        if data_path is not None:
            config = MockConfig(os.path.join(test_data_path, data_path))
        else:
            config = MockConfig()

        return MozbuildSandbox(config, config.child_path(relpath))
Ejemplo n.º 2
0
    def sandbox(self, data_path=None, metadata={}):
        config = None

        if data_path is not None:
            config = MockConfig(mozpath.join(test_data_path, data_path))
        else:
            config = MockConfig()

        return MozbuildSandbox(Context(VARIABLES, config), metadata)
Ejemplo n.º 3
0
    def test_invalid_utf8_substs(self):
        """Ensure invalid UTF-8 in substs is converted with an error."""

        # This is really mbcs. It's a bunch of invalid UTF-8.
        config = MockConfig(extra_substs={'BAD_UTF8': b'\x83\x81\x83\x82\x3A'})

        sandbox = MozbuildSandbox(config, '/foo/moz.build')

        self.assertEqual(sandbox['CONFIG']['BAD_UTF8'],
                         u'\ufffd\ufffd\ufffd\ufffd:')
Ejemplo n.º 4
0
    def test_exec_source_reassign_exported(self):
        config = MockConfig()

        exports = {'DIST_SUBDIR': 'browser'}

        sandbox = MozbuildSandbox(Context(VARIABLES, config),
            metadata={'exports': exports})

        self.assertEqual(sandbox['DIST_SUBDIR'], 'browser')

        sandbox.exec_source('DIST_SUBDIR = "foo"')
        with self.assertRaises(SandboxExecutionError) as se:
          sandbox.exec_source('DIST_SUBDIR = "bar"')

        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')
Ejemplo n.º 5
0
    def test_exec_source_reassign_exported(self):
        config = MockConfig()

        exports = {'DIST_SUBDIR': 'browser'}

        sandbox = MozbuildSandbox(Context(VARIABLES, config),
                                  metadata={'exports': exports})

        self.assertEqual(sandbox['DIST_SUBDIR'], 'browser')

        sandbox.exec_source('DIST_SUBDIR = "foo"')
        with self.assertRaises(SandboxExecutionError) as se:
            sandbox.exec_source('DIST_SUBDIR = "bar"')

        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')