Bug 1322025 - Enforce --help requirement on option's when argument. r=chmanchester, a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 25 Jan 2017 14:37:34 +0900
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357446 38a758ced7935484ca54b923b695df11769d8a02
parent 357445 d20b7ab6e1cc5c683ec2261baacdb0ca090cf074
child 357447 4ba744632d51076e2a0d8324fa8a590dcfb5441f
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester, IanN
bugs1322025, 1316957
milestone52.9.1
Bug 1322025 - Enforce --help requirement on option's when argument. r=chmanchester, a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH Options with a `when` argument (either directly, or inherited through only_when() or an include) require --help per _value_for_option, but that code path is not exercised during a lint pass. With this change, along the previous one, we now correctly detect that bug 1316957 was not supposed to work as is.
python/mozbuild/mozbuild/configure/lint.py
python/mozbuild/mozbuild/test/configure/test_lint.py
--- a/python/mozbuild/mozbuild/configure/lint.py
+++ b/python/mozbuild/mozbuild/configure/lint.py
@@ -109,16 +109,23 @@ class LintSandbox(ConfigureSandbox):
                         % (obj.name, arg.name, arg.name))
         elif ((self._help or need_help_dependency) and
               self._missing_help_dependency(obj)):
             raise ConfigureError("Missing @depends for `%s`: '--help'" %
                                  obj.name)
         return super(LintSandbox, self)._value_for_depends(
             obj, need_help_dependency)
 
+    def option_impl(self, *args, **kwargs):
+        result = super(LintSandbox, self).option_impl(*args, **kwargs)
+        when = self._conditions.get(result)
+        if when:
+            self._value_for(when, need_help_dependency=True)
+        return result
+
     def unwrap(self, func):
         glob = func.func_globals
         while func in self._wrapped:
             if isinstance(func.func_globals, SandboxedGlobal):
                 glob = func.func_globals
             func = self._wrapped[func]
         return func, glob
 
--- a/python/mozbuild/mozbuild/test/configure/test_lint.py
+++ b/python/mozbuild/mozbuild/test/configure/test_lint.py
@@ -128,16 +128,31 @@ class TestLint(unittest.TestCase):
 
                 include(bar)
             '''):
                 self.lint_test()
 
         self.assertEquals(e.exception.message,
                           "Missing @depends for `foo`: '--help'")
 
+        with self.assertRaises(ConfigureError) as e:
+            with self.moz_configure('''
+                option('--foo', help='foo')
+                @depends('--foo')
+                @imports('os')
+                def foo(value):
+                    return value
+
+                option('--bar', help='bar', when=foo)
+            '''):
+                self.lint_test()
+
+        self.assertEquals(e.exception.message,
+                          "Missing @depends for `foo`: '--help'")
+
         # There is a default restricted `os` module when there is no explicit
         # @imports, and it's fine to use it without a dependency on --help.
         with self.moz_configure('''
             option('--foo', help='foo')
             @depends('--foo')
             def foo(value):
                 os
                 return value