Bug 1363811 - Change TestConfigure.test_depends_or to test more cases. r=cmanchester a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 17 May 2017 15:09:42 +0900
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357462 c652e58fa5d2d304f211c0d03b881a29c7433ed8
parent 357461 8a25ba5859ed45b6827ad7a96823b5570f297f7b
child 357463 85ff684673134bc6b405d75b9edee783bbac1fc1
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)
reviewerscmanchester, IanN
bugs1363811
milestone52.9.1
Bug 1363811 - Change TestConfigure.test_depends_or to test more cases. r=cmanchester a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH Also, test the results match what a normal "or" of the returned values would be. This makes it clearer how the feature is meant to work.
python/mozbuild/mozbuild/test/configure/test_configure.py
--- a/python/mozbuild/mozbuild/test/configure/test_configure.py
+++ b/python/mozbuild/mozbuild/test/configure/test_configure.py
@@ -1287,40 +1287,45 @@ class TestConfigure(unittest.TestCase):
         ''' + moz_configure):
             self.get_config(['--enable-when'])
 
     def test_depends_or(self):
         with self.moz_configure('''
             option('--foo', nargs=1, help='foo')
             @depends('--foo')
             def foo(value):
-                return value or None
+                return value or 0
 
             option('--bar', nargs=1, help='bar')
             @depends('--bar')
             def bar(value):
+                return value or ''
+
+            option('--baz', nargs=1, help='baz')
+            @depends('--baz')
+            def baz(value):
                 return value
 
             set_config('FOOBAR', foo | bar)
+            set_config('FOOBARBAZ', foo | bar | baz)
         '''):
-            config = self.get_config()
-            self.assertEqual(config, {
-                'FOOBAR': NegativeOptionValue(),
-            })
-
-            config = self.get_config(['--foo=foo'])
-            self.assertEqual(config, {
-                'FOOBAR': PositiveOptionValue(('foo',)),
-            })
-
-            config = self.get_config(['--bar=bar'])
-            self.assertEqual(config, {
-                'FOOBAR': PositiveOptionValue(('bar',)),
-            })
-
-            config = self.get_config(['--foo=foo', '--bar=bar'])
-            self.assertEqual(config, {
-                'FOOBAR': PositiveOptionValue(('foo',)),
-            })
+            for foo_opt, foo_value in (
+                ('',  0),
+                ('--foo=foo', PositiveOptionValue(('foo',)))
+            ):
+                for bar_opt, bar_value in (
+                    ('', ''),
+                    ('--bar=bar', PositiveOptionValue(('bar',)))
+                ):
+                    for baz_opt, baz_value in (
+                        ('', NegativeOptionValue()),
+                        ('--baz=baz', PositiveOptionValue(('baz',)))
+                    ):
+                        config = self.get_config(
+                            [x for x in (foo_opt, bar_opt, baz_opt) if x])
+                        self.assertEqual(config, {
+                            'FOOBAR': foo_value or bar_value,
+                            'FOOBARBAZ': foo_value or bar_value or baz_value,
+                        })
 
 
 if __name__ == '__main__':
     main()