diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2020-02-12 11:27:55 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-02-12 09:19:42 -0800 |
commit | 076ee3e8a2a631671dea5787924ed3181c5a919c (patch) | |
tree | 554f3dfc0a1566e4b84ad652899bb8da118c0b8c | |
parent | msvc: accommodate for vcpkg's upgrade to OpenSSL v1.1.x (diff) | |
download | tgif-076ee3e8a2a631671dea5787924ed3181c5a919c.tar.xz |
tests: fix --write-junit-xml with subshells
In t0000, more precisely in its `test_bool_env` test case, there are two
subshells that are supposed to fail. To be even _more_ precise, they
fail by calling the `error` function, and that is okay, because it is in
a subshell, and it is expected that those two subshell invocations fail.
However, the `error` function also tries to finalize the JUnit XML (if
that XML was asked for, via `--write-junit-xml`. As a consequence, the
XML is edited to add a `time` attribute for the `testsuite` tag. And
since there are two expected `error` calls in addition to the final
`test_done`, the `finalize_junit_xml` function is called three times and
naturally the `time` attribute is added _three times_.
Azure Pipelines is not happy with that, complaining thusly:
##[warning]Failed to read D:\a\1\s\t\out\TEST-t0000-basic.xml. Error : 'time' is a duplicate attribute name. Line 2, position 82..
One possible way to address this would be to unset `write_junit_xml` in
the `test_bool_env` test case.
But that would be fragile, as other `error` calls in subshells could be
introduced.
So let's just modify `finalize_junit_xml` to remove any `time` attribute
before adding the authoritative one.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | t/test-lib.sh | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index e06fa02a0e..18065f5689 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1079,7 +1079,8 @@ finalize_junit_xml () { # adjust the overall time junit_time=$(test-tool date getnanos $junit_suite_start) - sed "s/<testsuite [^>]*/& time=\"$junit_time\"/" \ + sed -e "s/\(<testsuite.*\) time=\"[^\"]*\"/\1/" \ + -e "s/<testsuite [^>]*/& time=\"$junit_time\"/" \ <"$junit_xml_path" >"$junit_xml_path.new" mv "$junit_xml_path.new" "$junit_xml_path" |