New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
01-post-revprop-change-bg.t in vendors/FCM-2017.10.0/t/svn-hooks – NEMO

source: vendors/FCM-2017.10.0/t/svn-hooks/01-post-revprop-change-bg.t @ 13688

Last change on this file since 13688 was 10672, checked in by nicolasmartin, 5 years ago

Reimport latest FCM release

File size: 4.6 KB
Line 
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#-------------------------------------------------------------------------------
25tests 9
26#-------------------------------------------------------------------------------
27# Add pre-revprop-change to allow revprop change.
28cat >"$REPOS_PATH/hooks/pre-revprop-change" <<__BASH__
29#!/bin/bash
30exit
31__BASH__
32chmod +x "$REPOS_PATH/hooks/pre-revprop-change"
33# Add post-revprop-change
34cp -p "$FCM_HOME/etc/svn-hooks/post-revprop-change" \
35    "$REPOS_PATH/hooks/post-revprop-change"
36echo Hello >file
37svn import --no-auth-cache -q -m'test' file "$REPOS_URL/file"
38if [[ -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
44fi
45#-------------------------------------------------------------------------------
46TEST_KEY=$TEST_KEY_BASE
47run_pass "$TEST_KEY" \
48    svn propset --no-auth-cache -q --revprop -r 1 'svn:log' 'Add hello file' \
49    "$REPOS_URL"
50poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-revprop-change.log"
51date2datefmt "$REPOS_PATH/log/post-revprop-change.log" \
52    | sed '/^trac-admin/,$d; /^RET_CODE=/d' >"$TEST_KEY.log.expected"
53file_cmp "$TEST_KEY.log" "$TEST_KEY.log.expected" <<__LOG__
54YYYY-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__
63run_fail "$TEST_KEY.mail.out" test -f mail.out
64if [[ -z ${TRAC_ENV_PATH:-} ]]; then
65    skip 1 "$TEST_KEY.trac.db: Trac unavailable"
66else
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'
72fi
73#-------------------------------------------------------------------------------
74TEST_KEY=$TEST_KEY_BASE-author
75cat /dev/null >"$REPOS_PATH/log/post-revprop-change.log"
76run_pass "$TEST_KEY" \
77    svn propset --no-auth-cache --username=not-a-user --revprop -r 1 'svn:log' \
78    'Add welcome file' "$REPOS_URL"
79poll 10 grep -q '^RET_CODE=' "$REPOS_PATH/log/post-revprop-change.log"
80date2datefmt "$REPOS_PATH/log/post-revprop-change.log" \
81    | sed '/^trac-admin/,$d; /^RET_CODE=/d' >"$TEST_KEY.log.expected"
82file_cmp "$TEST_KEY.log" "$TEST_KEY.log.expected" <<'__LOG__'
83YYYY-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__
92if [[ -z ${TRAC_ENV_PATH:-} ]]; then
93    skip 1 "$TEST_KEY.trac.db: Trac unavailable"
94else
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'
100fi
101date2datefmt mail.out | sed '/^trac-admin/,$d; /^RET_CODE=/d' \
102    >"$TEST_KEY.mail.out.expected"
103file_grep  "$TEST_KEY.mail.out.01" \
104    '-rnotifications@localhost -sfoo@1 \[M svn:log\] by not-a-user' \
105    "$TEST_KEY.mail.out.expected"
106sed '1d' "$TEST_KEY.mail.out.expected" >"$TEST_KEY.mail.out.expected.02"
107file_cmp  "$TEST_KEY.mail.out.02" "$TEST_KEY.mail.out.expected.02" <<__LOG__
108YYYY-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#-------------------------------------------------------------------------------
119exit
Note: See TracBrowser for help on using the repository browser.