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