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-revprop-change-bg". |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | . $TEST_SOURCE_DIR/test_header_more |
---|
24 | #------------------------------------------------------------------------------- |
---|
25 | tests 9 |
---|
26 | #------------------------------------------------------------------------------- |
---|
27 | # Add pre-revprop-change to allow revprop change. |
---|
28 | cat >"$REPOS_PATH/hooks/pre-revprop-change" <<__BASH__ |
---|
29 | #!/bin/bash |
---|
30 | exit |
---|
31 | __BASH__ |
---|
32 | chmod +x "$REPOS_PATH/hooks/pre-revprop-change" |
---|
33 | # Add post-revprop-change |
---|
34 | cp -p "$FCM_HOME/etc/svn-hooks/post-revprop-change" \ |
---|
35 | "$REPOS_PATH/hooks/post-revprop-change" |
---|
36 | echo Hello >file |
---|
37 | svn import --no-auth-cache -q -m'test' file "$REPOS_URL/file" |
---|
38 | if [[ -n ${TRAC_ENV_PATH:-} ]]; then |
---|
39 | if $TRAC_RESYNC; then |
---|
40 | trac-admin "$TRAC_ENV_PATH" resync 1>/dev/null |
---|
41 | else |
---|
42 | trac-admin "$TRAC_ENV_PATH" changeset added "$REPOS_PATH" 1 1>/dev/null |
---|
43 | fi |
---|
44 | fi |
---|
45 | #------------------------------------------------------------------------------- |
---|
46 | TEST_KEY=$TEST_KEY_BASE |
---|
47 | run_pass "$TEST_KEY" \ |
---|
48 | svn propset --no-auth-cache -q --revprop -r 1 'svn:log' 'Add hello file' \ |
---|
49 | "$REPOS_URL" |
---|
50 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-revprop-change.log" |
---|
51 | date2datefmt "$REPOS_PATH/log/post-revprop-change.log" \ |
---|
52 | | sed '/^trac-admin/,$d; /^RET_CODE=/d' >"$TEST_KEY.log.expected" |
---|
53 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log.expected" <<__LOG__ |
---|
54 | YYYY-mm-ddTHH:MM:SSZ+ M svn:log @1 by $USER |
---|
55 | --- old-value |
---|
56 | +++ new-value |
---|
57 | @@ -1 +1 @@ |
---|
58 | -test |
---|
59 | \ No newline at end of file |
---|
60 | +Add hello file |
---|
61 | \ No newline at end of file |
---|
62 | __LOG__ |
---|
63 | run_fail "$TEST_KEY.mail.out" test -f mail.out |
---|
64 | if [[ -z ${TRAC_ENV_PATH:-} ]]; then |
---|
65 | skip 1 "$TEST_KEY.trac.db: Trac unavailable" |
---|
66 | else |
---|
67 | sqlite3 "$TRAC_ENV_PATH/db/trac.db" \ |
---|
68 | 'SELECT cast(rev as integer),message FROM revision;' \ |
---|
69 | >"$TEST_KEY.trac.db.expected" |
---|
70 | file_cmp "$TEST_KEY.trac.db" \ |
---|
71 | "$TEST_KEY.trac.db.expected" <<<'1|Add hello file' |
---|
72 | fi |
---|
73 | #------------------------------------------------------------------------------- |
---|
74 | TEST_KEY=$TEST_KEY_BASE-author |
---|
75 | cat /dev/null >"$REPOS_PATH/log/post-revprop-change.log" |
---|
76 | run_pass "$TEST_KEY" \ |
---|
77 | svn propset --no-auth-cache --username=not-a-user --revprop -r 1 'svn:log' \ |
---|
78 | 'Add welcome file' "$REPOS_URL" |
---|
79 | poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-revprop-change.log" |
---|
80 | date2datefmt "$REPOS_PATH/log/post-revprop-change.log" \ |
---|
81 | | sed '/^trac-admin/,$d; /^RET_CODE=/d' >"$TEST_KEY.log.expected" |
---|
82 | file_cmp "$TEST_KEY.log" "$TEST_KEY.log.expected" <<'__LOG__' |
---|
83 | YYYY-mm-ddTHH:MM:SSZ+ M svn:log @1 by not-a-user |
---|
84 | --- old-value |
---|
85 | +++ new-value |
---|
86 | @@ -1 +1 @@ |
---|
87 | -Add hello file |
---|
88 | \ No newline at end of file |
---|
89 | +Add welcome file |
---|
90 | \ No newline at end of file |
---|
91 | __LOG__ |
---|
92 | if [[ -z ${TRAC_ENV_PATH:-} ]]; then |
---|
93 | skip 1 "$TEST_KEY.trac.db: Trac unavailable" |
---|
94 | else |
---|
95 | sqlite3 "$TRAC_ENV_PATH/db/trac.db" \ |
---|
96 | 'SELECT cast(rev as integer),message FROM revision;' \ |
---|
97 | >"$TEST_KEY.trac.db.expected" |
---|
98 | file_cmp "$TEST_KEY.trac.db" \ |
---|
99 | "$TEST_KEY.trac.db.expected" <<<'1|Add welcome file' |
---|
100 | fi |
---|
101 | date2datefmt mail.out | sed '/^trac-admin/,$d; /^RET_CODE=/d' \ |
---|
102 | >"$TEST_KEY.mail.out.expected" |
---|
103 | file_grep "$TEST_KEY.mail.out.01" \ |
---|
104 | '-rnotifications@localhost -sfoo@1 \[M svn:log\] by not-a-user' \ |
---|
105 | "$TEST_KEY.mail.out.expected" |
---|
106 | sed '1d' "$TEST_KEY.mail.out.expected" >"$TEST_KEY.mail.out.expected.02" |
---|
107 | file_cmp "$TEST_KEY.mail.out.02" "$TEST_KEY.mail.out.expected.02" <<__LOG__ |
---|
108 | YYYY-mm-ddTHH:MM:SSZ+ M svn:log @1 by not-a-user |
---|
109 | ======================================================================== |
---|
110 | --- old-value |
---|
111 | +++ new-value |
---|
112 | @@ -1 +1 @@ |
---|
113 | -Add hello file |
---|
114 | \ No newline at end of file |
---|
115 | +Add welcome file |
---|
116 | \ No newline at end of file |
---|
117 | __LOG__ |
---|
118 | #------------------------------------------------------------------------------- |
---|
119 | exit |
---|