Blame


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