~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/tests/clients/cmdline/export_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
#  export_tests.py:  testing export cases.
 
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 shutil, string, sys, re, os
 
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
# Tests
 
34
#
 
35
#   Each test must return on success or raise on failure.
 
36
 
 
37
 
 
38
#----------------------------------------------------------------------
 
39
 
 
40
def export_empty_directory(sbox):
 
41
  "export an empty directory"
 
42
  sbox.build()
 
43
  
 
44
  svntest.main.safe_rmtree(sbox.wc_dir)
 
45
  export_target = sbox.wc_dir
 
46
  empty_dir_url = svntest.main.current_repo_url + '/A/C'
 
47
  svntest.main.run_svn(None, 'export', empty_dir_url, export_target)
 
48
  if not os.path.exists(export_target):
 
49
    raise svntest.Failure
 
50
 
 
51
def export_greek_tree(sbox):
 
52
  "export the greek tree"
 
53
  sbox.build()
 
54
 
 
55
  svntest.main.safe_rmtree(sbox.wc_dir)
 
56
  export_target = sbox.wc_dir
 
57
  expected_output = svntest.main.greek_state.copy()
 
58
  expected_output.wc_dir = sbox.wc_dir
 
59
  expected_output.desc[''] = Item()
 
60
  expected_output.tweak(contents=None, status='A ')
 
61
 
 
62
  svntest.actions.run_and_verify_export(svntest.main.current_repo_url,
 
63
                                        export_target,
 
64
                                        expected_output,
 
65
                                        svntest.main.greek_state.copy())
 
66
 
 
67
def export_working_copy(sbox):
 
68
  "export working copy"
 
69
  sbox.build()
 
70
 
 
71
  export_target = sbox.add_wc_path('export')
 
72
 
 
73
  svntest.actions.run_and_verify_export(sbox.wc_dir,
 
74
                                        export_target,
 
75
                                        svntest.wc.State(sbox.wc_dir, {}),
 
76
                                        svntest.main.greek_state.copy())
 
77
 
 
78
def export_working_copy_with_mods(sbox):
 
79
  "export working copy with mods"
 
80
  sbox.build()
 
81
 
 
82
  wc_dir = sbox.wc_dir
 
83
 
 
84
  # Make a couple of local mods to files
 
85
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
86
  rho_path = os.path.join(wc_dir, 'A', 'D', 'G', 'rho')
 
87
  kappa_path = os.path.join(wc_dir, 'kappa')
 
88
  gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
 
89
  E_path = os.path.join(wc_dir, 'A', 'B', 'E')
 
90
 
 
91
  svntest.main.file_append(mu_path, 'appended mu text')
 
92
  svntest.main.file_append(rho_path, 'new appended text for rho')
 
93
 
 
94
  svntest.main.file_append(kappa_path, "This is the file 'kappa'.")
 
95
  svntest.main.run_svn(None, 'add', kappa_path)
 
96
  svntest.main.run_svn(None, 'rm', E_path, gamma_path)
 
97
 
 
98
  expected_disk = svntest.main.greek_state.copy()
 
99
  expected_disk.tweak('A/mu',
 
100
                      contents=expected_disk.desc['A/mu'].contents
 
101
                      + 'appended mu text')
 
102
  expected_disk.tweak('A/D/G/rho',
 
103
                      contents=expected_disk.desc['A/D/G/rho'].contents
 
104
                      + 'new appended text for rho')
 
105
  expected_disk.add({'kappa' : Item("This is the file 'kappa'.")})
 
106
  expected_disk.remove('A/B/E/alpha', 'A/B/E/beta', 'A/B/E', 'A/D/gamma')
 
107
 
 
108
  export_target = sbox.add_wc_path('export')
 
109
 
 
110
  svntest.actions.run_and_verify_export(sbox.wc_dir,
 
111
                                        export_target,
 
112
                                        svntest.wc.State(sbox.wc_dir, {}),
 
113
                                        expected_disk)
 
114
 
 
115
def export_over_existing_dir(sbox):
 
116
  "export over existing dir"
 
117
  sbox.build()
 
118
 
 
119
  export_target = sbox.add_wc_path('export')
 
120
 
 
121
  # Create the target directory which should cause
 
122
  # the export operation to fail.
 
