From: Johannes Schindelin Date: Mon, 23 Mar 2020 12:44:35 +0000 (+0000) Subject: tests(junit-xml): avoid invalid XML X-Git-Tag: v2.27.0-rc0~141^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d3507cc71286c669674d8e184a3796de6af0cea7;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/t/test-lib.sh b/t/test-lib.sh index 0ea1e5a05e..7f0c02c016 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1085,6 +1085,7 @@ finalize_junit_xml () { junit_time=$(test-tool date getnanos $junit_suite_start) sed -e "s/\(]*/& time=\"$junit_time\"/" \ + -e '/^ *<\/testsuite/d' \ <"$junit_xml_path" >"$junit_xml_path.new" mv "$junit_xml_path.new" "$junit_xml_path"