3 # export_tests.py: testing export cases.
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 ######################################################################
27 Skip
= svntest
.testcase
.Skip
28 XFail
= svntest
.testcase
.XFail
29 Item
= svntest
.wc
.StateItem
32 ######################################################################
35 # Each test must return on success or raise on failure.
38 #----------------------------------------------------------------------
40 def export_empty_directory(sbox
):
41 "export an empty directory"
42 sbox
.build(create_wc
= False, read_only
= True)
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
):
51 def export_greek_tree(sbox
):
52 "export the greek tree"
53 sbox
.build(create_wc
= False, read_only
= True)
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 ')
62 svntest
.actions
.run_and_verify_export(sbox
.repo_url
,
65 svntest
.main
.greek_state
.copy())
67 def export_nonexistent_url(sbox
):
68 "attempt to export a nonexistent URL"
69 sbox
.build(create_wc
= False, read_only
= True)
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
)
78 def export_working_copy(sbox
):
80 sbox
.build(read_only
= True)
82 export_target
= sbox
.add_wc_path('export')
84 svntest
.actions
.run_and_verify_export(sbox
.wc_dir
,
86 svntest
.wc
.State(sbox
.wc_dir
, {}),
87 svntest
.main
.greek_state
.copy())
89 def export_working_copy_with_mods(sbox
):
90 "export working copy with mods"
91 sbox
.build(read_only
= True)
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')
102 svntest
.main
.file_append(mu_path
, 'appended mu text')
103 svntest
.main
.file_append(rho_path
, 'new appended text for rho')
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
)
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')
119 export_target
= sbox
.add_wc_path('export')
121 svntest
.actions
.run_and_verify_export(sbox
.wc_dir
,
123 svntest
.wc
.State(sbox
.wc_dir
, {}),
126 def export_over_existing_dir(sbox
):
127 "export over existing dir"
128 sbox
.build(read_only
= True)
130 export_target
= sbox
.add_wc_path('export')
132 # Create the target directory which should cause
133 # the export operation to fail.
134 os
.mkdir(export_target
)
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
)
140 # As an extra precaution, make sure export_target doesn't have
142 if len(os
.listdir(export_target
)):
143 raise svntest
.Failure("Unexpected files/directories in " + export_target
)
145 def export_keyword_translation(sbox
):
146 "export with keyword translation"
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
)
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 $')
166 export_target
= sbox
.add_wc_path('export')
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 ')
173 svntest
.actions
.run_and_verify_export(sbox
.repo_url
,
178 def export_eol_translation(sbox
):
179 "export with eol translation"
184 # Set svn:eol-style to 'CR' to see if it's applied correctly in the
186 mu_path
= os
.path
.join(wc_dir
, 'A', 'mu')
187 svntest
.main
.run_svn(None, 'ps', 'svn:eol-style',
189 svntest
.main
.run_svn(None, 'ci',
190 '-m', 'Added eol-style prop to mu', mu_path
)
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
)
196 export_target
= sbox
.add_wc_path('export')
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 ')
203 svntest
.actions
.run_and_verify_export(sbox
.repo_url
,
208 def export_working_copy_with_keyword_translation(sbox
):
209 "export working copy with keyword translation"
210 sbox
.build(read_only
= True)
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
)
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 $')
227 export_target
= sbox
.add_wc_path('export')
229 svntest
.actions
.run_and_verify_export(wc_dir
,
231 svntest
.wc
.State(sbox
.wc_dir
, {}),
234 def export_working_copy_with_property_mods(sbox
):
235 "export working copy with property mods"
236 sbox
.build(read_only
= True)
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',
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
)
249 export_target
= sbox
.add_wc_path('export')
251 svntest
.actions
.run_and_verify_export(wc_dir
,
253 svntest
.wc
.State(sbox
.wc_dir
, {}),
256 def export_working_copy_at_base_revision(sbox
):
257 "export working copy at base revision"
258 sbox
.build(read_only
= True)
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')
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
)
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()
279 export_target
= sbox
.add_wc_path('export')
281 svntest
.actions
.run_and_verify_export(wc_dir
,
283 svntest
.wc
.State(sbox
.wc_dir
, {}),
285 None, None, None, None,
288 def export_native_eol_option(sbox
):
289 "export with --native-eol"
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',
299 svntest
.main
.run_svn(None, 'ci',
300 '-m', 'Added eol-style prop to mu', mu_path
)
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
)
306 export_target
= sbox
.add_wc_path('export')
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 ')
313 svntest
.actions
.run_and_verify_export(sbox
.repo_url
,
317 None, None, None, None,
320 def export_nonexistent_file(sbox
):
321 "export nonexistent file"
322 sbox
.build(read_only
= True)
326 kappa_path
= os
.path
.join(wc_dir
, 'kappa')
328 export_target
= sbox
.add_wc_path('export')
330 svntest
.actions
.run_and_verify_svn("No error where one is expected",
331 None, svntest
.verify
.AnyOutput
,
332 'export', kappa_path
, export_target
)
334 def export_unversioned_file(sbox
):
335 "export unversioned file"
336 sbox
.build(read_only
= True)
340 kappa_path
= os
.path
.join(wc_dir
, 'kappa')
341 svntest
.main
.file_append(kappa_path
, "This is the file 'kappa'.")
343 export_target
= sbox
.add_wc_path('export')
345 svntest
.actions
.run_and_verify_svn("No error where one is expected",
346 None, svntest
.verify
.AnyOutput
,
347 'export', kappa_path
, export_target
)
349 def export_with_state_deleted(sbox
):
350 "export with state deleted=true"
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'),
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
,
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
,
376 def export_creates_intermediate_folders(sbox
):
377 "export and create some intermediate folders"
378 sbox
.build(create_wc
= False, read_only
= True)
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 ')
387 svntest
.actions
.run_and_verify_export(sbox
.repo_url
,
390 svntest
.main
.greek_state
.copy())
392 ########################################################################
396 # list all tests here, starting with None:
398 export_empty_directory
,
400 export_nonexistent_url
,
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
,
416 if __name__
== '__main__':
417 svntest
.main
.run_tests(test_list
)