@matheusbsbs / matheus-bagliano / commits / d3507cc712
Fork 0

tests(junit-xml): avoid invalid XML

When a test case is run in a subshell, we finalize the JUnit-style XML when said subshell exits. But then we continue to write into that XML as if nothing had happened. This leads to Azure Pipelines' Publish Test Results task complaining: Failed to read /home/vsts/work/1/s/t/out/TEST-t0000-basic.xml. Error : Unexpected end tag. Line 110, position 5. And indeed, the resulting XML is incorrect. Let's "re-open" the XML in such a case, i.e. remove the previously added closing tags. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Mar 23, 2020 at 12:44 UTC d3507cc71286c669674d8e184a3796de6af0cea7
1 file changed +1
t/test-lib.sh
+1
@@ -1085,6 +1085,7 @@ finalize_junit_xml () {
1085 junit_time=$(test-tool date getnanos $junit_suite_start)
1086 sed -e "s/\(<testsuite.*\) time=\"[^\"]*\"/\1/" \
1087 -e "s/<testsuite [^>]*/& time=\"$junit_time\"/" \
1088 + -e '/^ *<\/testsuite/d' \
1089 <"$junit_xml_path" >"$junit_xml_path.new"
1090 mv "$junit_xml_path.new" "$junit_xml_path"
1091