Bug 1259683 - Don't make imply_option() do anything when --help is on the command line. r=nalexander
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 25 Mar 2016 15:55:06 +0900
changeset 290543 98fd214bd3f2c3f6b78484c8c19a5f7c84aca880
parent 290542 e2fe62b540c6f41b67921e8479cb0f8adf83ce43
child 290544 7ca9567ed5c7f2055b9911dee5b41e62398361c7
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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,