Fix bugs in features_set._prune_overrides() and add another test case.
authorZac Medico <zmedico@gentoo.org>
Tue, 31 Aug 2010 06:06:46 +0000 (23:06 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 31 Aug 2010 06:06:46 +0000 (23:06 -0700)
pym/portage/package/ebuild/_config/features_set.py
pym/portage/tests/ebuild/test_config.py

index a39fb89dc7d00bac0e648f6f0474b4e8822d1e44..62236fd89dacc196191de616200dc43272ba586d 100644 (file)
@@ -115,15 +115,14 @@ class features_set(object):
                to persist for future config.regenerate() calls.
                """
                overrides_set = set(self._settings._features_overrides)
-               if len(overrides_set) < len(self._settings._features_overrides):
-                       positive = set()
-                       negative = set()
-                       for x in self._settings._features_overrides:
-                               if x[:1] == '-':
-                                       positive.discard(x[:1])
-                                       negative.add(x[:1])
-                               else:
-                                       positive.add(x)
-                                       negative.discard(x)
-                       self._settings._features_overrides[:] = \
-                               list(positive) + list(negative)
+               positive = set()
+               negative = set()
+               for x in self._settings._features_overrides:
+                       if x[:1] == '-':
+                               positive.discard(x[1:])
+                               negative.add(x[1:])
+                       else:
+                               positive.add(x)
+                               negative.discard(x)
+               self._settings._features_overrides[:] = \
+                       list(positive) + list('-' + x for x in negative)
index b12605aacdf9b6fc0764904994d08ae4345d4cdf..fa711bee44541341e92d9c00f90689806be0fcc5 100644 (file)
@@ -40,6 +40,14 @@ class ConfigTestCase(TestCase):
                        #  after: ['noclean']
                        self.assertEqual(settings._features_overrides.count('noclean'), 1)
                        self.assertEqual(settings._features_overrides.count('-noclean'), 0)
+
+                       settings.features.remove('noclean')
+
+                       # before: ['noclean', '-noclean']
+                       settings.features._prune_overrides()
+                       #  after: ['-noclean']
+                       self.assertEqual(settings._features_overrides.count('noclean'), 0)
+                       self.assertEqual(settings._features_overrides.count('-noclean'), 1)
                finally:
                        playground.cleanup()