~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/tests/clients/cmdline/svnlook_tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
#  svnlook_tests.py:  testing the 'svnlook' tool.
 
4
#
 
5
#  Subversion is a tool for revision control. 
 
6
#  See http://subversion.tigris.org for more information.
 
7
#    
 
8
# ====================================================================
 
9
# Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
10
#
 
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.
 
16
#
 
17
######################################################################
 
18
 
 
19
# General modules
 
20
import string, sys, re, os.path
 
21
 
 
22
# Our testing module
 
23
import svntest
 
24
 
 
25
 
 
26
# (abbreviation)
 
27
Skip = svntest.testcase.Skip
 
28
XFail = svntest.testcase.XFail
 
29
Item = svntest.wc.StateItem
 
30
 
 
31
 
 
32
#----------------------------------------------------------------------
 
33
 
 
34
# Convenience functions to make writing more tests easier
 
35
 
 
36
def run_svnlook(*varargs):
 
37
  output, dummy_errput = svntest.main.run_command(svntest.main.svnlook_binary,
 
38
      0, 0, *varargs)
 
39
  return output
 
40
 
 
41
 
 
42
def expect(tag, expected, got):
 
43
  if expected != got:
 
44
    print "When testing: %s" % tag
 
45
    print "Expected: %s" % expected
 
46
    print "     Got: %s" % got
 
47
    raise svntest.Failure
 
48
 
 
49
 
 
50
# Tests
 
51
 
 
52
def test_misc(sbox):
 
53
  "test miscellaneous svnlook features"
 
54
 
 
55
  sbox.build()
 
56
  wc_dir = sbox.wc_dir
 
57
  repo_dir = sbox.repo_dir
 
58
 
 
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')
 
64
 
 
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'),
 
69
    })
 
70
 
 
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)
 
76
 
 
77
  svntest.actions.run_and_verify_commit (wc_dir,
 
78
                                         expected_output,
 
79
                                         expected_status,
 
80
                                         None,
 
81
                                         None, None,
 
82
                                         None, None,
 
83
                                         wc_dir)
 
84
 
 
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",
 
89
                            "\n",
 
90
                            "UUID: ", uuid, "\n",
 
91
                           ],
 
92
                           'load', '--force-uuid', repo_dir)
 
93
 
 
94
  expect('youngest', [ '2\n' ], run_svnlook('youngest', repo_dir))
 
95
 
 
96
  expect('uuid', [ uuid + '\n' ], run_svnlook('uuid', repo_dir))
 
97
 
 
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.
 
101
 
 
102
  expect('log', [ 'log msg\n' ], run_svnlook('log', repo_dir))
 
103
 
 
104
  expect('propget svn:log', [ 'log msg' ],
 
105
      run_svnlook('propget', '--revprop', repo_dir, 'svn:log'))
 
106
 
 
107
 
 
108
  proplist = run_svnlook('proplist', '--revprop', repo_dir)
 
109
  proplist = [prop.strip() for prop in proplist]
 
110
  proplist.sort()
 
111
 
 
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
 
117
 
 
118
  output, errput = svntest.main.run_svnlook('propget', '--revprop', repo_dir,
 
119
      'foo:bar-baz-quux')
 
120
 
 
121
  rm = re.compile("Property.*not found")
 
122
  for line in errput:
 
123
    match = rm.search(line)
 
124
    if match:
 
125
      break
 
126
  else:
 
127
    raise svntest.main.SVNUnmatchedError
 
128
 
 
129
 
 
130
#----------------------------------------------------------------------
 
131
# Issue 1089
 
132
def delete_file_in_moved_dir(sbox):
 
133
  "delete file in moved dir"
 
134
 
 
135
  sbox.build()
 
136
  wc_dir = sbox.wc_dir
 
137
  repo_dir = sbox.repo_dir
 
138
 
 
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)
 
145
 
 
146
  # commit
 
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'),
 
151
    })
 
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),
 
158
    })
 
159
  svntest.actions.run_and_verify_commit (wc_dir,
 
160
                                         expected_output,
 
161
                                         expected_status,
 
162
                                         None,
 
163
                                         None, None,
 
164
                                         None, None,
 
165
                                         wc_dir)
 
166
 
 
167
  output, errput = svntest.main.run_svnlook("dirs-changed", repo_dir)
 
168
  if errput:
 
169
    raise svntest.Failure
 
170
 
 
171
  # Okay.  No failure, but did we get the right output?
 
172
  if len(output) != 2:
 
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
 
177
 
 
178
 
 
179
#----------------------------------------------------------------------
 
180
# Issue 1241
 
181
def test_print_property_diffs(sbox):
 
182
  "test the printing of property diffs"
 
183
 
 
184
  sbox.build()
 
185
  wc_dir = sbox.wc_dir
 
186
  repo_dir = sbox.repo_dir
 
187
 
 
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)
 
192
 
 
193
  # commit the change
 
194
  svntest.actions.run_and_verify_svn(None, None, [],
 
195
                                     'ci', '-m', 'log msg', iota_path)
 
196
 
 
197
  # Grab the diff
 
198
  expected_output, err = svntest.actions.run_and_verify_svn(None, None, [],
 
199
                                                            'diff',
 
200
                                                            '-r', 'PREV',
 
201
                                                            iota_path)
 
202
 
 
203
  output, errput = svntest.main.run_svnlook("diff", repo_dir)
 
204
  if errput:
 
205
    raise svntest.Failure
 
206
 
 
207
  # Okay.  No failure, but did we get the right output?
 
208
  if len(output) != len(expected_output):
 
209
    raise svntest.Failure
 
210
 
 
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')
 
214
 
 
215
  svntest.actions.compare_and_display_lines('', '', expected_output, output)
 
216
 
 
217
 
 
218
########################################################################
 
219
# Run the tests
 
220
 
 
221
 
 
222
# list all tests here, starting with None:
 
223
test_list = [ None,
 
224
              test_misc,
 
225
              delete_file_in_moved_dir,
 
226
              test_print_property_diffs,
 
227
             ]
 
228
 
 
229
if __name__ == '__main__':
 
230
  svntest.main.run_tests(test_list)
 
231
  # NOTREACHED
 
232
 
 
233
 
 
234
### End of file.