@@ -161,7 +161,7 @@ export annotation_input="tests/tmp/annotation.input"
161
161
run " $PWD /hooks/command"
162
162
163
163
assert_success
164
- assert_output --partial " No tests errors"
164
+ assert_output --partial " No test errors"
165
165
assert_output --partial " Will create annotation anyways"
166
166
167
167
unstub mktemp
@@ -178,7 +178,7 @@ export annotation_input="tests/tmp/annotation.input"
178
178
refute_output --partial " :junit:"
179
179
}
180
180
181
- @test " fails if the annotation is larger than 1MB" {
181
+ @test " fails if the annotation is larger than 1MB even after summary " {
182
182
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
183
183
184
184
stub mktemp \
@@ -187,7 +187,8 @@ export annotation_input="tests/tmp/annotation.input"
187
187
188
188
# 1KB over the 1MB size limit of annotations
189
189
stub du \
190
- " -k \* : echo 1025 \$ 2"
190
+ " -k \* : echo 1025$'\t'\$ 2" \
191
+ " -k \* : echo 1025$'\t'\$ 2"
191
192
192
193
stub buildkite-agent \
193
194
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4"
@@ -200,13 +201,47 @@ export annotation_input="tests/tmp/annotation.input"
200
201
assert_success
201
202
202
203
assert_output --partial " Failures too large to annotate"
204
+ assert_output --partial " failures are too large to create a build annotation"
203
205
204
206
unstub docker
205
207
unstub du
206
208
unstub buildkite-agent
207
209
unstub mktemp
208
210
}
209
211
212
+ @test " creates summary annotation if original is larger than 1MB" {
213
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
214
+
215
+ stub mktemp \
216
+ " -d \* : mkdir -p '$artifacts_tmp '; echo '$artifacts_tmp '" \
217
+ " -d \* : mkdir -p '$annotation_tmp '; echo '$annotation_tmp '"
218
+
219
+ # 1KB over the 1MB size limit of annotations
220
+ stub du \
221
+ " -k \* : echo 1025$'\t'\$ 2" \
222
+ " -k \* : echo 10$'\t'\$ 2"
223
+
224
+ stub buildkite-agent \
225
+ " artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
226
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
227
+
228
+ stub docker \
229
+ " --log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
230
+
231
+ run " $PWD /hooks/command"
232
+
233
+ assert_success
234
+
235
+ assert_output --partial " Failures too large to annotate"
236
+ assert_output --partial " using a simplified annotation"
237
+ assert_equal " 5 ${annotation_input} " " $( wc -l " ${annotation_input} " | cut -f 1) "
238
+
239
+ unstub docker
240
+ unstub du
241
+ unstub buildkite-agent
242
+ unstub mktemp
243
+ rm " ${annotation_input} "
244
+ }
210
245
211
246
@test " returns an error if fail-build-on-error is true" {
212
247
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
@@ -243,7 +278,8 @@ export annotation_input="tests/tmp/annotation.input"
243
278
244
279
# 1KB over the 1MB size limit of annotations
245
280
stub du \
246
- " -k \* : echo 1025 \$ 2"
281
+ " -k \* : echo 1025$'\t'\$ 2" \
282
+ " -k \* : echo 1025$'\t'\$ 2"
247
283
248
284
stub buildkite-agent \
249
285
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4"
0 commit comments