3 # Usage: svnmucc-test.py [build-dir-top [base-url]]
10 # calculate the absolute directory in which this test script lives
11 this_dir
= os
.path
.dirname(os
.path
.abspath(sys
.argv
[0]))
13 # add the Subversion Python test suite libraries to the path, and import
14 sys
.path
.insert(0, '%s/../../../subversion/tests/cmdline' % (this_dir
))
17 # calculate the top of the build tree
19 build_top
= os
.path
.abspath(sys
.argv
[1])
21 build_top
= os
.path
.abspath('%s/../../../' % (this_dir
))
23 # where lives svnmucc?
25 os
.path
.abspath('%s/contrib/client-side/svnmucc/svnmucc' % (build_top
))
27 # override some svntest binary locations
28 svntest
.main
.svn_binary
= \
29 os
.path
.abspath('%s/subversion/svn/svn' % (build_top
))
30 svntest
.main
.svnlook_binary
= \
31 os
.path
.abspath('%s/subversion/svnlook/svnlook' % (build_top
))
32 svntest
.main
.svnadmin_binary
= \
33 os
.path
.abspath('%s/subversion/svnadmin/svnadmin' % (build_top
))
35 # where lives the test repository?
37 os
.path
.abspath(('%s/contrib/client-side/svnmucc/svnmucc-test-repos'
40 if (len(sys
.argv
) > 2):
41 repos_url
= sys
.argv
[2] + '/svnmucc-test-repos'
43 repos_url
= 'file://' + repos_path
46 """Write MSG (formatted as a failure) to stderr, and exit with a
47 non-zero errorcode."""
49 sys
.stderr
.write("FAIL: " + msg
+ "\n")
53 _svnmucc_re
= re
.compile('^(r[0-9]+) committed by svnmuccuser at (.*)$')
54 _log_re
= re
.compile('^ ([ADRM] /[^\(]+($| \(from .*:[0-9]+\)$))')
56 def run_svnmucc(expected_path_changes
, *varargs
):
57 """Run svnmucc with the list of SVNMUCC_ARGS arguments. Verify that
58 its run results in a new commit with 'svn log -rHEAD' changed paths
59 that match the list of EXPECTED_PATH_CHANGES."""
62 outlines
, errlines
= svntest
.main
.run_command(svnmucc_binary
, 1, 0,
66 '--config-dir', 'dummy',
69 raise svntest
.main
.SVNCommitFailure(str(errlines
))
70 if len(outlines
) != 1 or not _svnmucc_re
.match(outlines
[0]):
71 raise svntest
.main
.SVNLineUnequal(str(outlines
))
73 # Now, run 'svn log -vq -rHEAD'
75 outlines
, errlines
= svntest
.main
.run_svn(None, 'log', '-vqrHEAD', repos_url
)
77 raise svntest
.Failure("Unable to verify commit with 'svn log': %s"
80 match
= _log_re
.match(line
)
82 changed_paths
.append(match
.group(1).rstrip('\n\r'))
84 expected_path_changes
.sort()
86 if changed_paths
!= expected_path_changes
:
87 raise svntest
.Failure("Logged path changes differ from expectations\n"
89 " actual: %s" % (str(expected_path_changes
),
102 run_svnmucc(['A /z.c',
104 'put', '/dev/null', 'z.c')
107 run_svnmucc(['A /foo/z.c (from /z.c:2)',
108 'A /foo/bar (from /foo:2)',
110 'cp', '2', 'z.c', 'foo/z.c',
111 'cp', '2', 'foo', 'foo/bar')
114 run_svnmucc(['A /zig (from /foo:3)',
117 'A /zig/zag (from /foo:3)',
119 'cp', '3', 'foo', 'zig',
121 'mv', 'foo', 'zig/zag')
124 run_svnmucc(['D /z.c',
125 'A /zig/zag/bar/y.c (from /z.c:4)',
126 'A /zig/zag/bar/x.c (from /z.c:2)',
128 'mv', 'z.c', 'zig/zag/bar/y.c',
129 'cp', '2', 'z.c', 'zig/zag/bar/x.c')
132 run_svnmucc(['D /zig/zag/bar/y.c',
133 'A /zig/zag/bar/y y.c (from /zig/zag/bar/y.c:5)',
134 'A /zig/zag/bar/y%20y.c (from /zig/zag/bar/y.c:5)',
136 'mv', 'zig/zag/bar/y.c', 'zig/zag/bar/y%20y.c',
137 'cp', 'HEAD', 'zig/zag/bar/y.c', 'zig/zag/bar/y%2520y.c')
140 run_svnmucc(['D /zig/zag/bar/y y.c',
141 'A /zig/zag/bar/z z1.c (from /zig/zag/bar/y y.c:6)',
142 'A /zig/zag/bar/z%20z.c (from /zig/zag/bar/y%20y.c:6)',
143 'A /zig/zag/bar/z z2.c (from /zig/zag/bar/y y.c:6)',
145 'mv', 'zig/zag/bar/y%20y.c', 'zig/zag/bar/z z1.c',
146 'cp', 'HEAD', 'zig/zag/bar/y%2520y.c', 'zig/zag/bar/z%2520z.c',
147 'cp', 'HEAD', 'zig/zag/bar/y y.c', 'zig/zag/bar/z z2.c')
150 run_svnmucc(['D /zig/zag',
151 'A /zig/foo (from /zig/zag:7)',
152 'D /zig/foo/bar/z%20z.c',
153 'D /zig/foo/bar/z z2.c',
154 'R /zig/foo/bar/z z1.c (from /zig/zag/bar/x.c:5)',
156 'mv', 'zig/zag', 'zig/foo',
157 'rm', 'zig/foo/bar/z z1.c',
158 'rm', 'zig/foo/bar/z%20z2.c',
159 'rm', 'zig/foo/bar/z%2520z.c',
160 'cp', '5', 'zig/zag/bar/x.c', 'zig/foo/bar/z%20z1.c')
163 run_svnmucc(['R /zig/foo/bar (from /zig/z.c:8)',
166 'cp', '8', 'zig/z.c', 'zig/foo/bar')
169 run_svnmucc(['R /zig/foo/bar (from /zig/foo/bar:8)',
170 'D /zig/foo/bar/z z1.c',
173 'cp', '8', 'zig/foo/bar', 'zig/foo/bar',
174 'rm', 'zig/foo/bar/z%20z1.c')
177 run_svnmucc(['R /zig/foo (from /zig/foo/bar:10)',
180 'cp', 'head', 'zig/foo/bar', 'zig/foo')
183 run_svnmucc(['D /zig',
184 'A /foo (from /foo:3)',
185 'A /foo/foo (from /foo:3)',
186 'A /foo/foo/foo (from /foo:3)',
188 'R /foo/foo/foo/bar (from /foo:3)',
191 'cp', '3', 'foo', 'foo',
192 'cp', '3', 'foo', 'foo/foo',
193 'cp', '3', 'foo', 'foo/foo/foo',
195 'rm', 'foo/foo/foo/bar',
196 'cp', '3', 'foo', 'foo/foo/foo/bar')
199 run_svnmucc(['A /boozle (from /foo:3)',
203 'cp', '3', 'foo', 'boozle',
204 'mkdir', 'boozle/buz',
205 'mkdir', 'boozle/buz/nuz')
208 run_svnmucc(['A /boozle/buz/svnmucc-test.py',
209 'A /boozle/guz (from /boozle/buz:13)',
210 'A /boozle/guz/svnmucc-test.py',
212 'put', '/dev/null', 'boozle/buz/svnmucc-test.py',
213 'cp', '13', 'boozle/buz', 'boozle/guz',
214 'put', '/dev/null', 'boozle/guz/svnmucc-test.py')
217 run_svnmucc(['M /boozle/buz/svnmucc-test.py',
218 'R /boozle/guz/svnmucc-test.py',
220 'put', sys
.argv
[0], 'boozle/buz/svnmucc-test.py',
221 'rm', 'boozle/guz/svnmucc-test.py',
222 'put', sys
.argv
[0], 'boozle/guz/svnmucc-test.py')
225 run_svnmucc(['R /foo/bar (from /foo/foo:15)'], #---------
227 'cp', '15', 'foo/foo', 'foo/bar',
228 'propset', 'testprop', 'true', 'foo/bar')
231 run_svnmucc(['M /foo/bar'], #---------
232 'propdel', 'testprop', 'foo/bar')
234 if __name__
== "__main__":
236 # remove any previously existing repository, then create a new one
237 if os
.path
.exists(repos_path
):
238 shutil
.rmtree(repos_path
)
239 outlines
, errlines
= svntest
.main
.run_svnadmin('create', '--fs-type',
242 raise svntest
.main
.SVNRepositoryCreateFailure(repos_path
)
243 fp
= open(os
.path
.join(repos_path
, 'conf', 'svnserve.conf'), 'w')
244 fp
.write('[general]\nauth-access = write\npassword-db = passwd\n')
246 fp
= open(os
.path
.join(repos_path
, 'conf', 'passwd'), 'w')
247 fp
.write('[users]\nsvnmuccuser = svnmuccpass\n')
250 except SystemExit, e
:
252 except svntest
.main
.SVNCommitFailure
, e
:
253 die("Error committing via svnmucc: %s" % (str(e
)))
254 except svntest
.main
.SVNLineUnequal
, e
:
255 die("Unexpected svnmucc output line: %s" % (str(e
)))
256 except svntest
.main
.SVNRepositoryCreateFailure
, e
:
257 die("Error creating test repository: %s" % (str(e
)))
258 except svntest
.Failure
, e
:
259 die("Test failed: %s" % (str(e
)))
261 die("Something bad happened: %s" % (str(e
)))
263 # cleanup the repository on a successful run
265 if os
.path
.exists(repos_path
):
266 shutil
.rmtree(repos_path
)