123
  os.mkdir(export_target)
 
124
 
 
125
  svntest.actions.run_and_verify_svn("No error where one is expected",
 
126
                                     None, svntest.SVNAnyOutput,
 
127
                                     'export', sbox.wc_dir, export_target)
 
128
 
 
129
  # As an extra precaution, make sure export_target doesn't have
 
130
  # anything in it.
 
131
  if len(os.listdir(export_target)):
 
132
    raise svntest.Failure("Unexpected files/directories in " + export_target)
 
133
 
 
134
def export_keyword_translation(sbox):
 
135
  "export with keyword translation"
 
136
  sbox.build()
 
137
 
 
138
  wc_dir = sbox.wc_dir
 
139
 
 
140
  # Add a keyword to A/mu and set the svn:keywords property
 
141
  # appropriately to make sure it's translated during
 
142
  # the export operation
 
143
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
144
  svntest.main.file_append(mu_path, '$LastChangedRevision$')
 
145
  svntest.main.run_svn(None, 'ps', 'svn:keywords', 
 
146
                       'LastChangedRevision', mu_path)
 
147
  svntest.main.run_svn(None, 'ci',
 
148
                       '--username', svntest.main.wc_author,
 
149
                       '--password', svntest.main.wc_passwd,
 
150
                       '-m', 'Added keyword to mu', mu_path)
 
151
 
 
152
  expected_disk = svntest.main.greek_state.copy()
 
153
  expected_disk.tweak('A/mu',
 
154
                      contents=expected_disk.desc['A/mu'].contents + 
 
155
                      '$LastChangedRevision: 2 $')
 
156
 
 
157
  export_target = sbox.add_wc_path('export')
 
158
 
 
159
  expected_output = svntest.main.greek_state.copy()
 
160
  expected_output.wc_dir = export_target
 
161
  expected_output.desc[''] = Item()
 
162
  expected_output.tweak(contents=None, status='A ')
 
163
 
 
164
  svntest.actions.run_and_verify_export(sbox.repo_url,
 
165
                                        export_target,
 
166
                                        expected_output,
 
167
                                        expected_disk)
 
168
 
 
169
def export_eol_translation(sbox):
 
170
  "export with eol translation"
 
171
  sbox.build()
 
172
 
 
173
  wc_dir = sbox.wc_dir
 
174
 
 
175
  # Append a '\n' to A/mu and set svn:eol-style to 'CR'
 
176
  # to see if it's applied correctly in the export operation
 
177
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
178
  svntest.main.file_append(mu_path, '\n')
 
179
  svntest.main.run_svn(None, 'ps', 'svn:eol-style', 
 
180
                       'CR', mu_path)
 
181
  svntest.main.run_svn(None, 'ci',
 
182
                       '--username', svntest.main.wc_author,
 
183
                       '--password', svntest.main.wc_passwd,
 
184
                       '-m', 'Added eol-style prop to mu', mu_path)
 
185
 
 
186
  expected_disk = svntest.main.greek_state.copy()
 
187
  expected_disk.tweak('A/mu',
 
188
                      contents=expected_disk.desc['A/mu'].contents + 
 
189
                      '\r')
 
190
 
 
191
  export_target = sbox.add_wc_path('export')
 
192
 
 
193
  expected_output = svntest.main.greek_state.copy()
 
194
  expected_output.wc_dir = export_target
 
195
  expected_output.desc[''] = Item()
 
196
  expected_output.tweak(contents=None, status='A ')
 
197
 
 
198
  svntest.actions.run_and_verify_export(sbox.repo_url,
 
199
                                        export_target,
 
200
                                        expected_output,
 
201
                                        expected_disk)
 
202
 
 
203
def export_working_copy_with_keyword_translation(sbox):
 
204
  "export working copy with keyword translation"
 
205
  sbox.build()
 
206
 
 
207
  wc_dir = sbox.wc_dir
 
208
 
 
209
  # Add a keyword to A/mu and set the svn:keywords property
 
210
  # appropriately to make sure it's translated during
 
211
  # the export operation
 
212
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
213
  svntest.main.file_append(mu_path, '$LastChangedRevision$')
 
214
  svntest.main.run_svn(None, 'ps', 'svn:keywords', 
 
215
                       'LastChangedRevision', mu_path)
 
