зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1563158 - Properly handle imply_option dependency loops when `when` is involved. r=chmanchester
This is an extension of the relaxation added in bug 1529799. Differential Revision: https://phabricator.services.mozilla.com/D36716 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
89f408ffff
Коммит
20ee1b2284
|
@ -468,6 +468,9 @@ class ConfigureSandbox(dict):
|
|||
implied_option.caller[2]))
|
||||
# If the option is known, check that the implied value doesn't
|
||||
# conflict with what value was attributed to the option.
|
||||
if (implied_option.when and
|
||||
not self._value_for(implied_option.when)):
|
||||
continue
|
||||
option_value = self._value_for_option(option)
|
||||
if value != option_value:
|
||||
reason = implied_option.reason
|
||||
|
|
|
@ -789,6 +789,56 @@ class TestConfigure(unittest.TestCase):
|
|||
'QUX': NegativeOptionValue(),
|
||||
})
|
||||
|
||||
config_path = mozpath.abspath(
|
||||
mozpath.join(test_data_path, 'moz.configure'))
|
||||
|
||||
# Same test as above, but using `when` in the `imply_option`.
|
||||
with self.moz_configure('''
|
||||
option('--with-foo', help='foo')
|
||||
|
||||
@depends('--with-foo')
|
||||
def qux_default(foo):
|
||||
return bool(foo)
|
||||
|
||||
option('--with-qux', default=qux_default, help='qux')
|
||||
|
||||
imply_option('--with-foo', True, when='--with-qux')
|
||||
|
||||
set_config('FOO', depends('--with-foo')(lambda x: x))
|
||||
set_config('QUX', depends('--with-qux')(lambda x: x))
|
||||
'''):
|
||||
config = self.get_config()
|
||||
self.assertEquals(config, {
|
||||
'FOO': NegativeOptionValue(),
|
||||
'QUX': NegativeOptionValue(),
|
||||
})
|
||||
|
||||
config = self.get_config(['--with-foo'])
|
||||
self.assertEquals(config, {
|
||||
'FOO': PositiveOptionValue(),
|
||||
'QUX': PositiveOptionValue(),
|
||||
})
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--with-qux'])
|
||||
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by 'imply_option at %s:10' conflicts "
|
||||
"with '--without-foo' from the default" % config_path)
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
config = self.get_config(['--without-foo', '--with-qux'])
|
||||
|
||||
self.assertEquals(e.exception.message,
|
||||
"'--with-foo' implied by 'imply_option at %s:10' conflicts "
|
||||
"with '--without-foo' from the command-line" % config_path)
|
||||
|
||||
config = self.get_config(['--without-qux'])
|
||||
self.assertEquals(config, {
|
||||
'FOO': NegativeOptionValue(),
|
||||
'QUX': NegativeOptionValue(),
|
||||
})
|
||||
|
||||
def test_imply_option_recursion(self):
|
||||
config_path = mozpath.abspath(
|
||||
mozpath.join(test_data_path, 'moz.configure'))
|
||||
|
|
Загрузка…
Ссылка в новой задаче