Bug 1259683 - Don't make imply_option() do anything when --help is on the command line. r?nalexander draft
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Mar 2016 15:55:06 +0900
changeset 344647 c18d3ca455393348542d9312687a1338dc5edf45
parent 344646 d1ccc9be91b8110b65f1962e8fa37e4a67d608bd
child 517016 7c1a94ef328b09ed6dc62ee626b98951df087cfa
push id13893
push userbmo:mh+mozilla@glandium.org
push dateFri, 25 Mar 2016 07:05:07 +0000
reviewersnalexander
bugs1259683
milestone48.0a1
Bug 1259683 - Don't make imply_option() do anything when --help is on the command line. r?nalexander This also adds the same tests that exist for set_config and set_define and that would have caught the `configure --help` breakage this change fixes.
python/mozbuild/mozbuild/configure/__init__.py
python/mozbuild/mozbuild/test/configure/test_configure.py
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -445,16 +445,19 @@ class ConfigureSandbox(dict):
 
         The `value` argument can also be (and usually is) a reference to a
         @depends function, in which case the result of that function will be
         used as per the descripted mapping above.
 
         The `reason` argument indicates what caused the option to be implied.
         It is necessary when it cannot be inferred from the `value`.
         '''
+        # Don't do anything when --help was on the command line
+        if self._help:
+            return
         if not reason and isinstance(value, DummyFunction):
             deps = self._depends[value][1]
             possible_reasons = [d for d in deps if d != self._help_option]
             if len(possible_reasons) == 1:
                 if isinstance(possible_reasons[0], Option):
                     reason = (self._raw_options.get(possible_reasons[0]) or
                               possible_reasons[0].option)
 
--- a/python/mozbuild/mozbuild/test/configure/test_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_configure.py
@@ -325,16 +325,20 @@ class TestConfigure(unittest.TestCase):
             # set_define('FOO'...)
             get_config(['--set-foo', '--set-name=FOO'])
 
     def test_imply_option_simple(self):
         def get_config(*args):
             return self.get_config(
                 *args, configure='imply_option/simple.configure')
 
+        config, out = self.get_result(
+            ['--help'], configure='imply_option/simple.configure')
+        self.assertEquals(config, {})
+
         config = get_config([])
         self.assertEquals(config, {})
 
         config = get_config(['--enable-foo'])
         self.assertIn('BAR', config)
         self.assertEquals(config['BAR'], PositiveOptionValue())
 
         with self.assertRaises(InvalidOptionError) as e:
@@ -345,16 +349,20 @@ class TestConfigure(unittest.TestCase):
             "'--enable-bar' implied by '--enable-foo' conflicts with "
             "'--disable-bar' from the command-line")
 
     def test_imply_option_negative(self):
         def get_config(*args):
             return self.get_config(
                 *args, configure='imply_option/negative.configure')
 
+        config, out = self.get_result(
+            ['--help'], configure='imply_option/negative.configure')
+        self.assertEquals(config, {})
+
         config = get_config([])
         self.assertEquals(config, {})
 
         config = get_config(['--enable-foo'])
         self.assertIn('BAR', config)
         self.assertEquals(config['BAR'], NegativeOptionValue())
 
         with self.assertRaises(InvalidOptionError) as e:
@@ -377,16 +385,20 @@ class TestConfigure(unittest.TestCase):
             "'--disable-bar' implied by '--disable-hoge' conflicts with "
             "'--enable-bar' from the command-line")
 
     def test_imply_option_values(self):
         def get_config(*args):
             return self.get_config(
                 *args, configure='imply_option/values.configure')
 
+        config, out = self.get_result(
+            ['--help'], configure='imply_option/values.configure')
+        self.assertEquals(config, {})
+
         config = get_config([])
         self.assertEquals(config, {})
 
         config = get_config(['--enable-foo=a'])
         self.assertIn('BAR', config)
         self.assertEquals(config['BAR'], PositiveOptionValue(('a',)))
 
         config = get_config(['--enable-foo=a,b'])
@@ -401,16 +413,20 @@ class TestConfigure(unittest.TestCase):
             "'--enable-bar=a,b' implied by '--enable-foo' conflicts with "
             "'--disable-bar' from the command-line")
 
     def test_imply_option_infer(self):
         def get_config(*args):
             return self.get_config(
                 *args, configure='imply_option/infer.configure')
 
+        config, out = self.get_result(
+            ['--help'], configure='imply_option/infer.configure')
+        self.assertEquals(config, {})
+
         config = get_config([])
         self.assertEquals(config, {})
 
         with self.assertRaises(InvalidOptionError) as e:
             get_config(['--enable-foo', '--disable-bar'])
 
         self.assertEquals(
             e.exception.message,