From 268b6cd2bbba40809fe93c7ddc59c56a501bd866 Mon Sep 17 00:00:00 2001 From: Mike Schulze Date: Sat, 24 Sep 2022 17:23:51 +0200 Subject: [PATCH] GD-322: Enclose failure message in a CDATA block when writing JUnit XML report - a failure message was writen plain in the XML and resultiong in a invalid XML - fixed by enclose the message in a CDATA block --- addons/gdUnit3/src/report/XmlElement.gd | 5 ++++- addons/gdUnit3/test/report/XmlElementTest.gd | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/gdUnit3/src/report/XmlElement.gd b/addons/gdUnit3/src/report/XmlElement.gd index 03fc0376..2227e695 100644 --- a/addons/gdUnit3/src/report/XmlElement.gd +++ b/addons/gdUnit3/src/report/XmlElement.gd @@ -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 "\n".format({"text" : text}) diff --git a/addons/gdUnit3/test/report/XmlElementTest.gd b/addons/gdUnit3/test/report/XmlElementTest.gd index b27a214f..64d3e753 100644 --- a/addons/gdUnit3/test/report/XmlElementTest.gd +++ b/addons/gdUnit3/test/report/XmlElementTest.gd @@ -71,7 +71,9 @@ func test_add_text() -> void: .text("This is a message") var expected = \ """ + """.replace("\r", "") assert_str(element.to_xml()).is_equal(expected) @@ -126,8 +128,10 @@ func test_complex_example() -> void: +