Skip to content

Commit 03a3288

Browse files
committed
tests: include stdout of failed commands in JUnit
All of the shell commands used by `make test-cmd` log success and failures to stdout, e.g.: get.sh -> if_has_string -> https://github.com/kubernetes/kubernetes/blob/2c9153576ec0eef9dfb4acac591874a71ff72cbb/hack/lib/test.sh#L340-L360 juLog captured stdout in addition to forwarding it to the overall test stdout, but then only used it to check for text that indicates a problem. The result was that after a test failure, the only thing visible in Spyglass was a fairly useless "script error" generated by juLog for its own call chain. One had to know that the entire build log contained more information and where to look for it. Now the stdout text is included in the JUnit file and thus visible when looking at just one failed test. The output itself is still hard to read (contains one line saying "FAIL!" and one has to know that the text below that line explains the failure), but that is a different story.
1 parent bd55d18 commit 03a3288

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

third_party/forked/shell2junit/sh2ju.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
### -ierror="RegExp" : same as -error but case insensitive
2121
### -fail="RegExp" : Any line from stderr which contains this pattern becomes part of
2222
### the failure messsage, without the text matching that pattern.
23-
### Example: -failure="^ERROR: "
23+
### Example: -fail="^ERROR: "
2424
### Default is to use the entire stderr as failure message.
2525
### -output="Path" : path to output directory, defaults to "./results"
2626
### - Junit reports are left in the folder 'result' under the directory where the script is executed.
@@ -129,6 +129,7 @@ function juLog() {
129129
[[ -n "${H}" ]] && err=1
130130
fi
131131
[[ ${err} -ne 0 ]] && echo "+++ error: ${err}" | tee -a ${outf}
132+
outMsg=$(cat ${outf})
132133
rm -f ${outf}
133134

134135
errMsg=$(cat ${errf})
@@ -163,6 +164,7 @@ ${failureMsg}
163164
<testcase assertions=\"1\" name=\"${name}\" time=\"${time}\" classname=\"${class}\">
164165
${failure}
165166
<system-err><![CDATA[${errMsg}]]></system-err>
167+
<system-out><![CDATA[${outMsg}]]></system-out>
166168
</testcase>
167169
"
168170
## testsuite block

0 commit comments

Comments
 (0)