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 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
82 ce1bfad9 2024-03-30 thomas
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
85 ce1bfad9 2024-03-30 thomas ret=$?
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"
89 ce1bfad9 2024-03-30 thomas return 1
90 ce1bfad9 2024-03-30 thomas fi
91 ce1bfad9 2024-03-30 thomas
92 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
93 ce1bfad9 2024-03-30 thomas }
94 ce1bfad9 2024-03-30 thomas
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`
97 ce1bfad9 2024-03-30 thomas
98 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
99 ce1bfad9 2024-03-30 thomas ret=$?
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
103 ce1bfad9 2024-03-30 thomas return 1
104 ce1bfad9 2024-03-30 thomas fi
105 ce1bfad9 2024-03-30 thomas
106 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
107 ce1bfad9 2024-03-30 thomas ret=$?
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
111 ce1bfad9 2024-03-30 thomas return 1
112 ce1bfad9 2024-03-30 thomas fi
113 ce1bfad9 2024-03-30 thomas
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"
121 ce1bfad9 2024-03-30 thomas done
122 ce1bfad9 2024-03-30 thomas
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) &
125 ce1bfad9 2024-03-30 thomas
126 ce1bfad9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
127 ce1bfad9 2024-03-30 thomas ret=$?
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"
131 ce1bfad9 2024-03-30 thomas return 1
132 ce1bfad9 2024-03-30 thomas fi
133 ce1bfad9 2024-03-30 thomas
134 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
135 ce1bfad9 2024-03-30 thomas
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
163 ce1bfad9 2024-03-30 thomas done
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
167 ce1bfad9 2024-03-30 thomas
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
170 ce1bfad9 2024-03-30 thomas ret=$?
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"
174 ce1bfad9 2024-03-30 thomas return 1
175 ce1bfad9 2024-03-30 thomas fi
176 ce1bfad9 2024-03-30 thomas
177 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
178 ce1bfad9 2024-03-30 thomas }
179 ce1bfad9 2024-03-30 thomas
180 ce1bfad9 2024-03-30 thomas test_many_commits_summarized() {
181 ce1bfad9 2024-03-30 thomas local testroot=`test_init many_commits_summarized 1`
182 ce1bfad9 2024-03-30 thomas
183 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
184 ce1bfad9 2024-03-30 thomas ret=$?
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
188 ce1bfad9 2024-03-30 thomas return 1
189 ce1bfad9 2024-03-30 thomas fi
190 ce1bfad9 2024-03-30 thomas
191 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
192 ce1bfad9 2024-03-30 thomas ret=$?
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
196 ce1bfad9 2024-03-30 thomas return 1
197 ce1bfad9 2024-03-30 thomas fi
198 ce1bfad9 2024-03-30 thomas
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 ce1bfad9 2024-03-30 thomas d=`date -u -r $author_time +"%G-%m-%d"`
206 ce1bfad9 2024-03-30 thomas set -- "$@" "$short_commit_id $d"
207 ce1bfad9 2024-03-30 thomas done
208 ce1bfad9 2024-03-30 thomas
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) &
211 ce1bfad9 2024-03-30 thomas
212 ce1bfad9 2024-03-30 thomas got send -b main -q -r $testroot/repo-clone
213 ce1bfad9 2024-03-30 thomas ret=$?
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"
217 ce1bfad9 2024-03-30 thomas return 1
218 ce1bfad9 2024-03-30 thomas fi
219 ce1bfad9 2024-03-30 thomas
220 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
221 ce1bfad9 2024-03-30 thomas
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
241 ce1bfad9 2024-03-30 thomas done
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
245 ce1bfad9 2024-03-30 thomas
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
248 ce1bfad9 2024-03-30 thomas ret=$?
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"
252 ce1bfad9 2024-03-30 thomas return 1
253 ce1bfad9 2024-03-30 thomas fi
254 ce1bfad9 2024-03-30 thomas
255 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
256 ce1bfad9 2024-03-30 thomas }
257 ce1bfad9 2024-03-30 thomas
258 ce1bfad9 2024-03-30 thomas test_branch_created() {
259 ce1bfad9 2024-03-30 thomas local testroot=`test_init branch_created 1`
260 ce1bfad9 2024-03-30 thomas
261 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
262 ce1bfad9 2024-03-30 thomas ret=$?
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
266 ce1bfad9 2024-03-30 thomas return 1
267 ce1bfad9 2024-03-30 thomas fi
268 ce1bfad9 2024-03-30 thomas
269 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
270 ce1bfad9 2024-03-30 thomas ret=$?
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
274 ce1bfad9 2024-03-30 thomas return 1
275 ce1bfad9 2024-03-30 thomas fi
276 ce1bfad9 2024-03-30 thomas
277 ce1bfad9 2024-03-30 thomas (cd $testroot/wt && got branch newbranch > /dev/null)
278 ce1bfad9 2024-03-30 thomas
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`
283 ce1bfad9 2024-03-30 thomas
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) &
286 ce1bfad9 2024-03-30 thomas
287 ce1bfad9 2024-03-30 thomas got send -b newbranch -q -r $testroot/repo-clone
288 ce1bfad9 2024-03-30 thomas ret=$?
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"
292 ce1bfad9 2024-03-30 thomas return 1
293 ce1bfad9 2024-03-30 thomas fi
294 ce1bfad9 2024-03-30 thomas
295 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
296 ce1bfad9 2024-03-30 thomas
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
322 ce1bfad9 2024-03-30 thomas
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
325 ce1bfad9 2024-03-30 thomas ret=$?
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"
329 ce1bfad9 2024-03-30 thomas return 1
330 ce1bfad9 2024-03-30 thomas fi
331 ce1bfad9 2024-03-30 thomas
332 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
333 ce1bfad9 2024-03-30 thomas }
334 ce1bfad9 2024-03-30 thomas
335 ce1bfad9 2024-03-30 thomas test_branch_removed() {
336 ce1bfad9 2024-03-30 thomas local testroot=`test_init branch_removed 1`
337 ce1bfad9 2024-03-30 thomas
338 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
339 ce1bfad9 2024-03-30 thomas ret=$?
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
343 ce1bfad9 2024-03-30 thomas return 1
344 ce1bfad9 2024-03-30 thomas fi
345 ce1bfad9 2024-03-30 thomas
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) &
348 ce1bfad9 2024-03-30 thomas
349 ce1bfad9 2024-03-30 thomas local commit_id=`git_show_branch_head $testroot/repo-clone newbranch`
350 ce1bfad9 2024-03-30 thomas
351 ce1bfad9 2024-03-30 thomas got send -d newbranch -q -r $testroot/repo-clone
352 ce1bfad9 2024-03-30 thomas ret=$?
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"
356 ce1bfad9 2024-03-30 thomas return 1
357 ce1bfad9 2024-03-30 thomas fi
358 ce1bfad9 2024-03-30 thomas
359 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
360 ce1bfad9 2024-03-30 thomas
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
378 ce1bfad9 2024-03-30 thomas
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
381 ce1bfad9 2024-03-30 thomas ret=$?
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"
385 ce1bfad9 2024-03-30 thomas return 1
386 ce1bfad9 2024-03-30 thomas fi
387 ce1bfad9 2024-03-30 thomas
388 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
389 ce1bfad9 2024-03-30 thomas }
390 ce1bfad9 2024-03-30 thomas
391 ce1bfad9 2024-03-30 thomas test_tag_created() {
392 ce1bfad9 2024-03-30 thomas local testroot=`test_init tag_created 1`
393 ce1bfad9 2024-03-30 thomas
394 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
395 ce1bfad9 2024-03-30 thomas ret=$?
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
399 ce1bfad9 2024-03-30 thomas return 1
400 ce1bfad9 2024-03-30 thomas fi
401 ce1bfad9 2024-03-30 thomas
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`
405 ce1bfad9 2024-03-30 thomas
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) &
408 ce1bfad9 2024-03-30 thomas
409 ce1bfad9 2024-03-30 thomas got send -t 1.0 -q -r $testroot/repo-clone
410 ce1bfad9 2024-03-30 thomas ret=$?
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"
414 ce1bfad9 2024-03-30 thomas return 1
415 ce1bfad9 2024-03-30 thomas fi
416 ce1bfad9 2024-03-30 thomas
417 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
418 ce1bfad9 2024-03-30 thomas
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
442 ce1bfad9 2024-03-30 thomas
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
445 ce1bfad9 2024-03-30 thomas ret=$?
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"
449 ce1bfad9 2024-03-30 thomas return 1
450 ce1bfad9 2024-03-30 thomas fi
451 ce1bfad9 2024-03-30 thomas
452 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
453 ce1bfad9 2024-03-30 thomas }
454 ce1bfad9 2024-03-30 thomas
455 ce1bfad9 2024-03-30 thomas test_tag_changed() {
456 ce1bfad9 2024-03-30 thomas local testroot=`test_init tag_changed 1`
457 ce1bfad9 2024-03-30 thomas
458 ce1bfad9 2024-03-30 thomas got clone -a -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone
459 ce1bfad9 2024-03-30 thomas ret=$?
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
463 ce1bfad9 2024-03-30 thomas return 1
464 ce1bfad9 2024-03-30 thomas fi
465 ce1bfad9 2024-03-30 thomas
466 ce1bfad9 2024-03-30 thomas got checkout -q $testroot/repo-clone $testroot/wt >/dev/null
467 ce1bfad9 2024-03-30 thomas ret=$?
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
471 ce1bfad9 2024-03-30 thomas return 1
472 ce1bfad9 2024-03-30 thomas fi
473 ce1bfad9 2024-03-30 thomas
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`
477 ce1bfad9 2024-03-30 thomas
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`
481 ce1bfad9 2024-03-30 thomas
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) &
484 ce1bfad9 2024-03-30 thomas
485 ce1bfad9 2024-03-30 thomas got send -f -t 1.0 -q -r $testroot/repo-clone
486 ce1bfad9 2024-03-30 thomas ret=$?
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"
490 ce1bfad9 2024-03-30 thomas return 1
491 ce1bfad9 2024-03-30 thomas fi
492 ce1bfad9 2024-03-30 thomas
493 ce1bfad9 2024-03-30 thomas wait %1 # wait for nc -l
494 ce1bfad9 2024-03-30 thomas
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
518 ce1bfad9 2024-03-30 thomas
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
521 ce1bfad9 2024-03-30 thomas ret=$?
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"
525 ce1bfad9 2024-03-30 thomas return 1
526 ce1bfad9 2024-03-30 thomas fi
527 ce1bfad9 2024-03-30 thomas
528 ce1bfad9 2024-03-30 thomas test_done "$testroot" "$ret"
529 ce1bfad9 2024-03-30 thomas }
530 ce1bfad9 2024-03-30 thomas
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