зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1311069 - Don't throw InvalidOptionError exceptions when a non-available option was set from an environment variable. r=chmanchester
--HG-- extra : rebase_source : 74b61120a2d1ec721d92c7f8697694b807670013
This commit is contained in:
Родитель
29c21aaf86
Коммит
ffb7fbf6c4
|
@ -475,8 +475,13 @@ class ConfigureSandbox(dict):
|
|||
when = self._conditions.get(option)
|
||||
if (when and not self._value_for(when, need_help_dependency=True) and
|
||||
value is not None and value.origin != 'default'):
|
||||
if value.origin == 'environment':
|
||||
# The value we return doesn't really matter, because of the
|
||||
# requirement for @depends to have the same when.
|
||||
return None
|
||||
raise InvalidOptionError(
|
||||
'%s is not available in this configuration' % option_string)
|
||||
'%s is not available in this configuration'
|
||||
% option_string.split('=', 1)[0])
|
||||
|
||||
return value
|
||||
|
||||
|
|
|
@ -774,7 +774,7 @@ class TestConfigure(unittest.TestCase):
|
|||
return False
|
||||
option('--with-foo', help='foo', when=always)
|
||||
option('--with-bar', help='bar', when=never)
|
||||
option('--with-qux', help='qux', when='--with-foo')
|
||||
option('--with-qux', env="QUX", help='qux', when='--with-foo')
|
||||
|
||||
set_config('FOO', depends('--with-foo', when=always)(lambda x: x))
|
||||
set_config('BAR', depends('--with-bar', when=never)(lambda x: x))
|
||||
|
@ -813,6 +813,19 @@ class TestConfigure(unittest.TestCase):
|
|||
'--with-qux is not available in this configuration'
|
||||
)
|
||||
|
||||
with self.assertRaises(InvalidOptionError) as e:
|
||||
self.get_config(['QUX=1'])
|
||||
|
||||
self.assertEquals(
|
||||
e.exception.message,
|
||||
'QUX is not available in this configuration'
|
||||
)
|
||||
|
||||
config = self.get_config(env={'QUX': '1'})
|
||||
self.assertEquals(config, {
|
||||
'FOO': NegativeOptionValue(),
|
||||
})
|
||||
|
||||
help, config = self.get_config(['--help'])
|
||||
self.assertEquals(help, textwrap.dedent('''\
|
||||
Usage: configure [options]
|
||||
|
|
Загрузка…
Ссылка в новой задаче