Skip to content

Commit 0cc0508

Browse files
committed
Report missing enum names instead of values
1 parent c1fa85e commit 0cc0508

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

clang/bindings/python/tests/cindex/test_enums.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,31 @@ def test_all_variants(self):
7272
python_enum = cenum_to_pythonenum.get(cursor.type.spelling)
7373
if cursor.kind == CursorKind.ENUM_CONSTANT_DECL:
7474
if python_enum not in enum_variant_map:
75-
enum_variant_map[python_enum] = []
76-
enum_variant_map[python_enum].append(cursor.enum_value)
75+
enum_variant_map[python_enum] = dict()
76+
enum_variant_map[python_enum][cursor.enum_value] = cursor.spelling
7777

7878
for enum in self.enums:
7979
with self.subTest(enum):
8080
python_kinds = set([kind.value for kind in enum])
81+
num_to_c_kind = enum_variant_map[enum]
82+
c_kinds = set(num_to_c_kind.keys())
8183
# Defined in Index.h but not in cindex.py
8284
missing_python_kinds = c_kinds - python_kinds
85+
missing_names = set(
86+
[num_to_c_kind[kind] for kind in missing_python_kinds]
87+
)
8388
self.assertEqual(
84-
missing_python_kinds,
89+
missing_names,
8590
set(),
8691
f"Please ensure these are defined in {enum} in cindex.py.",
8792
)
8893
# Defined in cindex.py but not in Index.h
8994
superfluous_python_kinds = python_kinds - c_kinds
95+
missing_names = set(
96+
[enum.from_id(kind) for kind in superfluous_python_kinds]
97+
)
9098
self.assertEqual(
91-
superfluous_python_kinds,
99+
missing_names,
92100
set(),
93101
f"Please ensure that all {enum} kinds defined in cindex.py have an equivalent in Index.h",
94102
)

0 commit comments

Comments
 (0)