3 # svnversion_tests.py: testing the 'svnversion' tool.
5 # Subversion is a tool for revision control.
6 # See http://subversion.tigris.org for more information.
8 # ====================================================================
9 # Copyright (c) 2003 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 ######################################################################
25 from svntest
import wc
28 Skip
= svntest
.testcase
.Skip
29 XFail
= svntest
.testcase
.XFail
30 Item
= svntest
.wc
.StateItem
32 #----------------------------------------------------------------------
34 def svnversion_test(sbox
):
35 "test 'svnversion' on wc and other dirs"
38 repo_url
= sbox
.repo_url
41 svntest
.actions
.run_and_verify_svnversion("Unmodified working copy",
45 # Unmodified, whole wc switched
46 svntest
.actions
.run_and_verify_svnversion("Unmodified switched working copy",
47 wc_dir
, "some/other/url",
50 mu_path
= os
.path
.join(wc_dir
, 'A', 'mu')
51 svntest
.main
.file_append(mu_path
, 'appended mu text')
54 svntest
.actions
.run_and_verify_svnversion("Modified text", wc_dir
, repo_url
,
57 expected_output
= wc
.State(wc_dir
, {'A/mu' : Item(verb
='Sending')})
58 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
59 expected_status
.tweak('A/mu', wc_rev
=2)
60 if svntest
.actions
.run_and_verify_commit(wc_dir
,
61 expected_output
, expected_status
,
66 svntest
.actions
.run_and_verify_svnversion("Unmodified mixed working copy",
70 svntest
.actions
.run_and_verify_svn(None, None, [],
71 'propset', 'blue', 'azul',
72 os
.path
.join(wc_dir
, 'A', 'mu'))
74 # Prop modified, mixed
75 svntest
.actions
.run_and_verify_svnversion("Property modified mixed wc",
79 iota_path
= os
.path
.join(wc_dir
, 'iota')
80 gamma_url
= sbox
.repo_url
+ '/A/D/gamma'
81 expected_output
= wc
.State(wc_dir
, {'iota' : Item(status
='U ')})
82 expected_status
.tweak('A/mu', status
=' M')
83 expected_status
.tweak('iota', switched
='S', wc_rev
=2)
84 expected_disk
= svntest
.main
.greek_state
.copy()
85 expected_disk
.tweak('A/mu',
86 contents
=expected_disk
.desc
['A/mu'].contents
88 expected_disk
.tweak('iota',
89 contents
=expected_disk
.desc
['A/D/gamma'].contents
)
90 if svntest
.actions
.run_and_verify_switch(wc_dir
, iota_path
, gamma_url
,
96 # Prop modified, mixed, part wc switched
97 svntest
.actions
.run_and_verify_svnversion("Prop-mod mixed partly switched",
101 # Plain (exported) directory that is a direct subdir of a versioned dir
102 Q_path
= os
.path
.join(wc_dir
, 'Q')
104 svntest
.actions
.run_and_verify_svnversion("Exported subdirectory",
106 [ "exported\n" ], [])
108 # Plain (exported) directory that is not a direct subdir of a versioned dir
109 R_path
= os
.path
.join(Q_path
, 'Q')
111 svntest
.actions
.run_and_verify_svnversion("Exported directory",
113 [ "exported\n" ], [])
115 # No directory generates an error
116 svntest
.actions
.run_and_verify_svnversion("None existent directory",
117 os
.path
.join(wc_dir
, 'Q', 'X'),
119 None, svntest
.verify
.AnyOutput
)
121 # Perform a sparse checkout of under the existing WC, and confirm that
122 # svnversion detects it as a "partial" WC.
123 A_path
= os
.path
.join(wc_dir
, "A")
124 A_A_path
= os
.path
.join(A_path
, "SPARSE_A")
125 expected_output
= wc
.State(A_path
, {
127 "SPARSE_A/mu" : Item(status
='A '),
129 expected_disk
= wc
.State("", {
130 "mu" : Item(expected_disk
.desc
['A/mu'].contents
),
132 svntest
.actions
.run_and_verify_checkout(repo_url
+ "/A", A_A_path
,
133 expected_output
, expected_disk
,
134 None, None, None, None,
137 # Partial (sparse) checkout
138 svntest
.actions
.run_and_verify_svnversion("Sparse checkout", A_A_path
,
139 repo_url
, [ "2SP\n" ], [])
142 #----------------------------------------------------------------------
144 def ignore_externals(sbox
):
145 "test 'svnversion' with svn:externals"
148 repo_url
= sbox
.repo_url
150 # Set up an external item
151 C_path
= os
.path
.join(wc_dir
, "A", "C")
152 externals_desc
= "ext -r 1 " + repo_url
+ "/A/D/G" + "\n"
153 tmp_f
= os
.tempnam(wc_dir
, 'tmp')
154 svntest
.main
.file_append(tmp_f
, externals_desc
)
155 svntest
.actions
.run_and_verify_svn(None, None, [],
157 '-F', tmp_f
, 'svn:externals', C_path
)
159 expected_output
= svntest
.wc
.State(wc_dir
, {
160 'A/C' : Item(verb
='Sending'),
162 expected_status
= svntest
.actions
.get_virginal_state(wc_dir
, 1)
163 expected_status
.tweak('A/C', wc_rev
=2)
164 svntest
.actions
.run_and_verify_commit(wc_dir
,
169 # Update to get it on disk
170 svntest
.actions
.run_and_verify_svn(None, None, [], 'up', wc_dir
)
171 ext_path
= os
.path
.join(C_path
, 'ext')
172 exit_code
, out
, err
= svntest
.actions
.run_and_verify_svn(
173 None, svntest
.verify
.AnyOutput
, [], 'info', ext_path
)
176 if line
.find('Revision: 1') != -1:
179 raise svntest
.Failure
181 svntest
.actions
.run_and_verify_svnversion("working copy with svn:externals",
185 ########################################################################
189 # list all tests here, starting with None:
195 if __name__
== '__main__':
196 warnings
.filterwarnings('ignore', 'tempnam', RuntimeWarning)
197 svntest
.main
.run_tests(test_list
)