Bug 952564 - Disallow empty lists in moz.build variables r=gps

--HG--
extra : rebase_source : 9a70b6a3150fe898a724a43815dc923bb0d70b89
extra : amend_source : 7aa800ef61427117e5dc461443f82ebd403d8164
This commit is contained in:
Sambuddha Basu 2016-02-18 17:26:09 -08:00
Родитель 3206518350
Коммит 79b3096449
4 изменённых файлов: 22 добавлений и 4 удалений

Просмотреть файл

@ -41,8 +41,6 @@ if CONFIG['MOZ_WEBSPEECH']:
'test/nsFakeSynthServices.cpp' 'test/nsFakeSynthServices.cpp'
] ]
DIRS = []
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
DIRS += ['windows'] DIRS += ['windows']

Просмотреть файл

@ -286,6 +286,10 @@ class Sandbox(dict):
if key in self._context and self._context[key] is not value: if key in self._context and self._context[key] is not value:
raise KeyError('global_ns', 'reassign', key) raise KeyError('global_ns', 'reassign', key)
if (key not in self._context and isinstance(value, (list, dict))
and not value):
raise KeyError('Variable %s assigned an empty value.' % key)
self._context[key] = value self._context[key] = value
else: else:
dict.__setitem__(self, key, value) dict.__setitem__(self, key, value)

Просмотреть файл

@ -0,0 +1,5 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
DIRS = []

Просмотреть файл

@ -11,8 +11,10 @@ import unittest
from mozunit import main from mozunit import main
from mozbuild.frontend.context import BugzillaComponent from mozbuild.frontend.context import BugzillaComponent
from mozbuild.frontend.reader import BuildReaderError from mozbuild.frontend.reader import (
from mozbuild.frontend.reader import BuildReader BuildReaderError,
BuildReader,
)
from mozbuild.test.common import MockConfig from mozbuild.test.common import MockConfig
@ -246,6 +248,15 @@ class TestBuildReader(unittest.TestCase):
contexts = list(reader.read_topsrcdir()) contexts = list(reader.read_topsrcdir())
def test_error_empty_list(self):
reader = self.reader('reader-error-empty-list')
with self.assertRaises(BuildReaderError) as bre:
list(reader.read_topsrcdir())
e = bre.exception
self.assertIn('Variable DIRS assigned an empty value.', str(e))
def test_inheriting_variables(self): def test_inheriting_variables(self):
reader = self.reader('inheriting-variables') reader = self.reader('inheriting-variables')