3 ba97b2d7 2024-03-20 stsp # Copyright (c) 2024 Stefan Sperling <stsp@openbsd.org>
5 ba97b2d7 2024-03-20 stsp # Permission to use, copy, modify, and distribute this software for any
6 ba97b2d7 2024-03-20 stsp # purpose with or without fee is hereby granted, provided that the above
7 ba97b2d7 2024-03-20 stsp # copyright notice and this permission notice appear in all copies.
9 ba97b2d7 2024-03-20 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 ba97b2d7 2024-03-20 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 ba97b2d7 2024-03-20 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 ba97b2d7 2024-03-20 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 ba97b2d7 2024-03-20 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 ba97b2d7 2024-03-20 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 ba97b2d7 2024-03-20 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 ba97b2d7 2024-03-20 stsp . ../cmdline/common.sh
18 ba97b2d7 2024-03-20 stsp . ./common.sh
20 ba97b2d7 2024-03-20 stsp test_file_changed() {
21 ba97b2d7 2024-03-20 stsp local testroot=`test_init file_changed 1`
23 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
25 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
26 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
27 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
31 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
33 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
34 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
35 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
39 ba97b2d7 2024-03-20 stsp echo "change alpha" > $testroot/wt/alpha
40 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
41 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
42 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone`
44 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
45 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
47 5a430400 2024-05-12 naddy sleep 1 # server starts up
49 ba97b2d7 2024-03-20 stsp got send -b main -q -r $testroot/repo-clone
51 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
52 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
53 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
57 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
59 1ddd9d55 2024-05-10 stsp short_commit_id=`trim_obj_id 28 $commit_id`
60 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
61 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
62 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
63 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
64 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
65 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
66 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
67 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
68 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
69 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} changed refs/heads/main: $short_commit_id\r\n" \
70 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
71 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
72 ba97b2d7 2024-03-20 stsp printf "commit $commit_id\n" >> $testroot/stdout.expected
73 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
74 ba97b2d7 2024-03-20 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
75 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
76 fb5636be 2024-03-27 op printf "messagelen: 14\n" >> $testroot/stdout.expected
77 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
78 ba97b2d7 2024-03-20 stsp printf " make changes\n \n" >> $testroot/stdout.expected
79 ba97b2d7 2024-03-20 stsp printf " M alpha | 1+ 1-\n\n" >> $testroot/stdout.expected
80 ba97b2d7 2024-03-20 stsp printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
81 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
82 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
83 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
84 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
86 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
87 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
89 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
90 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
91 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
95 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
98 ba97b2d7 2024-03-20 stsp test_many_commits_not_summarized() {
99 ba97b2d7 2024-03-20 stsp local testroot=`test_init many_commits_not_summarized 1`
101 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
103 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
104 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
105 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
109 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
111 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
112 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
113 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
117 ba97b2d7 2024-03-20 stsp for i in `seq 1 24`; do
118 ba97b2d7 2024-03-20 stsp echo "alpha $i" > $testroot/wt/alpha
119 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
120 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
121 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone`
122 ba97b2d7 2024-03-20 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
123 ba97b2d7 2024-03-20 stsp set -- "$@" "$commit_id $d"
126 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
127 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
129 5a430400 2024-05-12 naddy sleep 1 # server starts up
131 ba97b2d7 2024-03-20 stsp got send -b main -q -r $testroot/repo-clone
133 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
134 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
135 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
139 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
141 1ddd9d55 2024-05-10 stsp short_commit_id=`trim_obj_id 28 $commit_id`
142 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
143 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
144 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
145 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
146 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
147 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
148 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" \
149 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
150 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
151 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
152 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} changed refs/heads/main: $short_commit_id\r\n" \
153 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
154 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
155 ba97b2d7 2024-03-20 stsp for i in `seq 1 24`; do
156 ba97b2d7 2024-03-20 stsp s=`pop_idx $i "$@"`
157 ba97b2d7 2024-03-20 stsp commit_id=$(echo $s | cut -d' ' -f1)
158 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
159 ba97b2d7 2024-03-20 stsp printf "commit $commit_id\n" >> $testroot/stdout.expected
160 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
161 ba97b2d7 2024-03-20 stsp printf "date: $commit_time\n" >> $testroot/stdout.expected
162 fb5636be 2024-03-27 op printf "messagelen: 14\n" >> $testroot/stdout.expected
163 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
164 ba97b2d7 2024-03-20 stsp printf " make changes\n \n" >> $testroot/stdout.expected
165 ba97b2d7 2024-03-20 stsp printf " M alpha | 1+ 1-\n\n" \
166 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
167 ba97b2d7 2024-03-20 stsp printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
168 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
170 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
171 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
172 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
174 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
175 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
177 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
178 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
179 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
183 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
186 ba97b2d7 2024-03-20 stsp test_many_commits_summarized() {
187 ba97b2d7 2024-03-20 stsp local testroot=`test_init many_commits_summarized 1`
189 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
191 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
192 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
193 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
197 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
199 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
200 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
201 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
205 ba97b2d7 2024-03-20 stsp for i in `seq 1 51`; do
206 ba97b2d7 2024-03-20 stsp echo "alpha $i" > $testroot/wt/alpha
207 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
208 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
209 ba97b2d7 2024-03-20 stsp local short_commit_id=`trim_obj_id 33 $commit_id`
210 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone`
211 283939fb 2024-04-23 op d=`date -u -r $author_time +"%F"`
212 ba97b2d7 2024-03-20 stsp set -- "$@" "$short_commit_id $d"
215 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
216 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
218 5a430400 2024-05-12 naddy sleep 1 # server starts up
220 ba97b2d7 2024-03-20 stsp got send -b main -q -r $testroot/repo-clone
222 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
223 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
224 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
228 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
230 1ddd9d55 2024-05-10 stsp short_commit_id=`trim_obj_id 28 $commit_id`
231 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
232 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
233 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
234 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
235 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
236 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
237 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" \
238 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
239 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
240 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
241 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} changed refs/heads/main: $short_commit_id\r\n" \
242 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
243 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
244 ba97b2d7 2024-03-20 stsp for i in `seq 1 51`; do
245 ba97b2d7 2024-03-20 stsp s=`pop_idx $i "$@"`
246 ba97b2d7 2024-03-20 stsp commit_id=$(echo $s | cut -d' ' -f1)
247 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
248 ba97b2d7 2024-03-20 stsp printf "$commit_time $commit_id $GOT_AUTHOR_8 make changes\n" \
249 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
251 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
252 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
253 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
255 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
256 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
258 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
259 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
260 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
264 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
267 ba97b2d7 2024-03-20 stsp test_branch_created() {
268 ba97b2d7 2024-03-20 stsp local testroot=`test_init branch_created 1`
270 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
272 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
273 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
274 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
278 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
280 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
281 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
282 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
286 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got branch newbranch > /dev/null)
288 ba97b2d7 2024-03-20 stsp echo "change alpha on branch" > $testroot/wt/alpha
289 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
290 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
291 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
293 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
294 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
296 5a430400 2024-05-12 naddy sleep 1 # server starts up
298 ba97b2d7 2024-03-20 stsp got send -b newbranch -q -r $testroot/repo-clone
300 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
301 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
302 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
306 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
308 1ddd9d55 2024-05-10 stsp short_commit_id=`trim_obj_id 28 $commit_id`
309 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
310 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
311 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
312 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
313 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
314 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
315 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
316 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
317 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
318 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} created refs/heads/newbranch: $short_commit_id\r\n" \
319 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
320 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
321 ba97b2d7 2024-03-20 stsp printf "commit $commit_id\n" >> $testroot/stdout.expected
322 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
323 ba97b2d7 2024-03-20 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
324 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
325 fb5636be 2024-03-27 op printf "messagelen: 11\n" >> $testroot/stdout.expected
326 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
327 ba97b2d7 2024-03-20 stsp printf " newbranch\n \n" >> $testroot/stdout.expected
328 ba97b2d7 2024-03-20 stsp printf " M alpha | 1+ 1-\n\n" >> $testroot/stdout.expected
329 ba97b2d7 2024-03-20 stsp printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
330 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
331 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
332 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
333 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
335 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
336 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
338 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
339 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
340 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
344 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
347 ba97b2d7 2024-03-20 stsp test_branch_removed() {
348 ba97b2d7 2024-03-20 stsp local testroot=`test_init branch_removed 1`
350 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
352 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
353 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
354 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
358 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
359 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
361 5a430400 2024-05-12 naddy sleep 1 # server starts up
363 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
364 1ddd9d55 2024-05-10 stsp local short_commit_id=`trim_obj_id 28 $commit_id`
366 ba97b2d7 2024-03-20 stsp got send -d newbranch -q -r $testroot/repo-clone
368 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
369 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
370 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
374 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
376 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
377 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
378 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
379 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
380 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
381 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
382 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
383 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
384 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
385 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} removed refs/heads/newbranch: $short_commit_id\r\n" \
386 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
387 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
388 ba97b2d7 2024-03-20 stsp printf "Removed refs/heads/newbranch: $commit_id\n" \
389 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
390 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
391 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
392 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
394 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
395 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
397 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
398 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
399 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
403 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
406 ba97b2d7 2024-03-20 stsp test_tag_created() {
407 ba97b2d7 2024-03-20 stsp local testroot=`test_init tag_created 1`
409 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
411 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
412 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
413 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
417 ba97b2d7 2024-03-20 stsp got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
418 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
419 ba97b2d7 2024-03-20 stsp local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
420 1ddd9d55 2024-05-10 stsp local tag_id=`got ref -r $testroot/repo-clone -l \
421 1ddd9d55 2024-05-10 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
422 1ddd9d55 2024-05-10 stsp local short_tag_id=`trim_obj_id 28 $tag_id`
424 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
425 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
427 5a430400 2024-05-12 naddy sleep 1 # server starts up
429 ba97b2d7 2024-03-20 stsp got send -t 1.0 -q -r $testroot/repo-clone
431 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
432 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
433 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
437 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
439 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
440 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
441 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
442 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
443 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
444 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
445 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
446 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
447 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
448 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} created refs/tags/1.0: $short_tag_id\r\n" \
449 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
450 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
451 ba97b2d7 2024-03-20 stsp printf "tag refs/tags/1.0\n" >> $testroot/stdout.expected
452 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
453 ba97b2d7 2024-03-20 stsp d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
454 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
455 ba97b2d7 2024-03-20 stsp printf "object: commit $commit_id\n" >> $testroot/stdout.expected
456 fb5636be 2024-03-27 op printf "messagelen: 9\n" >> $testroot/stdout.expected
457 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
458 ba97b2d7 2024-03-20 stsp printf " new tag\n \n" >> $testroot/stdout.expected
459 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
460 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
461 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
463 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
464 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
466 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
467 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
468 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
472 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
475 ba97b2d7 2024-03-20 stsp test_tag_changed() {
476 ba97b2d7 2024-03-20 stsp local testroot=`test_init tag_changed 1`
478 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
480 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
481 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
482 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
486 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
488 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
489 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
490 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
494 ba97b2d7 2024-03-20 stsp echo "change alpha" > $testroot/wt/alpha
495 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
496 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
498 ba97b2d7 2024-03-20 stsp got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
499 ba97b2d7 2024-03-20 stsp got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
500 ba97b2d7 2024-03-20 stsp local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
501 1ddd9d55 2024-05-10 stsp local tag_id=`got ref -r $testroot/repo-clone -l \
502 1ddd9d55 2024-05-10 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
503 1ddd9d55 2024-05-10 stsp local short_tag_id=`trim_obj_id 28 $tag_id`
505 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
506 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
508 5a430400 2024-05-12 naddy sleep 1 # server starts up
510 ba97b2d7 2024-03-20 stsp got send -f -t 1.0 -q -r $testroot/repo-clone
512 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
513 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
514 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
518 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
520 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
521 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
522 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
523 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
524 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
525 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
526 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
527 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
528 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
529 1ddd9d55 2024-05-10 stsp printf "${GOTD_DEVUSER} changed refs/tags/1.0: $short_tag_id\r\n" \
530 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
531 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
532 ba97b2d7 2024-03-20 stsp printf "tag refs/tags/1.0\n" >> $testroot/stdout.expected
533 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
534 ba97b2d7 2024-03-20 stsp d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
535 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
536 ba97b2d7 2024-03-20 stsp printf "object: commit $commit_id\n" >> $testroot/stdout.expected
537 0f665edb 2024-03-27 op printf "messagelen: 9\n" >> $testroot/stdout.expected
538 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
539 ba97b2d7 2024-03-20 stsp printf " new tag\n \n" >> $testroot/stdout.expected
540 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
541 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
542 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
544 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
545 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
547 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
548 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
549 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
553 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
556 ba97b2d7 2024-03-20 stsp test_parseargs "$@"
557 ba97b2d7 2024-03-20 stsp run_test test_file_changed
558 ba97b2d7 2024-03-20 stsp run_test test_many_commits_not_summarized
559 ba97b2d7 2024-03-20 stsp run_test test_many_commits_summarized
560 ba97b2d7 2024-03-20 stsp run_test test_branch_created
561 ba97b2d7 2024-03-20 stsp run_test test_branch_removed
562 ba97b2d7 2024-03-20 stsp run_test test_tag_created
563 ba97b2d7 2024-03-20 stsp run_test test_tag_changed