File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed
Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 1010PLUGIN_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) /.."
1111MAX_SIZE=1024 # in KB
1212
13- echo " --- :junit: Download the junits"
14-
1513artifacts_dir=" $( pwd) /$( mktemp -d " junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX" ) "
1614annotation_dir=" $( pwd) /$( mktemp -d " junit-annotate-plugin-annotation-tmp.XXXXXXXXXX" ) "
1715annotation_path=" ${annotation_dir} /annotation.md"
@@ -31,9 +29,11 @@ function check_size {
3129
3230trap cleanup EXIT
3331
34- buildkite-agent artifact download \
35- " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS} " \
36- " $artifacts_dir "
32+ echo " --- :junit: Download the junits"
33+ if ! buildkite-agent artifact download " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS} " " $artifacts_dir " ; then
34+ echo " --- :boom: Could not download artifacts"
35+ exit 2
36+ fi
3737
3838echo " --- :junit: Processing the junits"
3939
@@ -59,7 +59,7 @@ if [[ $exit_code -eq 64 ]]; then # special exit code to signal test failures
5959 fail_build=1
6060 fi
6161elif [[ $exit_code -ne 0 ]]; then
62- echo " 🚨 Error when processing JUnit tests"
62+ echo " --- :boom: Error when processing JUnit tests"
6363 exit $exit_code
6464fi
6565
Original file line number Diff line number Diff line change @@ -260,4 +260,27 @@ export annotation_input="tests/tmp/annotation.input"
260260 unstub mktemp
261261 unstub buildkite-agent
262262 unstub docker
263+ }
264+
265+
266+
267+ @test " error bubbles up when agent download fails" {
268+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
269+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=false
270+
271+ stub mktemp \
272+ " -d \* : mkdir -p '$artifacts_tmp '; echo '$artifacts_tmp '" \
273+ " -d \* : mkdir -p '$annotation_tmp '; echo '$annotation_tmp '"
274+
275+ stub buildkite-agent \
276+ " artifact download \* \* : exit 1"
277+
278+ run " $PWD /hooks/command"
279+
280+ assert_failure 2
281+
282+ assert_output --partial " Could not download artifacts"
283+
284+ unstub mktemp
285+ unstub buildkite-agent
263286}
You can’t perform that action at this time.
0 commit comments