diff mbox series

[2/6] tests.codeparser: add test for exec of builtin from inline python

Message ID 20230801143813.2206785-2-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit ee22d3d51c60db2da97422b2be1e42239b7a2324
Headers show
Series [1/6] tests.data: add test for inline python calling a def'd function | expand

Commit Message

Richard Purdie Aug. 1, 2023, 2:38 p.m. UTC
From: Christopher Larson <kergoth@gmail.com>

This ensures that any change to the presence of builtins in inline
python execs will be noticed.

Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
 lib/bb/tests/codeparser.py | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/tests/codeparser.py b/lib/bb/tests/codeparser.py
index 7f5d59ca74..a64c614b0b 100644
--- a/lib/bb/tests/codeparser.py
+++ b/lib/bb/tests/codeparser.py
@@ -44,6 +44,7 @@  class VariableReferenceTest(ReferenceTest):
     def parseExpression(self, exp):
         parsedvar = self.d.expandWithRefs(exp, None)
         self.references = parsedvar.references
+        self.execs = parsedvar.execs
 
     def test_simple_reference(self):
         self.setEmptyVars(["FOO"])
@@ -61,6 +62,11 @@  class VariableReferenceTest(ReferenceTest):
         self.parseExpression("${@d.getVar('BAR') + 'foo'}")
         self.assertReferences(set(["BAR"]))
 
+    def test_python_exec_reference(self):
+        self.parseExpression("${@eval('3 * 5')}")
+        self.assertReferences(set())
+        self.assertExecs(set(["eval"]))
+
 class ShellReferenceTest(ReferenceTest):
 
     def parseExpression(self, exp):