File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -50,15 +50,19 @@ docker \
50
50
ruby:2.7-alpine ruby /src/bin/annotate /junits \
51
51
> " $annotation_path "
52
52
53
- if [[ $? -eq 64 ]]; then # special exit code to signal test failures
53
+ exit_code=$?
54
+ set -e
55
+
56
+ if [[ $exit_code -eq 64 ]]; then # special exit code to signal test failures
54
57
annotation_style=" error"
55
58
if [[ " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR:- false} " =~ (true| on| 1) ]]; then
56
59
fail_build=1
57
60
fi
61
+ elif [[ $exit_code -ne 0 ]]; then
62
+ echo " 🚨 Error when processing JUnit tests"
63
+ exit $exit_code
58
64
fi
59
65
60
- set -e
61
-
62
66
cat " $annotation_path "
63
67
64
68
if grep -q " <details>" " $annotation_path " ; then
Original file line number Diff line number Diff line change @@ -176,8 +176,8 @@ export annotation_input="tests/tmp/annotation.input"
176
176
assert_output --partial " Failures too large to annotate"
177
177
178
178
unstub docker
179
- unstub buildkite-agent
180
179
unstub du
180
+ unstub buildkite-agent
181
181
unstub mktemp
182
182
}
183
183
@@ -231,6 +231,32 @@ export annotation_input="tests/tmp/annotation.input"
231
231
232
232
assert_output --partial " Failures too large to annotate"
233
233
234
+ unstub mktemp
235
+ unstub du
236
+ unstub buildkite-agent
237
+ unstub docker
238
+ }
239
+
240
+ @test " error bubbles up when ruby code fails with anything but 64" {
241
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
242
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=false
243
+
244
+ stub mktemp \
245
+ " -d \* : mkdir -p '$artifacts_tmp '; echo '$artifacts_tmp '" \
246
+ " -d \* : mkdir -p '$annotation_tmp '; echo '$annotation_tmp '"
247
+
248
+ stub buildkite-agent \
249
+ " artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4"
250
+
251
+ stub docker \
252
+ " --log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 147"
253
+
254
+ run " $PWD /hooks/command"
255
+
256
+ assert_failure 147
257
+
258
+ assert_output --partial " Error when processing JUnit tests"
259
+
234
260
unstub mktemp
235
261
unstub buildkite-agent
236
262
unstub docker
You can’t perform that action at this time.
0 commit comments