| 1 |
import clang.cindex |
| 2 |
|
| 3 |
|
| 4 |
import unittest |
| 5 |
import ast |
| 6 |
|
| 7 |
|
| 8 |
class TestLib(unittest.TestCase): |
| 9 |
def test_functions_registered(self): |
| 10 |
def get_function_spelling(node): |
| 11 |
# The call expressions we are interested in have |
| 12 |
# their spelling in .attr, not .id |
| 13 |
if hasattr(node, "attr"): |
| 14 |
return node.attr |
| 15 |
return "" |
| 16 |
|
| 17 |
filename = clang.cindex.__file__ |
| 18 |
with open(filename) as file: |
| 19 |
root = ast.parse(file.read()) |
| 20 |
functions = [ |
| 21 |
get_function_spelling(node.func) |
| 22 |
for node in ast.walk(root) |
| 23 |
if isinstance(node, ast.Call) |
| 24 |
] |
| 25 |
used_functions = set([func for func in functions if func.startswith("clang_")]) |
| 26 |
registered_functions = set([item[0] for item in clang.cindex.FUNCTION_LIST]) |
| 27 |
self.assertEqual(used_functions - registered_functions, set()) |