Blame


1 5565365c 2024-03-27 op #!/bin/sh
2 5565365c 2024-03-27 op #
3 5565365c 2024-03-27 op # Copyright (c) 2024 Omar Polo <op@openbsd.org>
4 5565365c 2024-03-27 op #
5 5565365c 2024-03-27 op # Permission to use, copy, modify, and distribute this software for any
6 5565365c 2024-03-27 op # purpose with or without fee is hereby granted, provided that the above
7 5565365c 2024-03-27 op # copyright notice and this permission notice appear in all copies.
8 5565365c 2024-03-27 op #
9 5565365c 2024-03-27 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 5565365c 2024-03-27 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 5565365c 2024-03-27 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 5565365c 2024-03-27 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 5565365c 2024-03-27 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 5565365c 2024-03-27 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 5565365c 2024-03-27 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 5565365c 2024-03-27 op
17 5565365c 2024-03-27 op . ../cmdline/common.sh
18 5565365c 2024-03-27 op . ./common.sh
19 5565365c 2024-03-27 op
20 050c0b8c 2024-04-16 op # flan:password encoded in base64
21 050c0b8c 2024-04-16 op AUTH="ZmxhbjpwYXNzd29yZA=="
22 050c0b8c 2024-04-16 op
23 5565365c 2024-03-27 op test_file_changed() {
24 5565365c 2024-03-27 op local testroot=`test_init file_changed 1`
25 5565365c 2024-03-27 op
26 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
27 5565365c 2024-03-27 op ret=$?
28 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
29 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
30 5565365c 2024-03-27 op test_done "$testroot" 1
31 5565365c 2024-03-27 op return 1
32 5565365c 2024-03-27 op fi
33 5565365c 2024-03-27 op
34 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
35 5565365c 2024-03-27 op ret=$?
36 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
37 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
38 5565365c 2024-03-27 op test_done "$testroot" 1
39 5565365c 2024-03-27 op return 1
40 5565365c 2024-03-27 op fi
41 5565365c 2024-03-27 op
42 5565365c 2024-03-27 op echo "change alpha" > $testroot/wt/alpha
43 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
44 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
45 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
46 5565365c 2024-03-27 op
47 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
48 5565365c 2024-03-27 op > $testroot/stdout &
49 5565365c 2024-03-27 op
50 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
51 5565365c 2024-03-27 op ret=$?
52 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
53 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
54 5565365c 2024-03-27 op test_done "$testroot" "1"
55 5565365c 2024-03-27 op return 1
56 5565365c 2024-03-27 op fi
57 5565365c 2024-03-27 op
58 5565365c 2024-03-27 op wait %1 # wait for the http "server"
59 5565365c 2024-03-27 op
60 5565365c 2024-03-27 op d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
61 5565365c 2024-03-27 op
62 87890bc2 2024-03-28 op touch "$testroot/stdout.expected"
63 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
64 87890bc2 2024-03-28 op a
65 87890bc2 2024-03-28 op {"notifications":[{
66 93623901 2024-03-28 op "type":"commit",
67 87890bc2 2024-03-28 op "short":false,
68 c1003102 2024-04-15 op "repo":"test-repo",
69 87890bc2 2024-03-28 op "id":"$commit_id",
70 ac0a4dfc 2024-03-28 op "author":{
71 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
72 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
73 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
74 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
75 ac0a4dfc 2024-03-28 op },
76 ac0a4dfc 2024-03-28 op "committer":{
77 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
78 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
79 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
80 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
81 ac0a4dfc 2024-03-28 op },
82 87890bc2 2024-03-28 op "date":"$d",
83 ac0a4dfc 2024-03-28 op "short_message":"make changes",
84 87890bc2 2024-03-28 op "message":"make changes\n",
85 763b7f49 2024-03-28 op "diffstat":{
86 763b7f49 2024-03-28 op "files":[{
87 763b7f49 2024-03-28 op "action":"modified",
88 763b7f49 2024-03-28 op "file":"alpha",
89 763b7f49 2024-03-28 op "added":1,
90 763b7f49 2024-03-28 op "removed":1
91 763b7f49 2024-03-28 op }],
92 763b7f49 2024-03-28 op "total":{
93 763b7f49 2024-03-28 op "added":1,
94 763b7f49 2024-03-28 op "removed":1
95 763b7f49 2024-03-28 op }
96 763b7f49 2024-03-28 op }
97 ea5e974d 2024-03-28 op }]}
98 ea5e974d 2024-03-28 op .
99 ea5e974d 2024-03-28 op ,j
100 ea5e974d 2024-03-28 op w
101 ea5e974d 2024-03-28 op EOF
102 ea5e974d 2024-03-28 op
103 ea5e974d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
104 ea5e974d 2024-03-28 op ret=$?
105 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
106 ea5e974d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
107 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
108 ea5e974d 2024-03-28 op return 1
109 ea5e974d 2024-03-28 op fi
110 ea5e974d 2024-03-28 op
111 ea5e974d 2024-03-28 op test_done "$testroot" "$ret"
112 ea5e974d 2024-03-28 op }
113 ea5e974d 2024-03-28 op
114 ea5e974d 2024-03-28 op test_bad_utf8() {
115 ea5e974d 2024-03-28 op local testroot=`test_init bad_utf8 1`
116 ea5e974d 2024-03-28 op
117 ea5e974d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
118 ea5e974d 2024-03-28 op ret=$?
119 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
120 ea5e974d 2024-03-28 op echo "got clone failed unexpectedly" >&2
121 ea5e974d 2024-03-28 op test_done "$testroot" 1
122 ea5e974d 2024-03-28 op return 1
123 ea5e974d 2024-03-28 op fi
124 ea5e974d 2024-03-28 op
125 ea5e974d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
126 ea5e974d 2024-03-28 op ret=$?
127 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
128 ea5e974d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
129 ea5e974d 2024-03-28 op test_done "$testroot" 1
130 ea5e974d 2024-03-28 op fi
131 ea5e974d 2024-03-28 op
132 cdaefb15 2024-03-28 stsp # invalid utf8 sequence
133 ea5e974d 2024-03-28 op commit_msg="make$(printf '\xED\xA0\x80')changes"
134 ea5e974d 2024-03-28 op
135 ea5e974d 2024-03-28 op echo "changed" > $testroot/wt/alpha
136 ea5e974d 2024-03-28 op (cd $testroot/wt && got commit -m "$commit_msg" > /dev/null)
137 ea5e974d 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
138 ea5e974d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone`
139 ea5e974d 2024-03-28 op
140 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \
141 ea5e974d 2024-03-28 op > $testroot/stdout &
142 ea5e974d 2024-03-28 op
143 ea5e974d 2024-03-28 op got send -b main -q -r $testroot/repo-clone
144 ea5e974d 2024-03-28 op ret=$?
145 ea5e974d 2024-03-28 op if [ $ret -ne 0 ]; then
146 ea5e974d 2024-03-28 op echo "got send failed unexpectedly" >&2
147 ea5e974d 2024-03-28 op test_done "$testroot" "1"
148 ea5e974d 2024-03-28 op return 1
149 ea5e974d 2024-03-28 op fi
150 ea5e974d 2024-03-28 op
151 ea5e974d 2024-03-28 op wait %1 # wait for the http "server"
152 ea5e974d 2024-03-28 op
153 ea5e974d 2024-03-28 op d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
154 ea5e974d 2024-03-28 op
155 ea5e974d 2024-03-28 op touch "$testroot/stdout.expected"
156 ea5e974d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
157 ea5e974d 2024-03-28 op a
158 ea5e974d 2024-03-28 op {"notifications":[{
159 93623901 2024-03-28 op "type":"commit",
160 ea5e974d 2024-03-28 op "short":false,
161 c1003102 2024-04-15 op "repo":"test-repo",
162 ea5e974d 2024-03-28 op "id":"$commit_id",
163 ac0a4dfc 2024-03-28 op "author":{
164 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
165 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
166 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
167 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
168 ac0a4dfc 2024-03-28 op },
169 ac0a4dfc 2024-03-28 op "committer":{
170 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
171 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
172 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
173 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
174 ac0a4dfc 2024-03-28 op },
175 ea5e974d 2024-03-28 op "date":"$d",
176 ac0a4dfc 2024-03-28 op "short_message":"make\uFFFD\uFFFDchanges",
177 ea5e974d 2024-03-28 op "message":"make\uFFFD\uFFFDchanges\n",
178 763b7f49 2024-03-28 op "diffstat":{
179 763b7f49 2024-03-28 op "files":[{
180 763b7f49 2024-03-28 op "action":"modified",
181 763b7f49 2024-03-28 op "file":"alpha",
182 763b7f49 2024-03-28 op "added":1,
183 763b7f49 2024-03-28 op "removed":1
184 763b7f49 2024-03-28 op }],
185 763b7f49 2024-03-28 op "total":{
186 763b7f49 2024-03-28 op "added":1,
187 763b7f49 2024-03-28 op "removed":1
188 763b7f49 2024-03-28 op }
189 763b7f49 2024-03-28 op }
190 87890bc2 2024-03-28 op }]}
191 87890bc2 2024-03-28 op .
192 87890bc2 2024-03-28 op ,j
193 87890bc2 2024-03-28 op w
194 5565365c 2024-03-27 op EOF
195 5565365c 2024-03-27 op
196 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
197 5565365c 2024-03-27 op ret=$?
198 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
199 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
200 5565365c 2024-03-27 op test_done "$testroot" "$ret"
201 5565365c 2024-03-27 op return 1
202 5565365c 2024-03-27 op fi
203 5565365c 2024-03-27 op
204 5565365c 2024-03-27 op test_done "$testroot" "$ret"
205 5565365c 2024-03-27 op }
206 5565365c 2024-03-27 op
207 5565365c 2024-03-27 op test_many_commits_not_summarized() {
208 5565365c 2024-03-27 op local testroot=`test_init many_commits_not_summarized 1`
209 5565365c 2024-03-27 op
210 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
211 5565365c 2024-03-27 op ret=$?
212 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
213 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
214 5565365c 2024-03-27 op test_done "$testroot" 1
215 5565365c 2024-03-27 op return 1
216 5565365c 2024-03-27 op fi
217 5565365c 2024-03-27 op
218 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
219 5565365c 2024-03-27 op ret=$?
220 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
221 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
222 5565365c 2024-03-27 op test_done "$testroot" 1
223 5565365c 2024-03-27 op return 1
224 5565365c 2024-03-27 op fi
225 5565365c 2024-03-27 op
226 5565365c 2024-03-27 op for i in `seq 1 24`; do
227 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
228 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
229 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
230 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
231 5565365c 2024-03-27 op d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
232 5565365c 2024-03-27 op set -- "$@" "$commit_id $d"
233 5565365c 2024-03-27 op done
234 5565365c 2024-03-27 op
235 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
236 5565365c 2024-03-27 op > $testroot/stdout &
237 5565365c 2024-03-27 op
238 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
239 5565365c 2024-03-27 op ret=$?
240 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
241 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
242 5565365c 2024-03-27 op test_done "$testroot" "1"
243 5565365c 2024-03-27 op return 1
244 5565365c 2024-03-27 op fi
245 5565365c 2024-03-27 op
246 5565365c 2024-03-27 op wait %1 # wait for the http "server"
247 5565365c 2024-03-27 op
248 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
249 5565365c 2024-03-27 op comma=""
250 5565365c 2024-03-27 op for i in `seq 1 24`; do
251 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
252 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
253 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
254 87890bc2 2024-03-28 op
255 87890bc2 2024-03-28 op echo "$comma"
256 87890bc2 2024-03-28 op comma=','
257 87890bc2 2024-03-28 op
258 87890bc2 2024-03-28 op cat <<-EOF
259 87890bc2 2024-03-28 op {
260 93623901 2024-03-28 op "type":"commit",
261 87890bc2 2024-03-28 op "short":false,
262 c1003102 2024-04-15 op "repo":"test-repo",
263 87890bc2 2024-03-28 op "id":"$commit_id",
264 ac0a4dfc 2024-03-28 op "author":{
265 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
266 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
267 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
268 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
269 ac0a4dfc 2024-03-28 op },
270 ac0a4dfc 2024-03-28 op "committer":{
271 ac0a4dfc 2024-03-28 op "full":"$GOT_AUTHOR",
272 ac0a4dfc 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
273 ac0a4dfc 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
274 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_11"
275 ac0a4dfc 2024-03-28 op },
276 87890bc2 2024-03-28 op "date":"$commit_time",
277 ac0a4dfc 2024-03-28 op "short_message":"make changes",
278 87890bc2 2024-03-28 op "message":"make changes\n",
279 763b7f49 2024-03-28 op "diffstat":{
280 763b7f49 2024-03-28 op "files":[{
281 763b7f49 2024-03-28 op "action":"modified",
282 763b7f49 2024-03-28 op "file":"alpha",
283 763b7f49 2024-03-28 op "added":1,
284 763b7f49 2024-03-28 op "removed":1
285 763b7f49 2024-03-28 op }],
286 763b7f49 2024-03-28 op "total":{
287 763b7f49 2024-03-28 op "added":1,
288 763b7f49 2024-03-28 op "removed":1
289 763b7f49 2024-03-28 op }
290 763b7f49 2024-03-28 op }
291 87890bc2 2024-03-28 op }
292 87890bc2 2024-03-28 op EOF
293 5565365c 2024-03-27 op done >> $testroot/stdout.expected
294 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
295 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
296 87890bc2 2024-03-28 op ,j
297 87890bc2 2024-03-28 op w
298 87890bc2 2024-03-28 op EOF
299 5565365c 2024-03-27 op
300 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
301 5565365c 2024-03-27 op ret=$?
302 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
303 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
304 5565365c 2024-03-27 op test_done "$testroot" "$ret"
305 5565365c 2024-03-27 op return 1
306 5565365c 2024-03-27 op fi
307 5565365c 2024-03-27 op
308 5565365c 2024-03-27 op test_done "$testroot" "$ret"
309 5565365c 2024-03-27 op }
310 5565365c 2024-03-27 op
311 5565365c 2024-03-27 op test_many_commits_summarized() {
312 5565365c 2024-03-27 op local testroot=`test_init many_commits_summarized 1`
313 5565365c 2024-03-27 op
314 5565365c 2024-03-27 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
315 5565365c 2024-03-27 op ret=$?
316 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
317 5565365c 2024-03-27 op echo "got clone failed unexpectedly" >&2
318 5565365c 2024-03-27 op test_done "$testroot" 1
319 5565365c 2024-03-27 op return 1
320 5565365c 2024-03-27 op fi
321 5565365c 2024-03-27 op
322 5565365c 2024-03-27 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
323 5565365c 2024-03-27 op ret=$?
324 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
325 5565365c 2024-03-27 op echo "got checkout failed unexpectedly" >&2
326 5565365c 2024-03-27 op test_done "$testroot" 1
327 5565365c 2024-03-27 op return 1
328 5565365c 2024-03-27 op fi
329 5565365c 2024-03-27 op
330 5565365c 2024-03-27 op for i in `seq 1 51`; do
331 5565365c 2024-03-27 op echo "alpha $i" > $testroot/wt/alpha
332 5565365c 2024-03-27 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
333 5565365c 2024-03-27 op local commit_id=`git_show_head $testroot/repo-clone`
334 5565365c 2024-03-27 op local short_commit_id=`trim_obj_id 33 $commit_id`
335 5565365c 2024-03-27 op local author_time=`git_show_author_time $testroot/repo-clone`
336 5565365c 2024-03-27 op d=`date -u -r $author_time +"%G-%m-%d"`
337 5565365c 2024-03-27 op set -- "$@" "$short_commit_id $d"
338 5565365c 2024-03-27 op done
339 5565365c 2024-03-27 op
340 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
341 5565365c 2024-03-27 op > $testroot/stdout &
342 5565365c 2024-03-27 op
343 5565365c 2024-03-27 op got send -b main -q -r $testroot/repo-clone
344 5565365c 2024-03-27 op ret=$?
345 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
346 5565365c 2024-03-27 op echo "got send failed unexpectedly" >&2
347 5565365c 2024-03-27 op test_done "$testroot" "1"
348 5565365c 2024-03-27 op return 1
349 5565365c 2024-03-27 op fi
350 5565365c 2024-03-27 op
351 5565365c 2024-03-27 op wait %1 # wait for the http "server"
352 5565365c 2024-03-27 op
353 9e88f9d9 2024-03-28 op printf '{"notifications":[' > $testroot/stdout.expected
354 5565365c 2024-03-27 op comma=""
355 5565365c 2024-03-27 op for i in `seq 1 51`; do
356 5565365c 2024-03-27 op s=`pop_idx $i "$@"`
357 5565365c 2024-03-27 op commit_id=$(echo $s | cut -d' ' -f1)
358 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
359 87890bc2 2024-03-28 op
360 87890bc2 2024-03-28 op echo "$comma"
361 87890bc2 2024-03-28 op comma=','
362 87890bc2 2024-03-28 op
363 87890bc2 2024-03-28 op cat <<-EOF
364 87890bc2 2024-03-28 op {
365 93623901 2024-03-28 op "type":"commit",
366 87890bc2 2024-03-28 op "short":true,
367 c1003102 2024-04-15 op "repo":"test-repo",
368 87890bc2 2024-03-28 op "id":"$commit_id",
369 ac0a4dfc 2024-03-28 op "committer":{
370 ac0a4dfc 2024-03-28 op "user":"$GOT_AUTHOR_8"
371 ac0a4dfc 2024-03-28 op },
372 87890bc2 2024-03-28 op "date":"$commit_time",
373 ac0a4dfc 2024-03-28 op "short_message":"make changes"
374 87890bc2 2024-03-28 op }
375 87890bc2 2024-03-28 op EOF
376 5565365c 2024-03-27 op done >> $testroot/stdout.expected
377 5565365c 2024-03-27 op echo "]}" >> $testroot/stdout.expected
378 914bfd3d 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
379 914bfd3d 2024-03-28 op ,j
380 914bfd3d 2024-03-28 op w
381 914bfd3d 2024-03-28 op EOF
382 914bfd3d 2024-03-28 op
383 914bfd3d 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
384 914bfd3d 2024-03-28 op ret=$?
385 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
386 914bfd3d 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
387 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
388 914bfd3d 2024-03-28 op return 1
389 914bfd3d 2024-03-28 op fi
390 914bfd3d 2024-03-28 op
391 914bfd3d 2024-03-28 op test_done "$testroot" "$ret"
392 914bfd3d 2024-03-28 op }
393 914bfd3d 2024-03-28 op
394 914bfd3d 2024-03-28 op test_branch_created() {
395 914bfd3d 2024-03-28 op local testroot=`test_init branch_created 1`
396 914bfd3d 2024-03-28 op
397 914bfd3d 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
398 914bfd3d 2024-03-28 op ret=$?
399 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
400 914bfd3d 2024-03-28 op echo "got clone failed unexpectedly" >&2
401 914bfd3d 2024-03-28 op test_done "$testroot" 1
402 914bfd3d 2024-03-28 op return 1
403 914bfd3d 2024-03-28 op fi
404 914bfd3d 2024-03-28 op
405 914bfd3d 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
406 914bfd3d 2024-03-28 op ret=$?
407 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
408 914bfd3d 2024-03-28 op echo "got checkout failed unexpectedly" >&2
409 914bfd3d 2024-03-28 op test_done "$testroot" 1
410 914bfd3d 2024-03-28 op return 1
411 914bfd3d 2024-03-28 op fi
412 914bfd3d 2024-03-28 op
413 914bfd3d 2024-03-28 op (cd $testroot/wt && got branch newbranch > /dev/null)
414 914bfd3d 2024-03-28 op
415 914bfd3d 2024-03-28 op echo "change alpha on branch" > $testroot/wt/alpha
416 914bfd3d 2024-03-28 op (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
417 914bfd3d 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
418 914bfd3d 2024-03-28 op local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
419 914bfd3d 2024-03-28 op
420 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
421 914bfd3d 2024-03-28 op > $testroot/stdout &
422 914bfd3d 2024-03-28 op
423 914bfd3d 2024-03-28 op got send -b newbranch -q -r $testroot/repo-clone
424 914bfd3d 2024-03-28 op ret=$?
425 914bfd3d 2024-03-28 op if [ $ret -ne 0 ]; then
426 914bfd3d 2024-03-28 op echo "got send failed unexpectedly" >&2
427 914bfd3d 2024-03-28 op test_done "$testroot" "1"
428 914bfd3d 2024-03-28 op return 1
429 914bfd3d 2024-03-28 op fi
430 914bfd3d 2024-03-28 op
431 914bfd3d 2024-03-28 op wait %1 # wait for the http "server"
432 914bfd3d 2024-03-28 op
433 914bfd3d 2024-03-28 op d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
434 914bfd3d 2024-03-28 op
435 914bfd3d 2024-03-28 op # in the future it should contain something like this too
436 914bfd3d 2024-03-28 op # {
437 914bfd3d 2024-03-28 op # "type":"new-branch",
438 914bfd3d 2024-03-28 op # "user":"${GOTD_DEVUSER}",
439 914bfd3d 2024-03-28 op # "ref":"refs/heads/newbranch"
440 914bfd3d 2024-03-28 op # },
441 914bfd3d 2024-03-28 op
442 914bfd3d 2024-03-28 op touch "$testroot/stdout.expected"
443 87890bc2 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
444 914bfd3d 2024-03-28 op a
445 914bfd3d 2024-03-28 op {"notifications":[
446 914bfd3d 2024-03-28 op {
447 914bfd3d 2024-03-28 op "type":"commit",
448 914bfd3d 2024-03-28 op "short":false,
449 c1003102 2024-04-15 op "repo":"test-repo",
450 914bfd3d 2024-03-28 op "id":"$commit_id",
451 914bfd3d 2024-03-28 op "author":{
452 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
453 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
454 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
455 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
456 914bfd3d 2024-03-28 op },
457 914bfd3d 2024-03-28 op "committer":{
458 914bfd3d 2024-03-28 op "full":"$GOT_AUTHOR",
459 914bfd3d 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
460 914bfd3d 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
461 914bfd3d 2024-03-28 op "user":"$GOT_AUTHOR_11"
462 914bfd3d 2024-03-28 op },
463 914bfd3d 2024-03-28 op "date":"$d",
464 914bfd3d 2024-03-28 op "short_message":"newbranch",
465 914bfd3d 2024-03-28 op "message":"newbranch\n",
466 763b7f49 2024-03-28 op "diffstat":{
467 763b7f49 2024-03-28 op "files":[{
468 763b7f49 2024-03-28 op "action":"modified",
469 763b7f49 2024-03-28 op "file":"alpha",
470 763b7f49 2024-03-28 op "added":1,
471 763b7f49 2024-03-28 op "removed":1
472 763b7f49 2024-03-28 op }],
473 763b7f49 2024-03-28 op "total":{
474 763b7f49 2024-03-28 op "added":1,
475 763b7f49 2024-03-28 op "removed":1
476 763b7f49 2024-03-28 op }
477 763b7f49 2024-03-28 op }
478 914bfd3d 2024-03-28 op }
479 914bfd3d 2024-03-28 op ]}
480 914bfd3d 2024-03-28 op .
481 87890bc2 2024-03-28 op ,j
482 87890bc2 2024-03-28 op w
483 87890bc2 2024-03-28 op EOF
484 5565365c 2024-03-27 op
485 5565365c 2024-03-27 op cmp -s $testroot/stdout.expected $testroot/stdout
486 5565365c 2024-03-27 op ret=$?
487 5565365c 2024-03-27 op if [ $ret -ne 0 ]; then
488 5565365c 2024-03-27 op diff -u $testroot/stdout.expected $testroot/stdout
489 5565365c 2024-03-27 op test_done "$testroot" "$ret"
490 5565365c 2024-03-27 op return 1
491 5565365c 2024-03-27 op fi
492 5565365c 2024-03-27 op
493 5565365c 2024-03-27 op test_done "$testroot" "$ret"
494 5565365c 2024-03-27 op }
495 d6057084 2024-03-28 op
496 d6057084 2024-03-28 op test_branch_removed() {
497 d6057084 2024-03-28 op local testroot=`test_init branch_removed 1`
498 d6057084 2024-03-28 op
499 d6057084 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
500 d6057084 2024-03-28 op ret=$?
501 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
502 d6057084 2024-03-28 op echo "got clone failed unexpectedly" >&2
503 d6057084 2024-03-28 op test_done "$testroot" 1
504 d6057084 2024-03-28 op return 1
505 d6057084 2024-03-28 op fi
506 5565365c 2024-03-27 op
507 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
508 d6057084 2024-03-28 op > $testroot/stdout &
509 d6057084 2024-03-28 op
510 d6057084 2024-03-28 op local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
511 d6057084 2024-03-28 op
512 d6057084 2024-03-28 op got send -d newbranch -q -r $testroot/repo-clone
513 d6057084 2024-03-28 op ret=$?
514 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
515 d6057084 2024-03-28 op echo "got send failed unexpectedly" >&2
516 d6057084 2024-03-28 op test_done "$testroot" "1"
517 d6057084 2024-03-28 op return 1
518 d6057084 2024-03-28 op fi
519 d6057084 2024-03-28 op
520 d6057084 2024-03-28 op wait %1 # wait for the http "server"
521 d6057084 2024-03-28 op
522 d6057084 2024-03-28 op touch "$testroot/stdout.expected"
523 d6057084 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
524 d6057084 2024-03-28 op a
525 d6057084 2024-03-28 op {"notifications":[{
526 d6057084 2024-03-28 op "type":"branch-deleted",
527 c1003102 2024-04-15 op "repo":"test-repo",
528 d6057084 2024-03-28 op "ref":"refs/heads/newbranch",
529 d6057084 2024-03-28 op "id":"$commit_id"
530 553d8347 2024-03-28 op }]}
531 553d8347 2024-03-28 op .
532 553d8347 2024-03-28 op ,j
533 553d8347 2024-03-28 op w
534 553d8347 2024-03-28 op EOF
535 553d8347 2024-03-28 op
536 553d8347 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
537 553d8347 2024-03-28 op ret=$?
538 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
539 553d8347 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
540 553d8347 2024-03-28 op test_done "$testroot" "$ret"
541 553d8347 2024-03-28 op return 1
542 553d8347 2024-03-28 op fi
543 553d8347 2024-03-28 op
544 553d8347 2024-03-28 op test_done "$testroot" "$ret"
545 553d8347 2024-03-28 op }
546 553d8347 2024-03-28 op
547 553d8347 2024-03-28 op test_tag_created() {
548 553d8347 2024-03-28 op local testroot=`test_init tag_created 1`
549 553d8347 2024-03-28 op
550 553d8347 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
551 553d8347 2024-03-28 op ret=$?
552 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
553 553d8347 2024-03-28 op echo "got clone failed unexpectedly" >&2
554 553d8347 2024-03-28 op test_done "$testroot" 1
555 553d8347 2024-03-28 op return 1
556 553d8347 2024-03-28 op fi
557 553d8347 2024-03-28 op
558 553d8347 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
559 553d8347 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
560 553d8347 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
561 553d8347 2024-03-28 op
562 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
563 553d8347 2024-03-28 op >$testroot/stdout &
564 553d8347 2024-03-28 op
565 553d8347 2024-03-28 op got send -t 1.0 -q -r $testroot/repo-clone
566 553d8347 2024-03-28 op ret=$?
567 553d8347 2024-03-28 op if [ $ret -ne 0 ]; then
568 553d8347 2024-03-28 op echo "got send failed unexpectedly" >&2
569 553d8347 2024-03-28 op test_done "$testroot" "1"
570 553d8347 2024-03-28 op return 1
571 553d8347 2024-03-28 op fi
572 553d8347 2024-03-28 op
573 553d8347 2024-03-28 op wait %1 # wait for the http "server"
574 553d8347 2024-03-28 op
575 553d8347 2024-03-28 op d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
576 553d8347 2024-03-28 op
577 553d8347 2024-03-28 op touch "$testroot/stdout.expected"
578 553d8347 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
579 553d8347 2024-03-28 op a
580 553d8347 2024-03-28 op {"notifications":[{
581 553d8347 2024-03-28 op "type":"tag",
582 c1003102 2024-04-15 op "repo":"test-repo",
583 553d8347 2024-03-28 op "tag":"refs/tags/1.0",
584 553d8347 2024-03-28 op "tagger":{
585 553d8347 2024-03-28 op "full":"$GOT_AUTHOR",
586 553d8347 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
587 553d8347 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
588 553d8347 2024-03-28 op "user":"$GOT_AUTHOR_11"
589 553d8347 2024-03-28 op },
590 553d8347 2024-03-28 op "date":"$d",
591 553d8347 2024-03-28 op "object":{
592 553d8347 2024-03-28 op "type":"commit",
593 553d8347 2024-03-28 op "id":"$commit_id"
594 553d8347 2024-03-28 op },
595 553d8347 2024-03-28 op "message":"new tag\n\n"
596 d6057084 2024-03-28 op }]}
597 d6057084 2024-03-28 op .
598 d6057084 2024-03-28 op ,j
599 d6057084 2024-03-28 op w
600 d6057084 2024-03-28 op EOF
601 d6057084 2024-03-28 op
602 d6057084 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
603 d6057084 2024-03-28 op ret=$?
604 d6057084 2024-03-28 op if [ $ret -ne 0 ]; then
605 d6057084 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
606 d6057084 2024-03-28 op test_done "$testroot" "$ret"
607 d6057084 2024-03-28 op return 1
608 d6057084 2024-03-28 op fi
609 d6057084 2024-03-28 op
610 d6057084 2024-03-28 op test_done "$testroot" "$ret"
611 d6057084 2024-03-28 op }
612 cd182532 2024-03-28 op
613 cd182532 2024-03-28 op test_tag_changed() {
614 cd182532 2024-03-28 op local testroot=`test_init tag_changed 1`
615 cd182532 2024-03-28 op
616 cd182532 2024-03-28 op got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
617 cd182532 2024-03-28 op ret=$?
618 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
619 cd182532 2024-03-28 op echo "got clone failed unexpectedly" >&2
620 cd182532 2024-03-28 op test_done "$testroot" 1
621 cd182532 2024-03-28 op return 1
622 cd182532 2024-03-28 op fi
623 cd182532 2024-03-28 op
624 cd182532 2024-03-28 op got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
625 cd182532 2024-03-28 op ret=$?
626 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
627 cd182532 2024-03-28 op echo "got checkout failed unexpectedly" >&2
628 cd182532 2024-03-28 op test_done "$testroot" 1
629 cd182532 2024-03-28 op return 1
630 cd182532 2024-03-28 op fi
631 cd182532 2024-03-28 op
632 cd182532 2024-03-28 op echo "change alpha" > $testroot/wt/alpha
633 cd182532 2024-03-28 op (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
634 cd182532 2024-03-28 op local commit_id=`git_show_head $testroot/repo-clone`
635 d6057084 2024-03-28 op
636 cd182532 2024-03-28 op got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
637 cd182532 2024-03-28 op got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
638 cd182532 2024-03-28 op local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
639 cd182532 2024-03-28 op
640 050c0b8c 2024-04-16 op timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \
641 cd182532 2024-03-28 op > $testroot/stdout &
642 cd182532 2024-03-28 op
643 cd182532 2024-03-28 op got send -f -t 1.0 -q -r $testroot/repo-clone
644 cd182532 2024-03-28 op ret=$?
645 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
646 cd182532 2024-03-28 op echo "got send failed unexpectedly" >&2
647 cd182532 2024-03-28 op test_done "$testroot" "1"
648 cd182532 2024-03-28 op return 1
649 cd182532 2024-03-28 op fi
650 cd182532 2024-03-28 op
651 cd182532 2024-03-28 op wait %1 # wait for the http "server"
652 cd182532 2024-03-28 op
653 cd182532 2024-03-28 op d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
654 cd182532 2024-03-28 op
655 cd182532 2024-03-28 op # XXX: at the moment this is exactly the same as the "new tag"
656 cd182532 2024-03-28 op # notification
657 cd182532 2024-03-28 op
658 cd182532 2024-03-28 op touch "$testroot/stdout.expected"
659 cd182532 2024-03-28 op ed -s "$testroot/stdout.expected" <<-EOF
660 cd182532 2024-03-28 op a
661 cd182532 2024-03-28 op {"notifications":[{
662 cd182532 2024-03-28 op "type":"tag",
663 c1003102 2024-04-15 op "repo":"test-repo",
664 cd182532 2024-03-28 op "tag":"refs/tags/1.0",
665 cd182532 2024-03-28 op "tagger":{
666 cd182532 2024-03-28 op "full":"$GOT_AUTHOR",
667 cd182532 2024-03-28 op "name":"$GIT_AUTHOR_NAME",
668 cd182532 2024-03-28 op "mail":"$GIT_AUTHOR_EMAIL",
669 cd182532 2024-03-28 op "user":"$GOT_AUTHOR_11"
670 cd182532 2024-03-28 op },
671 cd182532 2024-03-28 op "date":"$d",
672 cd182532 2024-03-28 op "object":{
673 cd182532 2024-03-28 op "type":"commit",
674 cd182532 2024-03-28 op "id":"$commit_id"
675 cd182532 2024-03-28 op },
676 cd182532 2024-03-28 op "message":"new tag\n\n"
677 cd182532 2024-03-28 op }]}
678 cd182532 2024-03-28 op .
679 cd182532 2024-03-28 op ,j
680 cd182532 2024-03-28 op w
681 cd182532 2024-03-28 op EOF
682 cd182532 2024-03-28 op
683 cd182532 2024-03-28 op cmp -s $testroot/stdout.expected $testroot/stdout
684 cd182532 2024-03-28 op ret=$?
685 cd182532 2024-03-28 op if [ $ret -ne 0 ]; then
686 cd182532 2024-03-28 op diff -u $testroot/stdout.expected $testroot/stdout
687 cd182532 2024-03-28 op test_done "$testroot" "$ret"
688 cd182532 2024-03-28 op return 1
689 cd182532 2024-03-28 op fi
690 cd182532 2024-03-28 op
691 cd182532 2024-03-28 op test_done "$testroot" "$ret"
692 cd182532 2024-03-28 op }
693 cd182532 2024-03-28 op
694 5565365c 2024-03-27 op test_parseargs "$@"
695 5565365c 2024-03-27 op run_test test_file_changed
696 ea5e974d 2024-03-28 op run_test test_bad_utf8
697 5565365c 2024-03-27 op run_test test_many_commits_not_summarized
698 5565365c 2024-03-27 op run_test test_many_commits_summarized
699 914bfd3d 2024-03-28 op run_test test_branch_created
700 d6057084 2024-03-28 op run_test test_branch_removed
701 553d8347 2024-03-28 op run_test test_tag_created
702 cd182532 2024-03-28 op run_test test_tag_changed