Skip to content

Commit 4516873

Browse files
committed
[incrParse] Test utility: Compare syntax trees without IDs
IDs are not expected to be the same between incremental parsing and from-scratch parsing.
1 parent 9d59cd2 commit 4516873

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

utils/incrparse_test_util.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ def main():
196196
test_case + '.incr.swift.serialized.json'
197197
serialized_post_edit_filename = post_edit_file.name + '.serialized.json'
198198

199+
serialized_incr_no_ids_filename = serialized_incr_filename + '.noids.json'
200+
serialized_post_edit_no_ids_filename = serialized_post_edit_filename + \
201+
'.noids.json'
202+
199203
try:
200204
# Serialise the pre-edit syntax tree
201205
run_command(
@@ -232,6 +236,20 @@ def main():
232236
['-output-filename', serialized_incr_filename] +
233237
print_visual_reuse_info_args)
234238

239+
with open(serialized_incr_no_ids_filename, 'w+') as file:
240+
subprocess.check_call(
241+
['grep'] +
242+
['-v'] +
243+
['-e', '^ *"id": [0-9]*$'] +
244+
[serialized_incr_filename], stdout=file)
245+
246+
with open(serialized_post_edit_no_ids_filename, 'w+') as file:
247+
subprocess.check_call(
248+
['grep'] +
249+
['-v'] +
250+
['-e', '^ *"id": [0-9]*$'] +
251+
[serialized_post_edit_filename], stdout=file)
252+
235253
if print_visual_reuse_info:
236254
print(incr_parse_output)
237255
exit(0)
@@ -247,8 +265,8 @@ def main():
247265
run_command(
248266
[
249267
'diff', '-u',
250-
serialized_post_edit_filename,
251-
serialized_incr_filename
268+
serialized_incr_no_ids_filename,
269+
serialized_post_edit_no_ids_filename
252270
])
253271
except subprocess.CalledProcessError as e:
254272
print('Test case "%s" of %s FAILed' % (test_case, test_file.name),

0 commit comments

Comments
 (0)