Skip to contentSkip to conversation

tests/data: add test for incorrect remove behaviour

PATCH New Ross Burton 1 participant 2 messages Feb 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tests/data: add test for incorrect remove behaviour

The _remove operator isn't working correctly when used with a variable that expands to several items, so add a test case to exercise this path.

---
 bitbake/lib/bb/tests/data.py |    7 +++++++
 1 file changed, 7 insertions(+)
bitbake/lib/bb/tests/data.py +7 -0
index 81e4091..7994a88 100644
@@ -272,6 +272,13 @@ class TestConcatOverride(unittest.TestCase):
         bb.data.update_data(self.d)
         self.assertEqual(self.d.getVar("TEST", True), "Y")
 
+    def test_remove_expansion_items(self):
+        self.d.setVar("TEST", "A B C D")
+        self.d.setVar("BAR", "B D")
+        self.d.setVar("TEST_remove", "${BAR}")
+        bb.data.update_data(self.d)
+        self.assertEqual(self.d.getVar("TEST", True), "A C")
+
 class TestOverrides(unittest.TestCase):
     def setUp(self):
         self.d = bb.data.init()
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 2/2 data_smart: split expanded removal values when handling _remove

Given these assignments:

TEST="a b c d"
TEST_remove = "b d"

TEST evaluates to "a c". However, if the _remove override is given as a variable:

TEST="a b c d"
FOO = "b d"
TEST_remove = "${FOO}

TEST evaluates to "a b c d", because when FOO is expanded it isn't split into a list.

Solve this by splitting all members of removeactive once they've been expanded.

[ YOCTO #7272 ]

---
 bitbake/lib/bb/data_smart.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
bitbake/lib/bb/data_smart.py +2 -1
index b1ea33f..7bb7b4a 100644
@@ -621,7 +621,8 @@ class DataSmart(MutableMapping):
                 cachename = var + "[" + flag + "]"
             value = self.expand(value, cachename)
         if value and flag == "_content" and local_var is not None and "_removeactive" in local_var:
-            removes = [self.expand(r) for r in local_var["_removeactive"]]
+            removes = [self.expand(r).split()  for r in local_var["_removeactive"]]
+            removes = reduce(lambda a, b: a+b, removes, [])
             filtered = filter(lambda v: v not in removes,
                               value.split())
             value = " ".join(filtered)
Signature · 1 line
1.7.10.4