216
 
 
217
  expected_disk = svntest.main.greek_state.copy()
 
218
  expected_disk.tweak('A/mu',
 
219
                      contents=expected_disk.desc['A/mu'].contents + 
 
220
                      '$LastChangedRevision: 1M $')
 
221
 
 
222
  export_target = sbox.add_wc_path('export')
 
223
 
 
224
  svntest.actions.run_and_verify_export(wc_dir,
 
225
                                        export_target,
 
226
                                        svntest.wc.State(sbox.wc_dir, {}),
 
227
                                        expected_disk)
 
228
 
 
229
def export_working_copy_with_property_mods(sbox):
 
230
  "export working copy with property mods"
 
231
  sbox.build()
 
232
 
 
233
  wc_dir = sbox.wc_dir
 
234
 
 
235
  # Make a local property mod to A/mu
 
236
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
237
  svntest.main.file_append(mu_path, '\n')
 
238
  svntest.main.run_svn(None, 'ps', 'svn:eol-style',
 
239
                       'CR', mu_path)
 
240
 
 
241
  expected_disk = svntest.main.greek_state.copy()
 
242
  expected_disk.tweak('A/mu',
 
243
                      contents=expected_disk.desc['A/mu'].contents +
 
244
                      '\r')
 
245
 
 
246
  export_target = sbox.add_wc_path('export')
 
247
 
 
248
  svntest.actions.run_and_verify_export(wc_dir,
 
249
                                        export_target,
 
250
                                        svntest.wc.State(sbox.wc_dir, {}),
 
251
                                        expected_disk)
 
252
 
 
253
def export_working_copy_at_base_revision(sbox):
 
254
  "export working copy at base revision"
 
255
  sbox.build()
 
256
 
 
257
  wc_dir = sbox.wc_dir
 
258
 
 
259
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
260
  kappa_path = os.path.join(wc_dir, 'kappa')
 
261
  gamma_path = os.path.join(wc_dir, 'A', 'D', 'gamma')
 
262
  E_path = os.path.join(wc_dir, 'A', 'B', 'E')
 
263
 
 
264
  # Appends some text to A/mu, and add a new file
 
265
  # called kappa.  These modifications should *not*
 
266
  # get exported at the base revision.
 
267
  svntest.main.file_append(mu_path, 'Appended text')
 
268
  svntest.main.file_append(kappa_path, "This is the file 'kappa'.")
 
269
  svntest.main.run_svn(None, 'add', kappa_path)
 
270
  svntest.main.run_svn(None, 'rm', E_path, gamma_path)
 
271
 
 
272
  # Note that we don't tweak the expected disk tree at all,
 
273
  # since the appended text and kappa should not be present.
 
274
  expected_disk = svntest.main.greek_state.copy()
 
275
 
 
276
  export_target = sbox.add_wc_path('export')
 
277
 
 
278
  svntest.actions.run_and_verify_export(wc_dir,
 
279
                                        export_target,
 
280
                                        svntest.wc.State(sbox.wc_dir, {}),
 
281
                                        expected_disk,
 
282
                                        None, None, None, None,
 
283
                                        '-rBASE')
 
284
 
 
285
def export_native_eol_option(sbox):
 
286
  "export with --native-eol"
 
287
  sbox.build()
 
288
 
 
289
  wc_dir = sbox.wc_dir
 
290
 
 
291
  # Append a '\n' to A/mu and set svn:eol-style to 'native'
 
292
  # to see if it's applied correctly in the export operation
 
293
  mu_path = os.path.join(wc_dir, 'A', 'mu')
 
294
  svntest.main.file_append(mu_path, '\n')
 
295
  svntest.main.run_svn(None, 'ps', 'svn:eol-style', 
 
296
                       'native', mu_path)
 
297
  svntest.main.run_svn(None, 'ci',
 
298
                       '--username', svntest.main.wc_author,
 
299
                       '--password', svntest.main.wc_passwd,
 
300
                       '-m', 'Added eol-style prop to mu', mu_path)
 
301
 
 
302
  expected_disk = svntest.main.greek_state.copy()
 
303
  expected_disk.tweak('A/mu',
 
304
                      contents=expected_disk.desc['A/mu'].contents + 
 
305
                      '\r')
 
