Skip to content

Commit ba12980

Browse files
committed
Made stubs a lot more generic
1 parent 3a747e0 commit ba12980

File tree

1 file changed

+43
-29
lines changed

1 file changed

+43
-29
lines changed

tests/command.bats

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ export annotation_tmp="tests/tmp/junit-annotation"
1717
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=false
1818

1919
stub mktemp \
20-
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
21-
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
20+
"-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
21+
"-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
2222

23-
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts" \
24-
"annotate --context junit --style error : echo Annotation added"
23+
stub buildkite-agent \
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"
2526

26-
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
27+
stub docker \
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"
2729

2830
run "$PWD/hooks/command"
2931

@@ -41,13 +43,15 @@ export annotation_tmp="tests/tmp/junit-annotation"
4143
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=true
4244

4345
stub mktemp \
44-
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
45-
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
46+
"-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
47+
"-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
4648

47-
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts" \
48-
"annotate --context junit --style error : echo Annotation added"
49+
stub buildkite-agent \
50+
"artifact download \* \* : echo Downloaded artifact \$3 to \$4" \
51+
"annotate --context \* --style \* : cat >'${annotation_tmp}/annotation.input'; echo Annotation added with context \$3 and style \$5, content saved"
4952

50-
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
53+
stub docker \
54+
"--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"
5155

5256
run "$PWD/hooks/command"
5357

@@ -66,13 +70,15 @@ export annotation_tmp="tests/tmp/junit-annotation"
6670
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_CONTEXT="junit_custom_context"
6771

6872
stub mktemp \
69-
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
70-
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
73+
"-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
74+
"-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
7175

72-
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts" \
73-
"annotate --context junit_custom_context --style error : echo Annotation added"
76+
stub buildkite-agent \
77+
"artifact download \* \* : echo Downloaded artifact \$3 to \$4" \
78+
"annotate --context \* --style \* : cat >'${annotation_tmp}/annotation.input'; echo Annotation added with context \$3 and style \$5, content saved"
7479

75-
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN='custom_(*)_pattern.xml' --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT='file' --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
80+
stub docker \
81+
"--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"
7682

7783
run "$PWD/hooks/command"
7884

@@ -89,12 +95,14 @@ export annotation_tmp="tests/tmp/junit-annotation"
8995
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
9096

9197
stub mktemp \
92-
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
93-
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
98+
"-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
99+
"-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
94100

95-
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts"
101+
stub buildkite-agent \
102+
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
96103

97-
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo No test errors"
104+
stub docker \
105+
"--log-level error run --rm --volume \* --volume \* --env \* --env \* --env \* ruby:2.7-alpine ruby /src/bin/annotate /junits : echo No test errors"
98106

99107
run "$PWD/hooks/command"
100108

@@ -117,15 +125,18 @@ export annotation_tmp="tests/tmp/junit-annotation"
117125
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS="junits/*.xml"
118126

119127
stub mktemp \
120-
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
121-
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
128+
"-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
129+
"-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
122130

123131
# 1KB over the 1MB size limit of annotations
124-
stub du "-k /plugin/tests/tmp//plugin/junit-annotation/annotation.md : echo 1025 /plugin/tests/tmp//plugin/junit-annotation/annotation.md"
132+
stub du \
133+
"-k \* : echo 1025 \$2"
125134

126-
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts"
135+
stub buildkite-agent \
136+
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
127137

128-
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
138+
stub docker \
139+
"--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"
129140

130141
run "$PWD/hooks/command"
131142

@@ -144,15 +155,18 @@ export annotation_tmp="tests/tmp/junit-annotation"
144155
export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=true
145156

146157
stub mktemp \
147-
"-d junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX : mkdir -p $artifacts_tmp; echo $artifacts_tmp" \
148-
"-d junit-annotate-plugin-annotation-tmp.XXXXXXXXXX : mkdir -p $annotation_tmp; echo $annotation_tmp"
158+
"-d \* : mkdir -p '$artifacts_tmp'; echo '$artifacts_tmp'" \
159+
"-d \* : mkdir -p '$annotation_tmp'; echo '$annotation_tmp'"
149160

150161
# 1KB over the 1MB size limit of annotations
151-
stub du "-k /plugin/tests/tmp//plugin/junit-annotation/annotation.md : echo 1025 /plugin/tests/tmp//plugin/junit-annotation/annotation.md"
162+
stub du \
163+
"-k \* : echo 1025 \$2"
152164

153-
stub buildkite-agent "artifact download junits/*.xml /plugin/tests/tmp//plugin/junit-artifacts : echo Downloaded artifacts"
165+
stub buildkite-agent \
166+
"artifact download \* \* : echo Downloaded artifact \$3 to \$4"
154167

155-
stub docker "--log-level error run --rm --volume /plugin/tests/tmp//plugin/junit-artifacts:/junits --volume /plugin/hooks/../ruby:/src --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT= --env BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST= ruby:2.7-alpine ruby /src/bin/annotate /junits : echo '<details>Failure</details>' && exit 64"
168+
stub docker \
169+
"--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"
156170

157171
run "$PWD/hooks/command"
158172

0 commit comments

Comments
 (0)