mirror of
https://github.com/git/git
synced 2024-09-12 21:04:12 +00:00
test(junit): avoid line feeds in XML attributes
In the test case's output, we do want newline characters, but in the XML attributes we do not want them. However, the `xml_attr_encode` function always adds a Line Feed at the end (which are then encoded as `
`, even for XML attributes. This seems not to faze Azure Pipelines' XML parser, but it still is incorrect, so let's fix it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
78d5e4cfb4
commit
270ccd2a67
|
@ -50,7 +50,7 @@ finalize_test_case_output () {
|
||||||
;;
|
;;
|
||||||
failure)
|
failure)
|
||||||
junit_insert="<failure message=\"not ok $test_count -"
|
junit_insert="<failure message=\"not ok $test_count -"
|
||||||
junit_insert="$junit_insert $(xml_attr_encode "$1")\">"
|
junit_insert="$junit_insert $(xml_attr_encode --no-lf "$1")\">"
|
||||||
junit_insert="$junit_insert $(xml_attr_encode \
|
junit_insert="$junit_insert $(xml_attr_encode \
|
||||||
"$(if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
|
"$(if test -n "$GIT_TEST_TEE_OUTPUT_FILE"
|
||||||
then
|
then
|
||||||
|
@ -74,12 +74,12 @@ finalize_test_case_output () {
|
||||||
set "$* (known breakage)"
|
set "$* (known breakage)"
|
||||||
;;
|
;;
|
||||||
skip)
|
skip)
|
||||||
message="$(xml_attr_encode "$skipped_reason")"
|
message="$(xml_attr_encode --no-lf "$skipped_reason")"
|
||||||
set "$1" " <skipped message=\"$message\" />"
|
set "$1" " <skipped message=\"$message\" />"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
junit_attrs="name=\"$(xml_attr_encode "$this_test.$test_count $1")\""
|
junit_attrs="name=\"$(xml_attr_encode --no-lf "$this_test.$test_count $1")\""
|
||||||
shift
|
shift
|
||||||
junit_attrs="$junit_attrs classname=\"$this_test\""
|
junit_attrs="$junit_attrs classname=\"$this_test\""
|
||||||
junit_attrs="$junit_attrs time=\"$(test-tool \
|
junit_attrs="$junit_attrs time=\"$(test-tool \
|
||||||
|
@ -122,5 +122,11 @@ write_junit_xml () {
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_attr_encode () {
|
xml_attr_encode () {
|
||||||
|
if test "x$1" = "x--no-lf"
|
||||||
|
then
|
||||||
|
shift
|
||||||
|
printf '%s' "$*" | test-tool xml-encode
|
||||||
|
else
|
||||||
printf '%s\n' "$@" | test-tool xml-encode
|
printf '%s\n' "$@" | test-tool xml-encode
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue