Files
llvm/clang/bindings/python/tests/cindex/test_lib.py
Jannick Kremer 7a9bef0166 Revert "Move python binding tests to lit framework" (#149012)
This reverts commit f8707f994af2582f6dc58190106946efeb43bf05.
2025-07-16 05:32:08 +01:00

32 lines
1016 B
Python

import os
import clang.cindex
if "CLANG_LIBRARY_PATH" in os.environ:
clang.cindex.Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
import unittest
import ast
class TestLib(unittest.TestCase):
def test_functions_registered(self):
def get_function_spelling(node):
# The call expressions we are interested in have
# their spelling in .attr, not .id
if hasattr(node, "attr"):
return node.attr
return ""
filename = clang.cindex.__file__
with open(filename) as file:
root = ast.parse(file.read())
functions = [
get_function_spelling(node.func)
for node in ast.walk(root)
if isinstance(node, ast.Call)
]
used_functions = set([func for func in functions if func.startswith("clang_")])
registered_functions = set([item[0] for item in clang.cindex.FUNCTION_LIST])
self.assertEqual(used_functions - registered_functions, set())