Have sanity build output a Bazel test summary XML file.

This should avoid needing to download the full log file to find out which check failed, hopefully preventing inadvertent force submits.

PiperOrigin-RevId: 312587296
Change-Id: I788b2bddecbbdf5203c55e28b07c306a0e228fcf
This commit is contained in:
Revan Sopher 2020-05-20 17:26:59 -07:00 committed by TensorFlower Gardener
parent 92d97dfc59
commit d53c999feb

View File

@ -702,23 +702,37 @@ done
# Print summary of build results
COUNTER=0
echo "==== Summary of sanity check results ===="
TESTCASE_XML=''
while [[ ${COUNTER} -lt "${#SANITY_STEPS[@]}" ]]; do
INDEX=COUNTER
((INDEX++))
echo "${INDEX}. ${SANITY_STEPS[COUNTER]}: ${SANITY_STEPS_DESC[COUNTER]}"
TESTCASE_XML="${TESTCASE_XML} <testcase name=\"${SANITY_STEPS_DESC[COUNTER]}\" status=\"run\" classname=\"\" time=\"0\">"
if [[ ${STEP_EXIT_CODES[COUNTER]} == "0" ]]; then
printf " ${COLOR_GREEN}PASS${COLOR_NC}\n"
else
printf " ${COLOR_RED}FAIL${COLOR_NC}\n"
TESTCASE_XML="${TESTCASE_XML} <failure message=\"\" type=\"\"/>"
fi
TESTCASE_XML="${TESTCASE_XML} </testcase>"
((COUNTER++))
done
echo
echo "${FAIL_COUNTER} failed; ${PASS_COUNTER} passed."
mkdir -p "${KOKORO_ARTIFACTS_DIR}/${KOKORO_JOB_NAME}/summary"
echo '<?xml version="1.0" encoding="UTF-8"?>'\
'<testsuites name="1" tests="1" failures="0" errors="0" time="0">'\
'<testsuite name="Kokoro Summary" tests="'"$((FAIL_COUNTER + PASS_COUNTER))"\
'" failures="'"${FAIL_COUNTER}"'" errors="0" time="0">'\
"${TESTCASE_XML}"'</testsuite></testsuites>'\
> "${KOKORO_ARTIFACTS_DIR}/${KOKORO_JOB_NAME}/summary/sponge_log.xml"
echo
if [[ ${FAIL_COUNTER} == "0" ]]; then
printf "Sanity checks ${COLOR_GREEN}PASSED${COLOR_NC}\n"