Skip to content

Commit a3083a9

Browse files
committed
[Backend Tester] Add error message field to CSV report
ghstack-source-id: fe93cd1 ghstack-comment-id: 3257219383 Pull-Request: #13991
1 parent 0ee1054 commit a3083a9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

backends/test/suite/reporting.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
]
4646
)
4747

48+
CSV_FIELD_NAMES.append("Error")
49+
4850

4951
# Operators that are excluded from the counts returned by count_ops. These are used to
5052
# exclude operatations that are not logically relevant or delegatable to backends.
@@ -365,6 +367,15 @@ def write_csv_header(output: TextIO):
365367
def write_csv_row(record: TestCaseSummary, output: TextIO):
366368
writer = csv.DictWriter(output, CSV_FIELD_NAMES)
367369

370+
# Truncate error message if it's too long, keeping first and last 200 characters
371+
error_message = ""
372+
if record.error is not None:
373+
error_str = str(record.error)
374+
if len(error_str) > 400:
375+
error_message = error_str[:200] + "..." + error_str[-200:]
376+
else:
377+
error_message = error_str
378+
368379
row = {
369380
"Test ID": record.name,
370381
"Test Case": record.base_name,
@@ -373,6 +384,7 @@ def write_csv_row(record: TestCaseSummary, output: TextIO):
373384
"Params": _serialize_params(record.params),
374385
"Result": record.result.to_short_str(),
375386
"Result Detail": record.result.to_detail_str(),
387+
"Error": error_message,
376388
"Delegated": "True" if record.is_delegated() else "False",
377389
"Quantize Time (s)": (
378390
f"{record.quantize_time.total_seconds():.3f}"

0 commit comments

Comments
 (0)