@@ -10,7 +10,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
10
10
11
11
export artifacts_tmp=" tests/tmp/junit-artifacts"
12
12
export annotation_tmp=" tests/tmp/junit-annotation"
13
-
13
+ export annotation_input= " tests/tmp/annotation.input "
14
14
15
15
@test " runs the annotator and creates the annotation" {
16
16
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
@@ -22,7 +22,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
22
22
23
23
stub buildkite-agent \
24
24
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
25
- " annotate --context \* --style \* : cat >'${annotation_tmp} /annotation.input '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
25
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
26
26
27
27
stub docker \
28
28
" --log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
@@ -32,10 +32,12 @@ export annotation_tmp="tests/tmp/junit-annotation"
32
32
assert_success
33
33
34
34
assert_output --partial " Annotation added with context junit and style error"
35
-
35
+ assert_equal " $( cat " ${annotation_input} " ) " ' <details>Failure</details>'
36
+
36
37
unstub mktemp
37
38
unstub buildkite-agent
38
39
unstub docker
40
+ rm " ${annotation_input} "
39
41
}
40
42
41
43
@@ -49,7 +51,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
49
51
50
52
stub buildkite-agent \
51
53
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
52
- " annotate --context \* --style \* : cat >'${annotation_tmp} /annotation.input '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
54
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
53
55
54
56
stub docker \
55
57
" --log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
@@ -63,6 +65,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
63
65
unstub mktemp
64
66
unstub buildkite-agent
65
67
unstub docker
68
+ rm " ${annotation_input} "
66
69
}
67
70
@test " can pass through optional job uuid file pattern" {
68
71
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
@@ -74,7 +77,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
74
77
75
78
stub buildkite-agent \
76
79
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
77
- " annotate --context \* --style \* : cat >'${annotation_tmp} /annotation.input '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
80
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
78
81
79
82
stub docker \
80
83
" --log-level error run --rm --volume \* --volume \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN='custom_(*)_pattern.xml' --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
@@ -88,11 +91,11 @@ export annotation_tmp="tests/tmp/junit-annotation"
88
91
unstub mktemp
89
92
unstub buildkite-agent
90
93
unstub docker
94
+ rm " ${annotation_input} "
91
95
}
92
96
93
97
@test " can pass through optional failure format" {
94
98
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
95
- export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_CONTEXT=" junit_custom_context"
96
99
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=" file"
97
100
98
101
stub mktemp \
@@ -101,7 +104,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
101
104
102
105
stub buildkite-agent \
103
106
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
104
- " annotate --context \* --style \* : cat >'${annotation_tmp} /annotation.input '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
107
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
105
108
106
109
stub docker \
107
110
" --log-level error run --rm --volume \* --volume \* --env \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT='file' --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
@@ -115,6 +118,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
115
118
unstub mktemp
116
119
unstub buildkite-agent
117
120
unstub docker
121
+ rm " ${annotation_input} "
118
122
}
119
123
120
124
@test " doesn't create annotation unless there's failures" {
@@ -187,7 +191,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
187
191
188
192
stub buildkite-agent \
189
193
" artifact download \* \* : echo Downloaded artifact \$ 3 to \$ 4" \
190
- " annotate --context \* --style \* : cat >'${annotation_tmp} /annotation.input '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
194
+ " annotate --context \* --style \* : cat >'${annotation_input} '; echo Annotation added with context \$ 3 and style \$ 5, content saved"
191
195
192
196
stub docker \
193
197
" --log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
@@ -199,6 +203,7 @@ export annotation_tmp="tests/tmp/junit-annotation"
199
203
unstub mktemp
200
204
unstub buildkite-agent
201
205
unstub docker
206
+ rm " ${annotation_input} "
202
207
}
203
208
204
209
@test " returns an error if fail-build-on-error is true and annotation is too large" {
0 commit comments