Bug 1363811 - Change TestConfigure.test_depends_or to test more cases. r?chmanchester draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 17 May 2017 15:09:42 +0900
changeset 580722 42cefc0670f9b3fd20473d983136ee16800e6231
parent 580721 8b602649e6737c56519eb2753122696020b8096b
child 580723 5f568887e58875358a655d380066fb974288012f
push id59648
push userbmo:mh+mozilla@glandium.org
push dateThu, 18 May 2017 22:06:14 +0000
reviewerschmanchester
bugs1363811
milestone55.0a1
Bug 1363811 - Change TestConfigure.test_depends_or to test more cases. r?chmanchester 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()