Skip to content

Commit cf23549

Browse files
authored
[clang] Improve make_cxx_dr_status behavior when error occurs (#121785)
One of our contributors got confused by the behavior of the script when they incorrectly specified the status of a CWG issue (https://github.com/llvm/llvm-project/pull/102857/files#r1904264872), and this is an attempt to reduce the confusion: - script doesn't write anything to disk unless everything is good; - error messages are prefixed with (a very familiar) `error:` to make it more obvious that a fatal error occurred.
1 parent 2db7b31 commit cf23549

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

clang/www/make_cxx_dr_status

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ else:
8383

8484
status_map = collect_tests()
8585
drs = get_issues(issue_list_path)
86-
out_file = open(output, 'w')
87-
out_file.write('''\
86+
out_html = []
87+
out_html.append('''\
8888
<!DOCTYPE html>
8989
<!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
9090
<html>
@@ -149,7 +149,7 @@ def availability(issue):
149149
unresolved_status = unresolved_status_match.group(1)
150150
proposed_resolution_match = re.search(r' (open|drafting|review|tentatively ready|ready) (\d{4}-\d{2}(?:-\d{2})?|P\d{4}R\d+)$', status)
151151
if proposed_resolution_match is None:
152-
raise AvailabilityError('Issue {}: \'{}\' status should be followed by a paper number (P1234R5) or proposed resolution in YYYY-MM-DD format'.format(dr.issue, unresolved_status))
152+
raise AvailabilityError('error: issue {}: \'{}\' status should be followed by a paper number (P1234R5) or proposed resolution in YYYY-MM-DD format'.format(dr.issue, unresolved_status))
153153
proposed_resolution = proposed_resolution_match.group(2)
154154
status = status[:-1-len(proposed_resolution)]
155155
status = status[:-1-len(unresolved_status)]
@@ -236,7 +236,7 @@ def availability(issue):
236236
avail = 'Duplicate of <a href="#%s">%s</a>' % (dup, dup)
237237
_, avail_style, _, _ = availability(dup)
238238
else:
239-
raise AvailabilityError('Unknown status %s for issue %s' % (status, dr.issue))
239+
raise AvailabilityError('error: unknown status %s for issue %s' % (status, dr.issue))
240240
return (avail + avail_suffix, avail_style, unresolved_status, details)
241241

242242
count = {}
@@ -266,7 +266,7 @@ for dr in drs:
266266
else:
267267
if unresolved_status != dr.status:
268268
availability_error_occurred = True
269-
print("Issue %s is marked '%s', which differs from CWG index status '%s'" \
269+
print("error: issue %s is marked '%s', which differs from CWG index status '%s'" \
270270
% (dr.issue, unresolved_status, dr.status))
271271
continue
272272
else:
@@ -280,7 +280,7 @@ for dr in drs:
280280

281281
if unresolved_status:
282282
availability_error_occurred = True
283-
print("Issue %s is marked '%s', even though it is resolved in CWG index" \
283+
print("error: issue %s is marked '%s', even though it is resolved in CWG index" \
284284
% (dr.issue, unresolved_status))
285285
continue
286286

@@ -296,7 +296,7 @@ for dr in drs:
296296
<summary>{avail}</summary>
297297
{details}
298298
</details>'''
299-
out_file.write(f'''
299+
out_html.append(f'''
300300
<tr{row_style} id="{dr.issue}">
301301
<td><a href="https://cplusplus.github.io/CWG/issues/{dr.issue}.html">{dr.issue}</a></td>
302302
<td>{dr.status}</td>
@@ -310,12 +310,14 @@ if availability_error_occurred:
310310
for status, num in sorted(count.items()):
311311
print("%s: %s" % (status, num), file=sys.stderr)
312312

313-
out_file.write('''\
313+
out_html.append('''\
314314
</table>
315315
316316
</div>
317317
</body>
318318
</html>
319319
''')
320-
out_file.close()
321320

321+
out_file = open(output, 'w')
322+
out_file.write(''.join(out_html))
323+
out_file.close()

0 commit comments

Comments
 (0)