Blame


1 ba97b2d7 2024-03-20 stsp #!/bin/sh
2 ba97b2d7 2024-03-20 stsp #
3 ba97b2d7 2024-03-20 stsp # Copyright (c) 2024 Stefan Sperling <stsp@openbsd.org>
4 ba97b2d7 2024-03-20 stsp #
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.
8 ba97b2d7 2024-03-20 stsp #
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.
16 ba97b2d7 2024-03-20 stsp
17 ba97b2d7 2024-03-20 stsp . ../cmdline/common.sh
18 ba97b2d7 2024-03-20 stsp . ./common.sh
19 ba97b2d7 2024-03-20 stsp
20 ba97b2d7 2024-03-20 stsp test_file_changed() {
21 ba97b2d7 2024-03-20 stsp local testroot=`test_init file_changed 1`
22 ba97b2d7 2024-03-20 stsp
23 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
24 ba97b2d7 2024-03-20 stsp ret=$?
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
28 ba97b2d7 2024-03-20 stsp return 1
29 ba97b2d7 2024-03-20 stsp fi
30 ba97b2d7 2024-03-20 stsp
31 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
32 ba97b2d7 2024-03-20 stsp ret=$?
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
36 ba97b2d7 2024-03-20 stsp return 1
37 ba97b2d7 2024-03-20 stsp fi
38 ba97b2d7 2024-03-20 stsp
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`
43 ba97b2d7 2024-03-20 stsp
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) &
46 ba97b2d7 2024-03-20 stsp
47 ba97b2d7 2024-03-20 stsp got send -b main -q -r $testroot/repo-clone
48 ba97b2d7 2024-03-20 stsp ret=$?
49 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
50 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
51 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
52 ba97b2d7 2024-03-20 stsp return 1
53 ba97b2d7 2024-03-20 stsp fi
54 ba97b2d7 2024-03-20 stsp
55 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
56 ba97b2d7 2024-03-20 stsp
57 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
58 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
59 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
60 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
61 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
62 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
63 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
64 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
65 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
66 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} changed refs/heads/main\r\n" \
67 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
68 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
69 ba97b2d7 2024-03-20 stsp printf "commit $commit_id\n" >> $testroot/stdout.expected
70 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
71 ba97b2d7 2024-03-20 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
72 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
73 fb5636be 2024-03-27 op printf "messagelen: 14\n" >> $testroot/stdout.expected
74 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
75 ba97b2d7 2024-03-20 stsp printf " make changes\n \n" >> $testroot/stdout.expected
76 ba97b2d7 2024-03-20 stsp printf " M alpha | 1+ 1-\n\n" >> $testroot/stdout.expected
77 ba97b2d7 2024-03-20 stsp printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
78 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
79 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
80 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
81 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
82 ba97b2d7 2024-03-20 stsp
83 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
84 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
85 ba97b2d7 2024-03-20 stsp ret=$?
86 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
87 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
88 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
89 ba97b2d7 2024-03-20 stsp return 1
90 ba97b2d7 2024-03-20 stsp fi
91 ba97b2d7 2024-03-20 stsp
92 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
93 ba97b2d7 2024-03-20 stsp }
94 ba97b2d7 2024-03-20 stsp
95 ba97b2d7 2024-03-20 stsp test_many_commits_not_summarized() {
96 ba97b2d7 2024-03-20 stsp local testroot=`test_init many_commits_not_summarized 1`
97 ba97b2d7 2024-03-20 stsp
98 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
99 ba97b2d7 2024-03-20 stsp ret=$?
100 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
101 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
102 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
103 ba97b2d7 2024-03-20 stsp return 1
104 ba97b2d7 2024-03-20 stsp fi
105 ba97b2d7 2024-03-20 stsp
106 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
107 ba97b2d7 2024-03-20 stsp ret=$?
108 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
109 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
110 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
111 ba97b2d7 2024-03-20 stsp return 1
112 ba97b2d7 2024-03-20 stsp fi
113 ba97b2d7 2024-03-20 stsp
114 ba97b2d7 2024-03-20 stsp for i in `seq 1 24`; do
115 ba97b2d7 2024-03-20 stsp echo "alpha $i" > $testroot/wt/alpha
116 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
117 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
118 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone`
119 ba97b2d7 2024-03-20 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
120 ba97b2d7 2024-03-20 stsp set -- "$@" "$commit_id $d"
121 ba97b2d7 2024-03-20 stsp done
122 ba97b2d7 2024-03-20 stsp
123 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
124 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
125 ba97b2d7 2024-03-20 stsp
126 ba97b2d7 2024-03-20 stsp got send -b main -q -r $testroot/repo-clone
127 ba97b2d7 2024-03-20 stsp ret=$?
128 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
129 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
130 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
131 ba97b2d7 2024-03-20 stsp return 1
132 ba97b2d7 2024-03-20 stsp fi
133 ba97b2d7 2024-03-20 stsp
134 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
135 ba97b2d7 2024-03-20 stsp
136 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
137 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
138 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
139 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
140 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
141 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
142 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" \
143 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
144 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
145 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
146 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} changed refs/heads/main\r\n" \
147 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
148 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
149 ba97b2d7 2024-03-20 stsp for i in `seq 1 24`; do
150 ba97b2d7 2024-03-20 stsp s=`pop_idx $i "$@"`
151 ba97b2d7 2024-03-20 stsp commit_id=$(echo $s | cut -d' ' -f1)
152 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
153 ba97b2d7 2024-03-20 stsp printf "commit $commit_id\n" >> $testroot/stdout.expected
154 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
155 ba97b2d7 2024-03-20 stsp printf "date: $commit_time\n" >> $testroot/stdout.expected
156 fb5636be 2024-03-27 op printf "messagelen: 14\n" >> $testroot/stdout.expected
157 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
158 ba97b2d7 2024-03-20 stsp printf " make changes\n \n" >> $testroot/stdout.expected
159 ba97b2d7 2024-03-20 stsp printf " M alpha | 1+ 1-\n\n" \
160 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
161 ba97b2d7 2024-03-20 stsp printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
162 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
163 ba97b2d7 2024-03-20 stsp done
164 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
165 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
166 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
167 ba97b2d7 2024-03-20 stsp
168 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
169 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
170 ba97b2d7 2024-03-20 stsp ret=$?
171 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
172 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
173 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
174 ba97b2d7 2024-03-20 stsp return 1
175 ba97b2d7 2024-03-20 stsp fi
176 ba97b2d7 2024-03-20 stsp
177 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
178 ba97b2d7 2024-03-20 stsp }
179 ba97b2d7 2024-03-20 stsp
180 ba97b2d7 2024-03-20 stsp test_many_commits_summarized() {
181 ba97b2d7 2024-03-20 stsp local testroot=`test_init many_commits_summarized 1`
182 ba97b2d7 2024-03-20 stsp
183 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
184 ba97b2d7 2024-03-20 stsp ret=$?
185 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
186 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
187 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
188 ba97b2d7 2024-03-20 stsp return 1
189 ba97b2d7 2024-03-20 stsp fi
190 ba97b2d7 2024-03-20 stsp
191 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
192 ba97b2d7 2024-03-20 stsp ret=$?
193 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
194 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
195 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
196 ba97b2d7 2024-03-20 stsp return 1
197 ba97b2d7 2024-03-20 stsp fi
198 ba97b2d7 2024-03-20 stsp
199 ba97b2d7 2024-03-20 stsp for i in `seq 1 51`; do
200 ba97b2d7 2024-03-20 stsp echo "alpha $i" > $testroot/wt/alpha
201 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
202 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
203 ba97b2d7 2024-03-20 stsp local short_commit_id=`trim_obj_id 33 $commit_id`
204 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone`
205 283939fb 2024-04-23 op d=`date -u -r $author_time +"%F"`
206 ba97b2d7 2024-03-20 stsp set -- "$@" "$short_commit_id $d"
207 ba97b2d7 2024-03-20 stsp done
208 ba97b2d7 2024-03-20 stsp
209 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
210 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
211 ba97b2d7 2024-03-20 stsp
212 ba97b2d7 2024-03-20 stsp got send -b main -q -r $testroot/repo-clone
213 ba97b2d7 2024-03-20 stsp ret=$?
214 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
215 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
216 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
217 ba97b2d7 2024-03-20 stsp return 1
218 ba97b2d7 2024-03-20 stsp fi
219 ba97b2d7 2024-03-20 stsp
220 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
221 ba97b2d7 2024-03-20 stsp
222 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
223 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
224 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
225 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
226 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
227 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
228 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" \
229 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
230 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
231 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
232 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} changed refs/heads/main\r\n" \
233 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
234 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
235 ba97b2d7 2024-03-20 stsp for i in `seq 1 51`; do
236 ba97b2d7 2024-03-20 stsp s=`pop_idx $i "$@"`
237 ba97b2d7 2024-03-20 stsp commit_id=$(echo $s | cut -d' ' -f1)
238 166674b8 2024-04-09 stsp commit_time=$(echo "$s" | sed -e "s/^$commit_id //g")
239 ba97b2d7 2024-03-20 stsp printf "$commit_time $commit_id $GOT_AUTHOR_8 make changes\n" \
240 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
241 ba97b2d7 2024-03-20 stsp done
242 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
243 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
244 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
245 ba97b2d7 2024-03-20 stsp
246 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
247 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
248 ba97b2d7 2024-03-20 stsp ret=$?
249 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
250 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
251 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
252 ba97b2d7 2024-03-20 stsp return 1
253 ba97b2d7 2024-03-20 stsp fi
254 ba97b2d7 2024-03-20 stsp
255 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
256 ba97b2d7 2024-03-20 stsp }
257 ba97b2d7 2024-03-20 stsp
258 ba97b2d7 2024-03-20 stsp test_branch_created() {
259 ba97b2d7 2024-03-20 stsp local testroot=`test_init branch_created 1`
260 ba97b2d7 2024-03-20 stsp
261 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
262 ba97b2d7 2024-03-20 stsp ret=$?
263 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
264 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
265 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
266 ba97b2d7 2024-03-20 stsp return 1
267 ba97b2d7 2024-03-20 stsp fi
268 ba97b2d7 2024-03-20 stsp
269 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
270 ba97b2d7 2024-03-20 stsp ret=$?
271 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
272 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
273 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
274 ba97b2d7 2024-03-20 stsp return 1
275 ba97b2d7 2024-03-20 stsp fi
276 ba97b2d7 2024-03-20 stsp
277 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got branch newbranch > /dev/null)
278 ba97b2d7 2024-03-20 stsp
279 ba97b2d7 2024-03-20 stsp echo "change alpha on branch" > $testroot/wt/alpha
280 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'newbranch' > /dev/null)
281 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
282 ba97b2d7 2024-03-20 stsp local author_time=`git_show_author_time $testroot/repo-clone $commit_id`
283 ba97b2d7 2024-03-20 stsp
284 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
285 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
286 ba97b2d7 2024-03-20 stsp
287 ba97b2d7 2024-03-20 stsp got send -b newbranch -q -r $testroot/repo-clone
288 ba97b2d7 2024-03-20 stsp ret=$?
289 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
290 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
291 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
292 ba97b2d7 2024-03-20 stsp return 1
293 ba97b2d7 2024-03-20 stsp fi
294 ba97b2d7 2024-03-20 stsp
295 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
296 ba97b2d7 2024-03-20 stsp
297 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
298 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
299 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
300 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
301 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
302 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
303 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
304 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
305 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
306 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} created refs/heads/newbranch\r\n" \
307 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
308 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
309 ba97b2d7 2024-03-20 stsp printf "commit $commit_id\n" >> $testroot/stdout.expected
310 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
311 ba97b2d7 2024-03-20 stsp d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
312 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
313 fb5636be 2024-03-27 op printf "messagelen: 11\n" >> $testroot/stdout.expected
314 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
315 ba97b2d7 2024-03-20 stsp printf " newbranch\n \n" >> $testroot/stdout.expected
316 ba97b2d7 2024-03-20 stsp printf " M alpha | 1+ 1-\n\n" >> $testroot/stdout.expected
317 ba97b2d7 2024-03-20 stsp printf "1 file changed, 1 insertion(+), 1 deletion(-)\n\n" \
318 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
319 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
320 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
321 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
322 ba97b2d7 2024-03-20 stsp
323 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
324 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
325 ba97b2d7 2024-03-20 stsp ret=$?
326 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
327 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
328 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
329 ba97b2d7 2024-03-20 stsp return 1
330 ba97b2d7 2024-03-20 stsp fi
331 ba97b2d7 2024-03-20 stsp
332 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
333 ba97b2d7 2024-03-20 stsp }
334 ba97b2d7 2024-03-20 stsp
335 ba97b2d7 2024-03-20 stsp test_branch_removed() {
336 ba97b2d7 2024-03-20 stsp local testroot=`test_init branch_removed 1`
337 ba97b2d7 2024-03-20 stsp
338 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
339 ba97b2d7 2024-03-20 stsp ret=$?
340 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
341 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
342 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
343 ba97b2d7 2024-03-20 stsp return 1
344 ba97b2d7 2024-03-20 stsp fi
345 ba97b2d7 2024-03-20 stsp
346 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
347 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
348 ba97b2d7 2024-03-20 stsp
349 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
350 ba97b2d7 2024-03-20 stsp
351 ba97b2d7 2024-03-20 stsp got send -d newbranch -q -r $testroot/repo-clone
352 ba97b2d7 2024-03-20 stsp ret=$?
353 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
354 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
355 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
356 ba97b2d7 2024-03-20 stsp return 1
357 ba97b2d7 2024-03-20 stsp fi
358 ba97b2d7 2024-03-20 stsp
359 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
360 ba97b2d7 2024-03-20 stsp
361 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
362 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
363 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
364 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
365 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
366 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
367 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
368 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
369 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
370 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} removed refs/heads/newbranch\r\n" \
371 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
372 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
373 ba97b2d7 2024-03-20 stsp printf "Removed refs/heads/newbranch: $commit_id\n" \
374 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
375 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
376 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
377 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
378 ba97b2d7 2024-03-20 stsp
379 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
380 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
381 ba97b2d7 2024-03-20 stsp ret=$?
382 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
383 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
384 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
385 ba97b2d7 2024-03-20 stsp return 1
386 ba97b2d7 2024-03-20 stsp fi
387 ba97b2d7 2024-03-20 stsp
388 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
389 ba97b2d7 2024-03-20 stsp }
390 ba97b2d7 2024-03-20 stsp
391 ba97b2d7 2024-03-20 stsp test_tag_created() {
392 ba97b2d7 2024-03-20 stsp local testroot=`test_init tag_created 1`
393 ba97b2d7 2024-03-20 stsp
394 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
395 ba97b2d7 2024-03-20 stsp ret=$?
396 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
397 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
398 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
399 ba97b2d7 2024-03-20 stsp return 1
400 ba97b2d7 2024-03-20 stsp fi
401 ba97b2d7 2024-03-20 stsp
402 ba97b2d7 2024-03-20 stsp got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
403 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
404 ba97b2d7 2024-03-20 stsp local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
405 ba97b2d7 2024-03-20 stsp
406 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
407 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
408 ba97b2d7 2024-03-20 stsp
409 ba97b2d7 2024-03-20 stsp got send -t 1.0 -q -r $testroot/repo-clone
410 ba97b2d7 2024-03-20 stsp ret=$?
411 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
412 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
413 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
414 ba97b2d7 2024-03-20 stsp return 1
415 ba97b2d7 2024-03-20 stsp fi
416 ba97b2d7 2024-03-20 stsp
417 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
418 ba97b2d7 2024-03-20 stsp
419 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
420 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
421 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
422 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
423 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
424 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
425 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
426 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
427 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
428 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} created refs/tags/1.0\r\n" \
429 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
430 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
431 ba97b2d7 2024-03-20 stsp printf "tag refs/tags/1.0\n" >> $testroot/stdout.expected
432 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
433 ba97b2d7 2024-03-20 stsp d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
434 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
435 ba97b2d7 2024-03-20 stsp printf "object: commit $commit_id\n" >> $testroot/stdout.expected
436 fb5636be 2024-03-27 op printf "messagelen: 9\n" >> $testroot/stdout.expected
437 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
438 ba97b2d7 2024-03-20 stsp printf " new tag\n \n" >> $testroot/stdout.expected
439 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
440 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
441 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
442 ba97b2d7 2024-03-20 stsp
443 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
444 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
445 ba97b2d7 2024-03-20 stsp ret=$?
446 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
447 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
448 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
449 ba97b2d7 2024-03-20 stsp return 1
450 ba97b2d7 2024-03-20 stsp fi
451 ba97b2d7 2024-03-20 stsp
452 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
453 ba97b2d7 2024-03-20 stsp }
454 ba97b2d7 2024-03-20 stsp
455 ba97b2d7 2024-03-20 stsp test_tag_changed() {
456 ba97b2d7 2024-03-20 stsp local testroot=`test_init tag_changed 1`
457 ba97b2d7 2024-03-20 stsp
458 ba97b2d7 2024-03-20 stsp got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
459 ba97b2d7 2024-03-20 stsp ret=$?
460 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
461 ba97b2d7 2024-03-20 stsp echo "got clone failed unexpectedly" >&2
462 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
463 ba97b2d7 2024-03-20 stsp return 1
464 ba97b2d7 2024-03-20 stsp fi
465 ba97b2d7 2024-03-20 stsp
466 ba97b2d7 2024-03-20 stsp got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
467 ba97b2d7 2024-03-20 stsp ret=$?
468 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
469 ba97b2d7 2024-03-20 stsp echo "got checkout failed unexpectedly" >&2
470 ba97b2d7 2024-03-20 stsp test_done "$testroot" 1
471 ba97b2d7 2024-03-20 stsp return 1
472 ba97b2d7 2024-03-20 stsp fi
473 ba97b2d7 2024-03-20 stsp
474 ba97b2d7 2024-03-20 stsp echo "change alpha" > $testroot/wt/alpha
475 ba97b2d7 2024-03-20 stsp (cd $testroot/wt && got commit -m 'make changes' > /dev/null)
476 ba97b2d7 2024-03-20 stsp local commit_id=`git_show_head $testroot/repo-clone`
477 ba97b2d7 2024-03-20 stsp
478 ba97b2d7 2024-03-20 stsp got ref -r $testroot/repo-clone -d refs/tags/1.0 >/dev/null
479 ba97b2d7 2024-03-20 stsp got tag -r $testroot/repo-clone -m "new tag" 1.0 > /dev/null
480 ba97b2d7 2024-03-20 stsp local tagger_time=`git_show_tagger_time $testroot/repo-clone 1.0`
481 ba97b2d7 2024-03-20 stsp
482 ba97b2d7 2024-03-20 stsp (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \
483 ba97b2d7 2024-03-20 stsp | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) &
484 ba97b2d7 2024-03-20 stsp
485 ba97b2d7 2024-03-20 stsp got send -f -t 1.0 -q -r $testroot/repo-clone
486 ba97b2d7 2024-03-20 stsp ret=$?
487 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
488 ba97b2d7 2024-03-20 stsp echo "got send failed unexpectedly" >&2
489 ba97b2d7 2024-03-20 stsp test_done "$testroot" "1"
490 ba97b2d7 2024-03-20 stsp return 1
491 ba97b2d7 2024-03-20 stsp fi
492 ba97b2d7 2024-03-20 stsp
493 ba97b2d7 2024-03-20 stsp wait %1 # wait for nc -l
494 ba97b2d7 2024-03-20 stsp
495 ba97b2d7 2024-03-20 stsp HOSTNAME=`hostname`
496 ba97b2d7 2024-03-20 stsp printf "HELO localhost\r\n" > $testroot/stdout.expected
497 ba97b2d7 2024-03-20 stsp printf "MAIL FROM:<${GOTD_USER}@${HOSTNAME}>\r\n" \
498 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
499 ba97b2d7 2024-03-20 stsp printf "RCPT TO:<${GOTD_DEVUSER}>\r\n" >> $testroot/stdout.expected
500 ba97b2d7 2024-03-20 stsp printf "DATA\r\n" >> $testroot/stdout.expected
501 ba97b2d7 2024-03-20 stsp printf "From: ${GOTD_USER}@${HOSTNAME}\r\n" >> $testroot/stdout.expected
502 ba97b2d7 2024-03-20 stsp printf "To: ${GOTD_DEVUSER}\r\n" >> $testroot/stdout.expected
503 ba97b2d7 2024-03-20 stsp printf "Subject: $GOTD_TEST_REPO_NAME: " >> $testroot/stdout.expected
504 ba97b2d7 2024-03-20 stsp printf "${GOTD_DEVUSER} changed refs/tags/1.0\r\n" \
505 ba97b2d7 2024-03-20 stsp >> $testroot/stdout.expected
506 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
507 ba97b2d7 2024-03-20 stsp printf "tag refs/tags/1.0\n" >> $testroot/stdout.expected
508 ba97b2d7 2024-03-20 stsp printf "from: $GOT_AUTHOR\n" >> $testroot/stdout.expected
509 ba97b2d7 2024-03-20 stsp d=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
510 ba97b2d7 2024-03-20 stsp printf "date: $d\n" >> $testroot/stdout.expected
511 ba97b2d7 2024-03-20 stsp printf "object: commit $commit_id\n" >> $testroot/stdout.expected
512 0f665edb 2024-03-27 op printf "messagelen: 9\n" >> $testroot/stdout.expected
513 ba97b2d7 2024-03-20 stsp printf " \n" >> $testroot/stdout.expected
514 ba97b2d7 2024-03-20 stsp printf " new tag\n \n" >> $testroot/stdout.expected
515 ba97b2d7 2024-03-20 stsp printf "\r\n" >> $testroot/stdout.expected
516 ba97b2d7 2024-03-20 stsp printf ".\r\n" >> $testroot/stdout.expected
517 ba97b2d7 2024-03-20 stsp printf "QUIT\r\n" >> $testroot/stdout.expected
518 ba97b2d7 2024-03-20 stsp
519 ba97b2d7 2024-03-20 stsp grep -v ^Date $testroot/stdout > $testroot/stdout.filtered
520 ba97b2d7 2024-03-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout.filtered
521 ba97b2d7 2024-03-20 stsp ret=$?
522 ba97b2d7 2024-03-20 stsp if [ $ret -ne 0 ]; then
523 ba97b2d7 2024-03-20 stsp diff -u $testroot/stdout.expected $testroot/stdout.filtered
524 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
525 ba97b2d7 2024-03-20 stsp return 1
526 ba97b2d7 2024-03-20 stsp fi
527 ba97b2d7 2024-03-20 stsp
528 ba97b2d7 2024-03-20 stsp test_done "$testroot" "$ret"
529 ba97b2d7 2024-03-20 stsp }
530 ba97b2d7 2024-03-20 stsp
531 ba97b2d7 2024-03-20 stsp test_parseargs "$@"
532 ba97b2d7 2024-03-20 stsp run_test test_file_changed
533 ba97b2d7 2024-03-20 stsp run_test test_many_commits_not_summarized
534 ba97b2d7 2024-03-20 stsp run_test test_many_commits_summarized
535 ba97b2d7 2024-03-20 stsp run_test test_branch_created
536 ba97b2d7 2024-03-20 stsp run_test test_branch_removed
537 ba97b2d7 2024-03-20 stsp run_test test_tag_created
538 ba97b2d7 2024-03-20 stsp run_test test_tag_changed