3 ce1bfad9 2024-03-30 thomas # Copyright (c) 2024 Stefan Sperling <stsp@openbsd.org>
5 ce1bfad9 2024-03-30 thomas # Permission to use, copy, modify, and distribute this software for any
6 ce1bfad9 2024-03-30 thomas # purpose with or without fee is hereby granted, provided that the above
7 ce1bfad9 2024-03-30 thomas # copyright notice and this permission notice appear in all copies.
9 ce1bfad9 2024-03-30 thomas # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 ce1bfad9 2024-03-30 thomas # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 ce1bfad9 2024-03-30 thomas # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 ce1bfad9 2024-03-30 thomas # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 ce1bfad9 2024-03-30 thomas # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 ce1bfad9 2024-03-30 thomas # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 ce1bfad9 2024-03-30 thomas # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 ce1bfad9 2024-03-30 thomas . ../cmdline/common.sh
18 ce1bfad9 2024-03-30 thomas . ./common.sh
20 ce1bfad9 2024-03-30 thomas test_file_changed() {
21 ce1bfad9 2024-03-30 thomas local testroot=`test_init file_changed 1`
23 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
25 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
26 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
27 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
31 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
33 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
34 ce1bfad9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
35 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
39 ce1bfad9 2024-03-30 thomas echo "change alpha" > $testroot/wt/alpha
40 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
41 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
42 ce1bfad9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
44 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
45 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
47 ce1bfad9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
49 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
50 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
51 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
55 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
57 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
58 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
59 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
60 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
61 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
62 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
63 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
64 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
65 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
66 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} changed refs/heads/main\r\n" \
67 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
68 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
69 ce1bfad9 2024-03-30 thomas printf "commit $commit_id\n" >> $testroot/stdout.expected
70 ce1bfad9 2024-03-30 thomas printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
71 ce1bfad9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
72 ce1bfad9 2024-03-30 thomas printf "date: $d\n" >> $testroot/stdout.expected
73 24a2826a 2024-03-30 thomas printf "messagelen: 14\n" >> $testroot/stdout.expected
74 ce1bfad9 2024-03-30 thomas printf " \n" >> $testroot/stdout.expected
75 ce1bfad9 2024-03-30 thomas printf " make changes\n \n" >> $testroot/stdout.expected
76 ce1bfad9 2024-03-30 thomas printf " M alpha | 1+ 1-\n\n" >> $testroot/stdout.expected
77 ce1bfad9 2024-03-30 thomas printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
78 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
79 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
80 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
81 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
83 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
84 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
86 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
87 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
88 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
92 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
95 ce1bfad9 2024-03-30 thomas test_many_commits_not_summarized() {
96 ce1bfad9 2024-03-30 thomas local testroot=`test_init many_commits_not_summarized 1`
98 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
100 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
101 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
102 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
106 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
108 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
109 ce1bfad9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
110 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
114 ce1bfad9 2024-03-30 thomas for i in `seq 1 24`; do
115 ce1bfad9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
116 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
117 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
118 ce1bfad9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
119 ce1bfad9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
120 ce1bfad9 2024-03-30 thomas set -- "$@" "$commit_id $d"
123 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
124 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
126 ce1bfad9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
128 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
129 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
130 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
134 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
136 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
137 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
138 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
139 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
140 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
141 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
142 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" \
143 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
144 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
145 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
146 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} changed refs/heads/main\r\n" \
147 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
148 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
149 ce1bfad9 2024-03-30 thomas for i in `seq 1 24`; do
150 ce1bfad9 2024-03-30 thomas s=`pop_idx $i "$@"`
151 ce1bfad9 2024-03-30 thomas commit_id=$(echo $s | cut -d' ' -f1)
152 54b4b049 2024-04-09 thomas commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
153 ce1bfad9 2024-03-30 thomas printf "commit $commit_id\n" >> $testroot/stdout.expected
154 ce1bfad9 2024-03-30 thomas printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
155 ce1bfad9 2024-03-30 thomas printf "date: $commit_time\n" >> $testroot/stdout.expected
156 24a2826a 2024-03-30 thomas printf "messagelen: 14\n" >> $testroot/stdout.expected
157 ce1bfad9 2024-03-30 thomas printf " \n" >> $testroot/stdout.expected
158 ce1bfad9 2024-03-30 thomas printf " make changes\n \n" >> $testroot/stdout.expected
159 ce1bfad9 2024-03-30 thomas printf " M alpha | 1+ 1-\n\n" \
160 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
161 ce1bfad9 2024-03-30 thomas printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
162 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
164 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
165 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
166 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
168 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
169 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
171 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
172 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
173 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
177 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
180 ce1bfad9 2024-03-30 thomas test_many_commits_summarized() {
181 ce1bfad9 2024-03-30 thomas local testroot=`test_init many_commits_summarized 1`
183 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
185 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
186 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
187 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
191 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
193 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
194 ce1bfad9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
195 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
199 ce1bfad9 2024-03-30 thomas for i in `seq 1 51`; do
200 ce1bfad9 2024-03-30 thomas echo "alpha $i" > $testroot/wt/alpha
201 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
202 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
203 ce1bfad9 2024-03-30 thomas local short_commit_id=`trim_obj_id 33 $commit_id`
204 ce1bfad9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone`
205 c24e2d2e 2024-04-25 thomas.ad d=`date -u -r $author_time +"%F"`
206 ce1bfad9 2024-03-30 thomas set -- "$@" "$short_commit_id $d"
209 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
210 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
212 ce1bfad9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
214 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
215 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
216 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
220 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
222 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
223 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
224 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
225 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
226 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
227 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
228 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" \
229 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
230 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
231 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
232 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} changed refs/heads/main\r\n" \
233 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
234 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
235 ce1bfad9 2024-03-30 thomas for i in `seq 1 51`; do
236 ce1bfad9 2024-03-30 thomas s=`pop_idx $i "$@"`
237 ce1bfad9 2024-03-30 thomas commit_id=$(echo $s | cut -d' ' -f1)
238 54b4b049 2024-04-09 thomas commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
239 ce1bfad9 2024-03-30 thomas printf "$commit_time $commit_id $GOT_AUTHOR_8 make changes\n" \
240 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
242 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
243 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
244 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
246 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
247 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
249 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
250 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
251 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
255 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
258 ce1bfad9 2024-03-30 thomas test_branch_created() {
259 ce1bfad9 2024-03-30 thomas local testroot=`test_init branch_created 1`
261 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
263 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
264 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
265 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
269 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
271 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
272 ce1bfad9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
273 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
277 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got branch newbranch > /dev/null)
279 ce1bfad9 2024-03-30 thomas echo "change alpha on branch" > $testroot/wt/alpha
280 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
281 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
282 ce1bfad9 2024-03-30 thomas local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
284 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
285 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
287 ce1bfad9 2024-03-30 thomas got send -b newbranch -q -r $testroot/repo-clone
289 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
290 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
291 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
295 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
297 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
298 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
299 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
300 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
301 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
302 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
303 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
304 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
305 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
306 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} created refs/heads/newbranch\r\n" \
307 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
308 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
309 ce1bfad9 2024-03-30 thomas printf "commit $commit_id\n" >> $testroot/stdout.expected
310 ce1bfad9 2024-03-30 thomas printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
311 ce1bfad9 2024-03-30 thomas d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
312 ce1bfad9 2024-03-30 thomas printf "date: $d\n" >> $testroot/stdout.expected
313 24a2826a 2024-03-30 thomas printf "messagelen: 11\n" >> $testroot/stdout.expected
314 ce1bfad9 2024-03-30 thomas printf " \n" >> $testroot/stdout.expected
315 ce1bfad9 2024-03-30 thomas printf " newbranch\n \n" >> $testroot/stdout.expected
316 ce1bfad9 2024-03-30 thomas printf " M alpha | 1+ 1-\n\n" >> $testroot/stdout.expected
317 ce1bfad9 2024-03-30 thomas printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
318 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
319 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
320 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
321 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
323 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
324 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
326 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
327 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
328 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
332 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
335 ce1bfad9 2024-03-30 thomas test_branch_removed() {
336 ce1bfad9 2024-03-30 thomas local testroot=`test_init branch_removed 1`
338 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
340 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
341 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
342 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
346 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
347 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
349 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
351 ce1bfad9 2024-03-30 thomas got send -d newbranch -q -r $testroot/repo-clone
353 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
354 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
355 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
359 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
361 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
362 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
363 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
364 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
365 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
366 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
367 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
368 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
369 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
370 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} removed refs/heads/newbranch\r\n" \
371 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
372 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
373 ce1bfad9 2024-03-30 thomas printf "Removed refs/heads/newbranch: $commit_id\n" \
374 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
375 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
376 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
377 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
379 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
380 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
382 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
383 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
384 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
388 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
391 ce1bfad9 2024-03-30 thomas test_tag_created() {
392 ce1bfad9 2024-03-30 thomas local testroot=`test_init tag_created 1`
394 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
396 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
397 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
398 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
402 ce1bfad9 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
403 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
404 ce1bfad9 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
406 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
407 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
409 ce1bfad9 2024-03-30 thomas got send -t 1.0 -q -r $testroot/repo-clone
411 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
412 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
413 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
417 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
419 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
420 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
421 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
422 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
423 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
424 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
425 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
426 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
427 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
428 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} created refs/tags/1.0\r\n" \
429 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
430 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
431 ce1bfad9 2024-03-30 thomas printf "tag refs/tags/1.0\n" >> $testroot/stdout.expected
432 ce1bfad9 2024-03-30 thomas printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
433 ce1bfad9 2024-03-30 thomas d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
434 ce1bfad9 2024-03-30 thomas printf "date: $d\n" >> $testroot/stdout.expected
435 ce1bfad9 2024-03-30 thomas printf "object: commit $commit_id\n" >> $testroot/stdout.expected
436 24a2826a 2024-03-30 thomas printf "messagelen: 9\n" >> $testroot/stdout.expected
437 ce1bfad9 2024-03-30 thomas printf " \n" >> $testroot/stdout.expected
438 ce1bfad9 2024-03-30 thomas printf " new tag\n \n" >> $testroot/stdout.expected
439 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
440 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
441 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
443 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
444 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
446 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
447 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
448 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
452 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
455 ce1bfad9 2024-03-30 thomas test_tag_changed() {
456 ce1bfad9 2024-03-30 thomas local testroot=`test_init tag_changed 1`
458 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
460 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
461 ce1bfad9 2024-03-30 thomas echo "got clone failed unexpectedly" >&2
462 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
466 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
468 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
469 ce1bfad9 2024-03-30 thomas echo "got checkout failed unexpectedly" >&2
470 ce1bfad9 2024-03-30 thomas test_done "$testroot" 1
474 ce1bfad9 2024-03-30 thomas echo "change alpha" > $testroot/wt/alpha
475 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
476 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_head $testroot/repo-clone`
478 ce1bfad9 2024-03-30 thomas got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
479 ce1bfad9 2024-03-30 thomas got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
480 ce1bfad9 2024-03-30 thomas local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
482 ce1bfad9 2024-03-30 thomas (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
483 ce1bfad9 2024-03-30 thomas | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
485 ce1bfad9 2024-03-30 thomas got send -f -t 1.0 -q -r $testroot/repo-clone
487 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
488 ce1bfad9 2024-03-30 thomas echo "got send failed unexpectedly" >&2
489 ce1bfad9 2024-03-30 thomas test_done "$testroot" "1"
493 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
495 ce1bfad9 2024-03-30 thomas HOSTNAME=`hostname`
496 ce1bfad9 2024-03-30 thomas printf "HELO localhost\r\n" > $testroot/stdout.expected
497 ce1bfad9 2024-03-30 thomas printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
498 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
499 ce1bfad9 2024-03-30 thomas printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
500 ce1bfad9 2024-03-30 thomas printf "DATA\r\n" >> $testroot/stdout.expected
501 ce1bfad9 2024-03-30 thomas printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
502 ce1bfad9 2024-03-30 thomas printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
503 ce1bfad9 2024-03-30 thomas printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
504 ce1bfad9 2024-03-30 thomas printf "${GOTD_DEVUSER} changed refs/tags/1.0\r\n" \
505 ce1bfad9 2024-03-30 thomas >> $testroot/stdout.expected
506 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
507 ce1bfad9 2024-03-30 thomas printf "tag refs/tags/1.0\n" >> $testroot/stdout.expected
508 ce1bfad9 2024-03-30 thomas printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
509 ce1bfad9 2024-03-30 thomas d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
510 ce1bfad9 2024-03-30 thomas printf "date: $d\n" >> $testroot/stdout.expected
511 ce1bfad9 2024-03-30 thomas printf "object: commit $commit_id\n" >> $testroot/stdout.expected
512 c97a1399 2024-03-30 thomas printf "messagelen: 9\n" >> $testroot/stdout.expected
513 ce1bfad9 2024-03-30 thomas printf " \n" >> $testroot/stdout.expected
514 ce1bfad9 2024-03-30 thomas printf " new tag\n \n" >> $testroot/stdout.expected
515 ce1bfad9 2024-03-30 thomas printf "\r\n" >> $testroot/stdout.expected
516 ce1bfad9 2024-03-30 thomas printf ".\r\n" >> $testroot/stdout.expected
517 ce1bfad9 2024-03-30 thomas printf "QUIT\r\n" >> $testroot/stdout.expected
519 ce1bfad9 2024-03-30 thomas grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
520 ce1bfad9 2024-03-30 thomas cmp -s $testroot/stdout.expected $testroot/stdout.filtered
522 ce1bfad9 2024-03-30 thomas if [ $ret -ne 0 ]; then
523 ce1bfad9 2024-03-30 thomas diff -u $testroot/stdout.expected $testroot/stdout.filtered
524 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
528 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
531 ce1bfad9 2024-03-30 thomas test_parseargs "$@"
532 ce1bfad9 2024-03-30 thomas run_test test_file_changed
533 ce1bfad9 2024-03-30 thomas run_test test_many_commits_not_summarized
534 ce1bfad9 2024-03-30 thomas run_test test_many_commits_summarized
535 ce1bfad9 2024-03-30 thomas run_test test_branch_created
536 ce1bfad9 2024-03-30 thomas run_test test_branch_removed
537 ce1bfad9 2024-03-30 thomas run_test test_tag_created
538 ce1bfad9 2024-03-30 thomas run_test test_tag_changed