Merge pull request #129701 from pohly/test-shell-output

tests: include stdout of failed commands in JUnit
This commit is contained in:
Kubernetes Prow Robot 2025-01-22 07:18:37 -08:00 committed by GitHub
commit 42c4ddbe2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,7 +20,7 @@
### -ierror="RegExp" : same as -error but case insensitive ### -ierror="RegExp" : same as -error but case insensitive
### -fail="RegExp" : Any line from stderr which contains this pattern becomes part of ### -fail="RegExp" : Any line from stderr which contains this pattern becomes part of
### the failure messsage, without the text matching that pattern. ### the failure messsage, without the text matching that pattern.
### Example: -failure="^ERROR: " ### Example: -fail="^ERROR: "
### Default is to use the entire stderr as failure message. ### Default is to use the entire stderr as failure message.
### -output="Path" : path to output directory, defaults to "./results" ### -output="Path" : path to output directory, defaults to "./results"
### - Junit reports are left in the folder 'result' under the directory where the script is executed. ### - Junit reports are left in the folder 'result' under the directory where the script is executed.
@ -129,6 +129,7 @@ function juLog() {
[[ -n "${H}" ]] && err=1 [[ -n "${H}" ]] && err=1
fi fi
[[ ${err} -ne 0 ]] && echo "+++ error: ${err}" | tee -a ${outf} [[ ${err} -ne 0 ]] && echo "+++ error: ${err}" | tee -a ${outf}
outMsg=$(cat ${outf})
rm -f ${outf} rm -f ${outf}
errMsg=$(cat ${errf}) errMsg=$(cat ${errf})
@ -163,6 +164,7 @@ ${failureMsg}
<testcase assertions=\"1\" name=\"${name}\" time=\"${time}\" classname=\"${class}\"> <testcase assertions=\"1\" name=\"${name}\" time=\"${time}\" classname=\"${class}\">
${failure} ${failure}
<system-err><![CDATA[${errMsg}]]></system-err> <system-err><![CDATA[${errMsg}]]></system-err>
<system-out><![CDATA[${outMsg}]]></system-out>
</testcase> </testcase>
" "
## testsuite block ## testsuite block