306
 
 
307
  export_target = sbox.add_wc_path('export')
 
308
 
 
309
  expected_output = svntest.main.greek_state.copy()
 
310
  expected_output.wc_dir = export_target
 
311
  expected_output.desc[''] = Item()
 
312
  expected_output.tweak(contents=None, status='A ')
 
313
 
 
314
  svntest.actions.run_and_verify_export(sbox.repo_url,
 
315
                                        export_target,
 
316
                                        expected_output,
 
317
                                        expected_disk,
 
318
                                        None, None, None, None,
 
319
                                        '--native-eol','CR')
 
320
 
 
321
def export_nonexistant_file(sbox):
 
322
  "export nonexistant file"
 
323
  sbox.build()
 
324
 
 
325
  wc_dir = sbox.wc_dir
 
326
 
 
327
  kappa_path = os.path.join(wc_dir, 'kappa')
 
328
 
 
329
  export_target = sbox.add_wc_path('export')
 
330
 
 
331
  svntest.actions.run_and_verify_svn("No error where one is expected",
 
332
                                     None, svntest.SVNAnyOutput,
 
333
                                     'export', kappa_path, export_target)
 
334
 
 
335
def export_unversioned_file(sbox):
 
336
  "export unversioned file"
 
337
  sbox.build()
 
338
 
 
339
  wc_dir = sbox.wc_dir
 
340
 
 
341
  kappa_path = os.path.join(wc_dir, 'kappa')
 
342
  svntest.main.file_append(kappa_path, "This is the file 'kappa'.")
 
343
 
 
344
  export_target = sbox.add_wc_path('export')
 
345
 
 
346
  svntest.actions.run_and_verify_svn("No error where one is expected",
 
347
                                     None, svntest.SVNAnyOutput,
 
348
                                     'export', kappa_path, export_target)
 
349
 
 
350
def export_with_state_deleted(sbox):
 
351
  "export with state deleted=true"
 
352
  sbox.build()
 
353
 
 
354
  wc_dir = sbox.wc_dir
 
355
 
 
356
  # state deleted=true caused export to crash
 
357
  alpha_path = os.path.join(wc_dir, 'A', 'B', 'E', 'alpha')
 
358
  svntest.actions.run_and_verify_svn(None, None, [], 'rm', alpha_path)
 
359
  expected_output = svntest.wc.State(wc_dir, {
 
360
    'A/B/E/alpha' : Item(verb='Deleting'),
 
361
    })
 
362
  expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
 
363
  expected_status.tweak(wc_rev=1)
 
364
  expected_status.remove('A/B/E/alpha')
 
365
  svntest.actions.run_and_verify_commit(wc_dir,
 
366
                                        expected_output, expected_status,
 
367
                                        None, None, None, None, None,
 
368
                                        wc_dir)
 
369
 
 
370
  export_target = sbox.add_wc_path('export')
 
371
  expected_output = svntest.wc.State(sbox.wc_dir, {})
 
372
  expected_disk = svntest.main.greek_state.copy()
 
373
  expected_disk.remove('A/B/E/alpha')
 
374
  svntest.actions.run_and_verify_export(sbox.wc_dir,
 
375
                                        export_target,
 
376
                                        expected_output,
 
377
                                        expected_disk)
 
378
 
 
379
########################################################################
 
380
# Run the tests
 
381
 
 
382
 
 
383
# list all tests here, starting with None:
 
384
test_list = [ None,
 
385
              export_empty_directory,
 
386
              export_greek_tree,
 
387
              export_working_copy,
 
388
              export_working_copy_with_mods,
 
389
              export_over_existing_dir,
 
390
              export_keyword_translation,
 
391
              export_eol_translation,
 
392
              export_working_copy_with_keyword_translation,
 
393
              export_working_copy_with_property_mods,
 
394
              export_working_copy_at_base_revision,
 
395
              export_native_eol_option,
 
396
              export_nonexistant_file,
 
397
              export_unversioned_file,
 
398
              export_with_state_deleted,
 
399
             ]
 
400
 
 
401
if __name__ == '__main__':
 
402
  svntest.main.run_tests(test_list)
 
403
  # NOTREACHED
 
404
 
 
405
 
 
406
### End of file.