diff mbox series

[v3,2/4] data_smart: differ taking overrides with unexpanded variables into account

Message ID 1791899582.8631fc262581453bbf619ec5b2062170.1a13589bf0a0008425@vates.tech
State New
Headers show
Series [v3,1/4] data: add a (failing) test showing non-expansion of lowercase variable in override | expand

Commit Message

Yann Dirson Oct. 13, 2026, 1:52 p.m. UTC
In original code, in a setVar call for, say, "TEST:foo-${MACHINE}",
the __setvar_regexp__ regexp does not match *because of capitals*, so
it stores a variable name including $ and caps. Later during
finalization expandKeys then calls renameVar and setVar, at which
point the regexp matches and the override is detected.

The reason why this works is not because there is a variable in the
override text, but because there are uppercase letters, so it would
break with lowercase, as well as if we want to change the regexp to
allow uppercase in an override string.

Signed-off-by: Yann Dirson <yann.dirson@vates.tech>
Assisted-by: Claude Opus 5.5
---
 lib/bb/data_smart.py | 2 +-
 lib/bb/tests/data.py | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 8aa7c1f99..a6e4bddb6 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -31,7 +31,7 @@  from bb.COW  import COWDictBase
 logger = logging.getLogger("BitBake.Data")
 
 __setvar_keyword__ = [":append", ":prepend", ":remove"]
-__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z]*))?$')
+__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z$]*))?$')
 __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+}")
 __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
 __whitespace_split__ = re.compile(r'(\s)')
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index 31a1ec323..fb455be98 100644
--- a/lib/bb/tests/data.py
+++ b/lib/bb/tests/data.py
@@ -417,7 +417,6 @@  class TestOverrides(unittest.TestCase):
         self.assertEqual(self.d.getVar("TEST"), "base appended")
 
     # Test an :append whose override name is lowercase
-    @unittest.expectedFailure
     def test_append_in_expanded_lowercase_override(self):
         self.d.setVar("machine", "qemux86")
         self.d.setVar("PN", "gizmo")