1 | #!/bin/bash |
---|
2 | #------------------------------------------------------------------------------- |
---|
3 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
4 | # |
---|
5 | # This file is part of FCM, tools for managing and building source code. |
---|
6 | # |
---|
7 | # FCM is free software: you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation, either version 3 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # FCM is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | #------------------------------------------------------------------------------- |
---|
20 | # Basic tests for "post-commit-bg". |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | FCM_SVN_HOOK_ADMIN_EMAIL=fcm.admin.team |
---|
24 | . $TEST_SOURCE_DIR/test_header_more |
---|
25 | |
---|
26 | test_tidy() { |
---|
27 | rm -f \ |
---|
28 | "$REPOS_PATH/hooks/post-commit-bg-custom" \ |
---|
29 | "$REPOS_PATH/hooks/post-commit-background-custom" \ |
---|
30 | "$REPOS_PATH/hooks/commit.conf" \ |
---|
31 | "$REPOS_PATH/log/post-commit.log" \ |
---|
32 | 'file1' \ |
---|
33 | 'file2' \ |
---|
34 | 'file3' \ |
---|
35 | 'file4' \ |
---|
36 | 'file5' \ |
---|
37 | 'svnperms.conf' \ |
---|
38 | 'mail.out' |
---|
39 | } |
---|
40 | #------------------------------------------------------------------------------- |
---|
41 | tests 44 |
---|
42 | #------------------------------------------------------------------------------- |
---|
43 | cp -p "$FCM_HOME/etc/svn-hooks/post-commit" "$REPOS_PATH/hooks/" |
---|
44 | sed -i "/set -eu/a\ |
---|
45 | echo \$2 >$PWD/rev; echo \$3 >$PWD/txn" "$REPOS_PATH/hooks/post-commit" |
---|
46 | #------------------------------------------------------------------------------- |
---|
47 | TEST_KEY="$TEST_KEY_BASE-basic" |
---|
48 | test_tidy |
---|
49 | touch file1 |
---|
50 | svn import --no-auth-cache -q -m"$TEST_KEY" file1 "$REPOS_URL/file1" |
---|
51 | REV=$(<rev) |
---|
52 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
53 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
54 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
55 | >"$TEST_KEY.log" |
---|
56 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
57 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
58 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
59 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
60 | * Dumped revision $REV. |
---|
61 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
62 | REV_FILE_SIZE=??? # <1MB |
---|
63 | RET_CODE=0 |
---|
64 | __LOG__ |
---|
65 | if [[ -n ${TRAC_ENV_PATH:-} ]] && ! $TRAC_RESYNC; then |
---|
66 | sqlite3 "$TRAC_ENV_PATH/db/trac.db" \ |
---|
67 | 'SELECT cast(rev as integer),message FROM revision;' \ |
---|
68 | >"$TEST_KEY.trac.db.expected" |
---|
69 | file_cmp "$TEST_KEY.trac.db" \ |
---|
70 | "$TEST_KEY.trac.db.expected" <<<"$REV|$TEST_KEY" |
---|
71 | else |
---|
72 | skip 1 '"trac-admin changeset added" not available' |
---|
73 | fi |
---|
74 | run_pass "$TEST_KEY.dump" test -s "$PWD/svn-dumps/foo-$REV.gz" |
---|
75 | run_fail "$TEST_KEY.mail.out" test -e mail.out |
---|
76 | #------------------------------------------------------------------------------- |
---|
77 | # Install and remove commit.conf, svnperms.conf |
---|
78 | for NAME in 'commit.conf' 'svnperms.conf'; do |
---|
79 | TEST_KEY="$TEST_KEY_BASE-no-add-${NAME}" |
---|
80 | test_tidy |
---|
81 | # (Use "svnperms.conf" syntax. Doesn't matter for the purpose of this test.) |
---|
82 | cat >"${NAME}" <<'__CONF__' |
---|
83 | [foo] |
---|
84 | .*=*(add,remove,update) |
---|
85 | __CONF__ |
---|
86 | mkdir -p "svn-hooks/foo" |
---|
87 | cat >"svn-hooks/foo/${NAME}" <<'__CONF__' |
---|
88 | # This is the site override |
---|
89 | [foo] |
---|
90 | .*=*(add,remove,update) |
---|
91 | __CONF__ |
---|
92 | cp -p "svn-hooks/foo/${NAME}" "$REPOS_PATH/hooks/${NAME}" |
---|
93 | svn import --no-auth-cache -q -m"${TEST_KEY}" "${NAME}" \ |
---|
94 | "${REPOS_URL}/${NAME}" |
---|
95 | REV="$(<'rev')" |
---|
96 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
97 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
98 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
99 | >"$TEST_KEY.log" |
---|
100 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
101 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
102 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
103 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
104 | * Dumped revision $REV. |
---|
105 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
106 | REV_FILE_SIZE=??? # <1MB |
---|
107 | RET_CODE=0 |
---|
108 | __LOG__ |
---|
109 | file_cmp "${TEST_KEY}.conf" \ |
---|
110 | "svn-hooks/foo/${NAME}" "$REPOS_PATH/hooks/${NAME}" |
---|
111 | rm -fr 'svn-hooks' |
---|
112 | |
---|
113 | test_tidy |
---|
114 | svn delete --no-auth-cache -q -m"Delete ${TEST_KEY}" "${REPOS_URL}/${NAME}" |
---|
115 | |
---|
116 | TEST_KEY="$TEST_KEY_BASE-add-${NAME}" |
---|
117 | test_tidy |
---|
118 | # (Use "svnperms.conf" syntax. Doesn't matter for the purpose of this test.) |
---|
119 | cat >${NAME} <<'__CONF__' |
---|
120 | [foo] |
---|
121 | .*=*(add,remove,update) |
---|
122 | __CONF__ |
---|
123 | svn import --no-auth-cache -q -m"$TEST_KEY" ${NAME} \ |
---|
124 | "$REPOS_URL/${NAME}" |
---|
125 | REV=$(<rev) |
---|
126 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
127 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
128 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
129 | >"$TEST_KEY.log" |
---|
130 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
131 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
132 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
133 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
134 | * Dumped revision $REV. |
---|
135 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
136 | REV_FILE_SIZE=??? # <1MB |
---|
137 | svnlook cat $REPOS_PATH ${NAME} >$REPOS_PATH/hooks/${NAME} |
---|
138 | RET_CODE=0 |
---|
139 | __LOG__ |
---|
140 | file_cmp "$TEST_KEY.conf" ${NAME} "$REPOS_PATH/hooks/${NAME}" |
---|
141 | |
---|
142 | TEST_KEY="$TEST_KEY_BASE-modify-${NAME}" |
---|
143 | test_tidy |
---|
144 | svn co -q "$REPOS_URL" work |
---|
145 | # (Use "svnperms.conf" syntax. Doesn't matter for the purpose of this test.) |
---|
146 | cat >work/${NAME} <<'__CONF__' |
---|
147 | [foo] |
---|
148 | .*=*(add,remove,update) |
---|
149 | |
---|
150 | [bar] |
---|
151 | __CONF__ |
---|
152 | svn commit --no-auth-cache -q -m"$TEST_KEY" work |
---|
153 | REV=$(<rev) |
---|
154 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
155 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
156 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
157 | >"$TEST_KEY.log" |
---|
158 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
159 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
160 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
161 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
162 | * Dumped revision $REV. |
---|
163 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
164 | REV_FILE_SIZE=??? # <1MB |
---|
165 | svnlook cat $REPOS_PATH ${NAME} >$REPOS_PATH/hooks/${NAME} |
---|
166 | RET_CODE=0 |
---|
167 | __LOG__ |
---|
168 | file_cmp "$TEST_KEY.conf" work/${NAME} "$REPOS_PATH/hooks/${NAME}" |
---|
169 | rm -f -r work |
---|
170 | |
---|
171 | TEST_KEY="$TEST_KEY_BASE-remove-${NAME}" |
---|
172 | test_tidy |
---|
173 | touch "$REPOS_PATH/hooks/${NAME}" |
---|
174 | svn rm --no-auth-cache -q -m'remove ${NAME}' "$REPOS_URL/${NAME}" |
---|
175 | REV=$(<rev) |
---|
176 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
177 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
178 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
179 | >"$TEST_KEY.log" |
---|
180 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
181 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
182 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
183 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
184 | * Dumped revision $REV. |
---|
185 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
186 | REV_FILE_SIZE=??? # <1MB |
---|
187 | rm -f $REPOS_PATH/hooks/${NAME} |
---|
188 | RET_CODE=0 |
---|
189 | __LOG__ |
---|
190 | run_fail "$TEST_KEY.conf" test -e "$REPOS_PATH/hooks/${NAME}" |
---|
191 | done |
---|
192 | #------------------------------------------------------------------------------- |
---|
193 | TEST_KEY="$TEST_KEY_BASE-size" |
---|
194 | test_tidy |
---|
195 | perl -e 'map {print(rand())} 1..524288' >file2 # compress should be >1MB |
---|
196 | svn import --no-auth-cache -q -m"$TEST_KEY" file2 "$REPOS_URL/file2" |
---|
197 | REV=$(<rev) |
---|
198 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
199 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
200 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
201 | >"$TEST_KEY.log" |
---|
202 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
203 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
204 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
205 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
206 | * Dumped revision $REV. |
---|
207 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
208 | REV_FILE_SIZE=??? # >1MB <10MB |
---|
209 | RET_CODE=1 |
---|
210 | __LOG__ |
---|
211 | date2datefmt mail.out \ |
---|
212 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
213 | >"$TEST_KEY.mail.out" |
---|
214 | file_cmp "$TEST_KEY.mail.out" "$TEST_KEY.mail.out" <<__LOG__ |
---|
215 | -s [post-commit-bg] $REPOS_PATH@$REV fcm.admin.team |
---|
216 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
217 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
218 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
219 | * Dumped revision $REV. |
---|
220 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
221 | REV_FILE_SIZE=??? # >1MB <10MB |
---|
222 | RET_CODE=1 |
---|
223 | __LOG__ |
---|
224 | #------------------------------------------------------------------------------- |
---|
225 | TEST_KEY="$TEST_KEY_BASE-size-2" |
---|
226 | test_tidy |
---|
227 | perl -e 'map {print(rand())} 1..2097152' >'file3' # compress should be >10MB |
---|
228 | svn import --no-auth-cache -q -m"${TEST_KEY}" 'file3' "${REPOS_URL}/file3" |
---|
229 | REV="$(<'rev')" |
---|
230 | poll 10 grep -q '^RET_CODE=' "${REPOS_PATH}/log/post-commit.log" |
---|
231 | poll 10 test -e 'mail.out' |
---|
232 | date2datefmt "${REPOS_PATH}/log/post-commit.log" \ |
---|
233 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
234 | >"${TEST_KEY}.log" |
---|
235 | file_cmp "${TEST_KEY}.log" "${TEST_KEY}.log" <<__LOG__ |
---|
236 | YYYY-mm-ddTHH:MM:SSZ+ ${REV} by ${USER} |
---|
237 | svnadmin dump -r${REV} --incremental --deltas ${REPOS_PATH} | gzip \\ |
---|
238 | | (dd 'conv=fsync' "of=${PWD}/svn-dumps/foo-${REV}-tmp.gz" 2>/dev/null) |
---|
239 | * Dumped revision ${REV}. |
---|
240 | mv "${PWD}/svn-dumps/foo-${REV}-tmp.gz" "${PWD}/svn-dumps/foo-${REV}.gz" |
---|
241 | REV_FILE_SIZE=??? # >10MB |
---|
242 | RET_CODE=1 |
---|
243 | __LOG__ |
---|
244 | date2datefmt mail.out \ |
---|
245 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
246 | >"${TEST_KEY}.mail.out" |
---|
247 | file_cmp "${TEST_KEY}.mail.out" "${TEST_KEY}.mail.out" <<__LOG__ |
---|
248 | -s [post-commit-bg] ${REPOS_PATH}@${REV} fcm.admin.team |
---|
249 | YYYY-mm-ddTHH:MM:SSZ+ ${REV} by ${USER} |
---|
250 | svnadmin dump -r${REV} --incremental --deltas ${REPOS_PATH} | gzip \\ |
---|
251 | | (dd 'conv=fsync' "of=${PWD}/svn-dumps/foo-${REV}-tmp.gz" 2>/dev/null) |
---|
252 | * Dumped revision ${REV}. |
---|
253 | mv "${PWD}/svn-dumps/foo-${REV}-tmp.gz" "${PWD}/svn-dumps/foo-${REV}.gz" |
---|
254 | REV_FILE_SIZE=??? # >10MB |
---|
255 | RET_CODE=1 |
---|
256 | __LOG__ |
---|
257 | #------------------------------------------------------------------------------- |
---|
258 | TEST_KEY="$TEST_KEY_BASE-custom-1" # good custom |
---|
259 | test_tidy |
---|
260 | touch file4 |
---|
261 | cat >"$REPOS_PATH/hooks/post-commit-bg-custom" <<'__BASH__' |
---|
262 | #!/bin/bash |
---|
263 | echo "$@" |
---|
264 | __BASH__ |
---|
265 | chmod +x "$REPOS_PATH/hooks/post-commit-bg-custom" |
---|
266 | svn import --no-auth-cache -q -m"$TEST_KEY" file4 "$REPOS_URL/file4" |
---|
267 | REV=$(<rev) |
---|
268 | TXN=$(<txn) |
---|
269 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
270 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
271 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
272 | >"$TEST_KEY.log" |
---|
273 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
274 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
275 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
276 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
277 | * Dumped revision $REV. |
---|
278 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
279 | REV_FILE_SIZE=??? # <1MB |
---|
280 | $REPOS_PATH/hooks/post-commit-bg-custom $REPOS_PATH $REV $TXN |
---|
281 | $REPOS_PATH $REV $TXN |
---|
282 | RET_CODE=0 |
---|
283 | __LOG__ |
---|
284 | run_fail "$TEST_KEY.mail.out" test -e mail.out |
---|
285 | #------------------------------------------------------------------------------- |
---|
286 | TEST_KEY="$TEST_KEY_BASE-custom-2" # bad custom |
---|
287 | test_tidy |
---|
288 | cat >"$REPOS_PATH/hooks/post-commit-background-custom" <<'__BASH__' |
---|
289 | #!/bin/bash |
---|
290 | echo 'I have gone to the dark side.' >&2 |
---|
291 | false |
---|
292 | __BASH__ |
---|
293 | chmod +x "$REPOS_PATH/hooks/post-commit-background-custom" |
---|
294 | touch file5 |
---|
295 | svn import --no-auth-cache -q -m"$TEST_KEY" file5 "$REPOS_URL/file5" |
---|
296 | REV=$(<rev) |
---|
297 | TXN=$(<txn) |
---|
298 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
299 | date2datefmt "$REPOS_PATH/log/post-commit.log" \ |
---|
300 | | sed '/^trac-admin/d; s/^\(REV_FILE_SIZE=\).*\( #\)/\1???\2/' \ |
---|
301 | >"$TEST_KEY.log" |
---|
302 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log" <<__LOG__ |
---|
303 | YYYY-mm-ddTHH:MM:SSZ+ $REV by $USER |
---|
304 | svnadmin dump -r$REV --incremental --deltas $REPOS_PATH | gzip \\ |
---|
305 | | (dd 'conv=fsync' "of=$PWD/svn-dumps/foo-$REV-tmp.gz" 2>/dev/null) |
---|
306 | * Dumped revision $REV. |
---|
307 | mv "$PWD/svn-dumps/foo-$REV-tmp.gz" "$PWD/svn-dumps/foo-$REV.gz" |
---|
308 | REV_FILE_SIZE=??? # <1MB |
---|
309 | $REPOS_PATH/hooks/post-commit-background-custom $REPOS_PATH $REV $TXN |
---|
310 | I have gone to the dark side. |
---|
311 | RET_CODE=1 |
---|
312 | __LOG__ |
---|
313 | file_test "$TEST_KEY.mail.out" mail.out |
---|
314 | #------------------------------------------------------------------------------- |
---|
315 | # Test branch owner notification |
---|
316 | echo 'Hello World' >file |
---|
317 | svn import -q -m'hello world' file "$REPOS_URL/hello/trunk/file" |
---|
318 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
319 | |
---|
320 | TEST_KEY="$TEST_KEY_BASE-branch-create-owner-1" # create author is owner |
---|
321 | test_tidy |
---|
322 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
323 | svn cp -q -m '' --parents \ |
---|
324 | "$REPOS_URL/hello/trunk" \ |
---|
325 | "$REPOS_URL/hello/branches/dev/$USER/whatever" |
---|
326 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
327 | run_fail "$TEST_KEY.mail.out" test -s mail.out |
---|
328 | |
---|
329 | TEST_KEY="$TEST_KEY_BASE-branch-create-owner-2" # create author not owner |
---|
330 | test_tidy |
---|
331 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
332 | svn cp -q -m '' --parents \ |
---|
333 | --username=root \ |
---|
334 | --no-auth-cache \ |
---|
335 | "$REPOS_URL/hello/trunk" \ |
---|
336 | "$REPOS_URL/hello/branches/test/$USER/whatever" |
---|
337 | REV=$(<rev) |
---|
338 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
339 | file_grep "$TEST_KEY.mail.out.1" \ |
---|
340 | "^-rnotifications@localhost -sfoo@${REV} by root" mail.out |
---|
341 | file_grep "$TEST_KEY.mail.out.2" "^r${REV} | root" mail.out |
---|
342 | |
---|
343 | TEST_KEY="$TEST_KEY_BASE-branch-create-owner-3" # same as 2, but no notify |
---|
344 | test_tidy |
---|
345 | svn cp -q -m '' --parents \ |
---|
346 | --username=root \ |
---|
347 | --no-auth-cache \ |
---|
348 | "$REPOS_URL/hello/trunk" \ |
---|
349 | "$REPOS_URL/hello/branches/test/$USER/whatever2" |
---|
350 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
351 | run_fail "$TEST_KEY.mail.out" test -s mail.out |
---|
352 | |
---|
353 | TEST_KEY="$TEST_KEY_BASE-branch-modify-owner-1" # modify author is owner |
---|
354 | test_tidy |
---|
355 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
356 | svn co -q "$REPOS_URL/hello/branches/dev/$USER/whatever" hello |
---|
357 | echo 'Hello Earth' >hello/file |
---|
358 | svn ci -q -m'Hello Earth' hello/file |
---|
359 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
360 | run_fail "$TEST_KEY.mail.out" test -s mail.out |
---|
361 | |
---|
362 | TEST_KEY="$TEST_KEY_BASE-branch-modify-owner-2" # modify author not owner |
---|
363 | test_tidy |
---|
364 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
365 | #svn co -q "$REPOS_URL/hello/branches/dev/$USER/whatever" hello |
---|
366 | echo 'Hello Alien' >hello/file |
---|
367 | svn ci -q -m'Hello Earth' --username=root --no-auth-cache hello/file |
---|
368 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
369 | REV=$(<rev) |
---|
370 | file_grep "$TEST_KEY.mail.out.1" \ |
---|
371 | "^-rnotifications@localhost -sfoo@${REV} by root" mail.out |
---|
372 | file_grep "$TEST_KEY.mail.out.2" "^r${REV} | root" mail.out |
---|
373 | |
---|
374 | TEST_KEY="$TEST_KEY_BASE-share-branch-owner-1" # modify share author is owner |
---|
375 | test_tidy |
---|
376 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
377 | svn cp -q -m '' --parents \ |
---|
378 | "$REPOS_URL/hello/trunk" \ |
---|
379 | "$REPOS_URL/hello/branches/dev/Share/whatever" |
---|
380 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
381 | run_fail "$TEST_KEY.create.mail.out" test -s mail.out |
---|
382 | test_tidy |
---|
383 | echo 'Greet Alien' >'greet.txt' |
---|
384 | svn import -q -m '' 'greet.txt' \ |
---|
385 | "$REPOS_URL/hello/branches/dev/Share/whatever/greet.txt" |
---|
386 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
387 | run_fail "$TEST_KEY.modify.mail.out" test -s mail.out |
---|
388 | |
---|
389 | TEST_KEY="$TEST_KEY_BASE-share-branch-owner-2" # modify share author not owner |
---|
390 | test_tidy |
---|
391 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
392 | echo 'Hail Alien' >'hail.txt' |
---|
393 | svn import -q -m '' --username=root --no-auth-cache 'hail.txt' \ |
---|
394 | "$REPOS_URL/hello/branches/dev/Share/whatever/hail.txt" |
---|
395 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
396 | REV=$(<rev) |
---|
397 | file_grep "$TEST_KEY.mail.out.1" \ |
---|
398 | "^-rnotifications@localhost -sfoo@${REV} by root" 'mail.out' |
---|
399 | file_grep "$TEST_KEY.mail.out.2" "^r${REV} | root" 'mail.out' |
---|
400 | |
---|
401 | TEST_KEY="$TEST_KEY_BASE-branch-delete-owner-1" # delete author is owner |
---|
402 | test_tidy |
---|
403 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
404 | svn rm -q -m'No Hello' "$REPOS_URL/hello/branches/dev/$USER/whatever" |
---|
405 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
406 | run_fail "$TEST_KEY.mail.out" test -s mail.out |
---|
407 | |
---|
408 | TEST_KEY="$TEST_KEY_BASE-branch-delete-owner-2" # delete author not owner |
---|
409 | test_tidy |
---|
410 | echo 'notify-owner' >"${REPOS_PATH}/hooks/commit.conf" |
---|
411 | svn rm -q -m'No Hello' --username=root --no-auth-cache \ |
---|
412 | "$REPOS_URL/hello/branches/test/$USER/whatever" |
---|
413 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-commit.log" |
---|
414 | REV=$(<rev) |
---|
415 | file_grep "$TEST_KEY.mail.out.1" \ |
---|
416 | "^-rnotifications@localhost -sfoo@${REV} by root" mail.out |
---|
417 | file_grep "$TEST_KEY.mail.out.2" "^r${REV} | root" mail.out |
---|
418 | #------------------------------------------------------------------------------- |
---|
419 | # Test owner notification |
---|
420 | TEST_KEY="${TEST_KEY_BASE}-owner-1" # trunk author is not owner |
---|
421 | test_tidy |
---|
422 | cat >"${REPOS_PATH}/hooks/commit.conf" <<__CONF__ |
---|
423 | notify-owner |
---|
424 | owner = $USER |
---|
425 | __CONF__ |
---|
426 | rm -fr 'hello' |
---|
427 | svn co -q "${REPOS_URL}/hello/trunk" 'hello' |
---|
428 | echo 'Hello' >'hello/file' |
---|
429 | svn ci -q -m 'hello whatever' '--no-auth-cache' '--username=root' 'hello' |
---|
430 | poll 10 grep -q '^RET_CODE=' "${REPOS_PATH}/log/post-commit.log" |
---|
431 | poll 10 test -e 'mail.out' |
---|
432 | REV="$(<rev)" |
---|
433 | file_grep "${TEST_KEY}.mail.out.1" \ |
---|
434 | "^-rnotifications@localhost -sfoo@${REV} by root" 'mail.out' |
---|
435 | file_grep "${TEST_KEY}.mail.out.2" "^r${REV} | root" 'mail.out' |
---|
436 | #------------------------------------------------------------------------------- |
---|
437 | exit |
---|