Skip to content

Commit 28d6cd8

Browse files
andy31415j-ororke
authored andcommitted
Add explicity merge_globals options to the parser for IDL generator. (project-chip#34590)
ZAP codegen will not add comments for referenced globals, so validating IDL as text should not contain them (otherwise parse compare fails)
1 parent 6ac1008 commit 28d6cd8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/py_matter_idl/matter_idl/test_idl_generator.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def ReadMatterIdl(repo_path: str) -> str:
5555
return stream.read()
5656

5757

58-
def ParseMatterIdl(repo_path: str, skip_meta: bool) -> Idl:
59-
return CreateParser(skip_meta=skip_meta).parse(ReadMatterIdl(repo_path))
58+
def ParseMatterIdl(repo_path: str, skip_meta: bool, merge_globals: bool) -> Idl:
59+
return CreateParser(skip_meta=skip_meta, merge_globals=merge_globals).parse(ReadMatterIdl(repo_path))
6060

6161

6262
def RenderAsIdlTxt(idl: Idl) -> str:
@@ -106,8 +106,10 @@ def test_client_clusters(self):
106106
# Files MUST be identical except the header comments which are different
107107
original = SkipLeadingComments(ReadMatterIdl(path), also_strip=[
108108
" // NOTE: Default/not specifically set"])
109+
# Do not merge globals because ZAP generated matter files do not contain
110+
# the merge global data (will not render global reference comments).
109111
generated = SkipLeadingComments(RenderAsIdlTxt(
110-
ParseMatterIdl(path, skip_meta=False)))
112+
ParseMatterIdl(path, skip_meta=False, merge_globals=False)))
111113

112114
self.assertTextEqual(original, generated)
113115

@@ -126,9 +128,9 @@ def test_app_rendering(self):
126128
]
127129

128130
for path in test_paths:
129-
idl = ParseMatterIdl(path, skip_meta=True)
131+
idl = ParseMatterIdl(path, skip_meta=True, merge_globals=True)
130132
txt = RenderAsIdlTxt(idl)
131-
idl2 = CreateParser(skip_meta=True).parse(txt)
133+
idl2 = CreateParser(skip_meta=True, merge_globals=True).parse(txt)
132134

133135
# checks that data types and content is the same
134136
self.assertEqual(idl, idl2)

0 commit comments

Comments
 (0)