21
21
function cleanup() {
22
22
return_code=$?
23
23
24
- os::test::junit::generate_report
25
- if [[ " ${JUNIT_REPORT_NUM_FAILED:- } " == " 0 failed" ]]; then
26
- if [[ " ${return_code} " -ne " 0" ]]; then
27
- os::log::warning " While the jUnit report found no failed tests, the \` go test\` process failed."
28
- os::log::warning " This usually means that the unit test suite failed to compile."
29
- fi
30
- fi
31
-
32
24
os::util::describe_return_code " ${return_code} "
33
25
exit " ${return_code} "
34
26
}
@@ -135,11 +127,15 @@ if [[ -n "${junit_report}" ]]; then
135
127
# we don't care if the `go test` fails in this pipe, as we want to generate the report and summarize the output anyway
136
128
set +o pipefail
137
129
138
- go test -i ${gotest_flags} ${test_packages}
139
- go test ${gotest_flags} ${test_packages} 2> " ${test_error_file} " | tee " ${JUNIT_REPORT_OUTPUT} "
130
+ os::util::ensure::built_binary_exists ' gotest2junit '
131
+ report_file= " $( mktemp " ${ARTIFACT_DIR} /unit_report_XXXXX " ) .xml "
140
132
133
+ go test -json ${gotest_flags} ${test_packages} 2> " ${test_error_file} " | tee " ${JUNIT_REPORT_OUTPUT} " | gotest2junit > " ${report_file} "
141
134
test_return_code=" ${PIPESTATUS[0]} "
142
135
136
+ gzip " ${test_error_file} " -c > " ${ARTIFACT_DIR} /unit-error.log.gz"
137
+ gzip " ${JUNIT_REPORT_OUTPUT} " -c > " ${ARTIFACT_DIR} /unit.log.gz"
138
+
143
139
set -o pipefail
144
140
145
141
if [[ -s " ${test_error_file} " ]]; then
@@ -162,7 +158,6 @@ $( cat "${test_error_file}") "
162
158
163
159
elif [[ -n " ${coverage_output_dir} " ]]; then
164
160
# we need to generate coverage reports
165
- go test -i ${gotest_flags} ${test_packages}
166
161
for test_package in ${test_packages} ; do
167
162
mkdir -p " ${coverage_output_dir} /${test_package} "
168
163
local_gotest_flags=" ${gotest_flags} -coverprofile=${coverage_output_dir} /${test_package} /profile.out"
@@ -187,6 +182,5 @@ elif [[ -n "${dlv_debug}" ]]; then
187
182
dlv test ${test_packages}
188
183
else
189
184
# we need to generate neither jUnit XML nor coverage reports
190
- go test -i ${gotest_flags} ${test_packages}
191
185
go test ${gotest_flags} ${test_packages}
192
186
fi
0 commit comments