3
# svnlook_tests.py: testing the 'svnlook' tool.
5
# Subversion is a tool for revision control.
6
# See http://subversion.tigris.org for more information.
8
# ====================================================================
9
# Copyright (c) 2000-2004 CollabNet. All rights reserved.
11
# This software is licensed as described in the file COPYING, which
12
# you should have received as part of this distribution. The terms
13
# are also available at http://subversion.tigris.org/license-1.html.
14
# If newer versions of this license are posted there, you may use a
15
# newer version instead, at your option.
17
######################################################################
20
import string, sys, re, os.path
27
Skip = svntest.testcase.Skip
28
XFail = svntest.testcase.XFail
29
Item = svntest.wc.StateItem
32
#----------------------------------------------------------------------
34
# Convenience functions to make writing more tests easier
36
def run_svnlook(*varargs):
37
output, dummy_errput = svntest.main.run_command(svntest.main.svnlook_binary,
42
def expect(tag, expected, got):
44
print "When testing: %s" % tag
45
print "Expected: %s" % expected
46
print " Got: %s" % got
53
"test miscellaneous svnlook features"
57
repo_dir = sbox.repo_dir
59
# Make a couple of local mods to files
60
mu_path = os.path.join(wc_dir, 'A', 'mu')
61
rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
62
svntest.main.file_append (mu_path, 'appended mu text')
63
svntest.main.file_append (rho_path, 'new appended text for rho')
65
# Created expected output tree for 'svn ci'
66
expected_output = svntest.wc.State(wc_dir, {
67
'A/mu' : Item(verb='Sending'),
68
'A/D/G/rho' : Item(verb='Sending'),
71
# Create expected status tree; all local revisions should be at 1,
72
# but mu and rho should be at revision 2.
73
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
74
expected_status.tweak(wc_rev=1)
75
expected_status.tweak('A/mu', 'A/D/G/rho', wc_rev=2)
77
svntest.actions.run_and_verify_commit (wc_dir,
85
# give the repo a new UUID
86
uuid = "01234567-89ab-cdef-89ab-cdef01234567"
87
svntest.main.run_command_stdin(svntest.main.svnadmin_binary, None, 1,
88
["SVN-fs-dump-format-version: 2\n",
92
'load', '--force-uuid', repo_dir)
94
expect('youngest', [ '2\n' ], run_svnlook('youngest', repo_dir))
96
expect('uuid', [ uuid + '\n' ], run_svnlook('uuid', repo_dir))
98
# it would be nice to test the author too, but the current test framework
99
# does not pull a username when testing over ra_dav or ra_svn,
100
# so the commits have an empty author.
102
expect('log', [ 'log msg\n' ], run_svnlook('log', repo_dir))
104
expect('propget svn:log', [ 'log msg' ],
105
run_svnlook('propget', '--revprop', repo_dir, 'svn:log'))
108
proplist = run_svnlook('proplist', '--revprop', repo_dir)
109
proplist = [prop.strip() for prop in proplist]
112
# We cannot rely on svn:author's presence. ra_svn doesn't set it.
113
if not (proplist == [ 'svn:author', 'svn:date', 'svn:log' ]
114
or proplist == [ 'svn:date', 'svn:log' ]):
115
print "Unexpected result from proplist: %s" % proplist
116
raise svntest.Failure
118
output, errput = svntest.main.run_svnlook('propget', '--revprop', repo_dir,
121
rm = re.compile("Property.*not found")
123
match = rm.search(line)
127
raise svntest.main.SVNUnmatchedError
130
#----------------------------------------------------------------------
132
def delete_file_in_moved_dir(sbox):
133
"delete file in moved dir"
137
repo_dir = sbox.repo_dir
139
# move E to E2 and delete E2/alpha
140
E_path = os.path.join(wc_dir, 'A', 'B', 'E')
141
E2_path = os.path.join(wc_dir, 'A', 'B', 'E2')
142
svntest.actions.run_and_verify_svn(None, None, [], 'mv', E_path, E2_path)
143
alpha_path = os.path.join(E2_path, 'alpha')
144
svntest.actions.run_and_verify_svn(None, None, [], 'rm', alpha_path)
147
expected_output = svntest.wc.State(wc_dir, {
148
'A/B/E' : Item(verb='Deleting'),
149
'A/B/E2' : Item(verb='Adding'),
150
'A/B/E2/alpha' : Item(verb='Deleting'),
152
expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
153
expected_status.tweak(wc_rev=1)
154
expected_status.remove('A/B/E', 'A/B/E/alpha', 'A/B/E/beta')
155
expected_status.add({
156
'A/B/E2' : Item(status=' ', wc_rev=2),
157
'A/B/E2/beta' : Item(status=' ', wc_rev=2),
159
svntest.actions.run_and_verify_commit (wc_dir,
167
output, errput = svntest.main.run_svnlook("dirs-changed", repo_dir)
169
raise svntest.Failure
171
# Okay. No failure, but did we get the right output?
173
raise svntest.Failure
174
if not ((string.strip(output[0]) == 'A/B/')
175
and (string.strip(output[1]) == 'A/B/E2/')):
176
raise svntest.Failure
179
#----------------------------------------------------------------------
181
def test_print_property_diffs(sbox):
182
"test the printing of property diffs"
186
repo_dir = sbox.repo_dir
188
# Add a bogus property to iota
189
iota_path = os.path.join(wc_dir, 'iota')
190
svntest.actions.run_and_verify_svn(None, None, [], 'propset',
191
'bogus_prop', 'bogus_val', iota_path)
194
svntest.actions.run_and_verify_svn(None, None, [],
195
'ci', '-m', 'log msg', iota_path)
198
expected_output, err = svntest.actions.run_and_verify_svn(None, None, [],
203
output, errput = svntest.main.run_svnlook("diff", repo_dir)
205
raise svntest.Failure
207
# Okay. No failure, but did we get the right output?
208
if len(output) != len(expected_output):
209
raise svntest.Failure
211
# replace wcdir/iota with iota in expected_output
212
for i in xrange(len(expected_output)):
213
expected_output[i] = string.replace(expected_output[i], iota_path, 'iota')
215
svntest.actions.compare_and_display_lines('', '', expected_output, output)
218
########################################################################
222
# list all tests here, starting with None:
225
delete_file_in_moved_dir,
226
test_print_property_diffs,
229
if __name__ == '__main__':
230
svntest.main.run_tests(test_list)