Skip to content

Commit

Permalink
KAFKA-17418: Improve markdown formatting in junit.py (apache#17071)
Browse files Browse the repository at this point in the history
Newline characters in the failure message of tests were causing the Markdown tables to be malformed.
This patch fixes that by replacing newlines with "<br>" tags and escaping other HTML that may appear in message.

Reviewers: David Arthur <mumrah@gmail.com>
  • Loading branch information
xijiu authored Sep 10, 2024
1 parent 5cf3098 commit ac4784e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/scripts/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import sys
from typing import Tuple, Optional, List, Iterable
import xml.etree.ElementTree
import html


logger = logging.getLogger()
Expand Down Expand Up @@ -99,6 +100,9 @@ def parse_report(workspace_path, report_path, fp) -> Iterable[TestSuite]:
test_case_failed = False
elif elem.tag == "failure":
failure_message = elem.get("message")
if failure_message:
failure_message = html.escape(failure_message)
failure_message = failure_message.replace('\n', '<br>').replace('\r', '<br>')
failure_class = elem.get("type")
failure_stack_trace = elem.text
failure = partial_test_case(failure_message, failure_class, failure_stack_trace)
Expand Down

0 comments on commit ac4784e

Please sign in to comment.