Skip to content

Commit b42dbed

Browse files
committed
Corrected (and modularized) tests now that there is a new environment variable
1 parent 3326110 commit b42dbed

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

tests/command.bats

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export artifacts_tmp="tests/tmp/junit-artifacts"
1212
export annotation_tmp="tests/tmp/junit-annotation"
1313
export annotation_input="tests/tmp/annotation.input"
1414

15+
DOCKER_STUB_DEFAULT_OPTIONS='--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* --env \* \*'
16+
1517
@test "runs the annotator and creates the annotation" {
1618
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
1719
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=false
@@ -25,7 +27,7 @@ export annotation_input="tests/tmp/annotation.input"
2527
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
2628

2729
stub docker \
28-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
30+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
2931

3032
run "$PWD/hooks/command"
3133

@@ -53,14 +55,14 @@ export annotation_input="tests/tmp/annotation.input"
5355
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
5456

5557
stub docker \
56-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
58+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
5759

5860
run "$PWD/hooks/command"
5961

6062
assert_success
6163

6264
assert_output --partial "Annotation added with context junit_custom_context"
63-
65+
6466
unstub mktemp
6567
unstub buildkite-agent
6668
unstub docker
@@ -80,7 +82,7 @@ export annotation_input="tests/tmp/annotation.input"
8082
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
8183

8284
stub docker \
83-
"--log-level error run --rm --volume \* --volume \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN='custom_(*)_pattern.xml' --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
85+
"--log-level error run --rm --volume \* --volume \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN='custom_(*)_pattern.xml' --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
8486

8587
run "$PWD/hooks/command"
8688

@@ -107,7 +109,7 @@ export annotation_input="tests/tmp/annotation.input"
107109
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
108110

109111
stub docker \
110-
"--log-level error run --rm --volume \* --volume \* --env \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT='file' --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
112+
"--log-level error run --rm --volume \* --volume \* --env \* --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT='file' --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
111113

112114
run "$PWD/hooks/command"
113115

@@ -132,7 +134,7 @@ export annotation_input="tests/tmp/annotation.input"
132134
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
133135

134136
stub docker \
135-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
137+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
136138

137139
run "$PWD/hooks/command"
138140

@@ -156,7 +158,7 @@ export annotation_input="tests/tmp/annotation.input"
156158
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
157159

158160
stub docker \
159-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
161+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
160162

161163
run "$PWD/hooks/command"
162164

@@ -195,7 +197,7 @@ export annotation_input="tests/tmp/annotation.input"
195197
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
196198

197199
stub docker \
198-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
200+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
199201

200202
run "$PWD/hooks/command"
201203

@@ -227,7 +229,7 @@ export annotation_input="tests/tmp/annotation.input"
227229
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
228230

229231
stub docker \
230-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
232+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
231233

232234
run "$PWD/hooks/command"
233235

@@ -257,7 +259,7 @@ export annotation_input="tests/tmp/annotation.input"
257259
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
258260

259261
stub docker \
260-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
262+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
261263

262264
run "$PWD/hooks/command"
263265

@@ -281,12 +283,12 @@ export annotation_input="tests/tmp/annotation.input"
281283
stub du \
282284
"-k \* : echo 1025$'\t'\$2" \
283285
"-k \* : echo 1025$'\t'\$2"
284-
286+
285287
stub buildkite-agent \
286288
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
287289

288290
stub docker \
289-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
291+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
290292

291293
run "$PWD/hooks/command"
292294

@@ -312,7 +314,7 @@ export annotation_input="tests/tmp/annotation.input"
312314
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
313315

314316
stub docker \
315-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 147"
317+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 147"
316318

317319
run "$PWD/hooks/command"
318320

@@ -380,7 +382,7 @@ export annotation_input="tests/tmp/annotation.input"
380382
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
381383

382384
stub docker \
383-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
385+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : echo 'Total tests: 0'"
384386

385387
run "$PWD/hooks/command"
386388

@@ -406,7 +408,7 @@ export annotation_input="tests/tmp/annotation.input"
406408
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
407409

408410
stub docker \
409-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : echo 'Total tests: 100'"
411+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : echo 'Total tests: 100'"
410412

411413
run "$PWD/hooks/command"
412414

@@ -432,7 +434,7 @@ export annotation_input="tests/tmp/annotation.input"
432434
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
433435

434436
stub docker \
435-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* \* ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
437+
"${DOCKER_STUB_DEFAULT_OPTIONS} ruby /src/bin/annotate /junits : cat tests/2-tests-1-failure.output && exit 64"
436438

437439
run "$PWD/hooks/command"
438440

@@ -457,7 +459,7 @@ export annotation_input="tests/tmp/annotation.input"
457459
"annotate --context \* --style \* : cat >'${annotation_input}'; echo Annotation added with context \$3 and style \$5, content saved"
458460

459461
stub docker \
460-
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:special ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
462+
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* --env \* ruby:special ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
461463

462464
run "$PWD/hooks/command"
463465

@@ -470,4 +472,4 @@ export annotation_input="tests/tmp/annotation.input"
470472
unstub buildkite-agent
471473
unstub docker
472474
rm "${annotation_input}"
473-
}
475+
}

0 commit comments

Comments
 (0)