Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD-322: Encloses the error message when writing a JUnit XML report in a CDATA block #323

Merged
merged 1 commit into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion addons/gdUnit3/src/report/XmlElement.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ func to_xml() -> String:
"attributes": attributes,
"childs": childs,
"_indentation": _indentation(),
"text": _text})
"text": cdata(_text)})

func cdata(text :String) -> String:
return "" if text.empty() else "<![CDATA[\n{text}]]>\n".format({"text" : text})
4 changes: 4 additions & 0 deletions addons/gdUnit3/test/report/XmlElementTest.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func test_add_text() -> void:
.text("This is a message")
var expected = \
"""<testsuites>
<![CDATA[
This is a message
]]>
</testsuites>
""".replace("\r", "")
assert_str(element.to_xml()).is_equal(expected)
Expand Down Expand Up @@ -126,8 +128,10 @@ func test_complex_example() -> void:
</testcase>
<testcase id="2" name="test_case_2">
<failure message="test_case.gd:12" type="FAILURE">
<![CDATA[
This is a failure
Expecting true but was false
]]>
</failure>
</testcase>
<testcase id="3" name="test_case_3">
Expand Down