source: valtobtest/subversion-1.6.2/subversion/tests/cmdline/export_tests.py @ 3

Last change on this file since 3 was 3, checked in by valtob, 15 years ago

subversion source 1.6.2 as test

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