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 exit_code
, outlines
, errlines
= \
63 svntest
.main
.run_command(svnmucc_binary
, 1, 0,
67 '--config-dir', 'dummy',
70 raise svntest
.main
.SVNCommitFailure(str(errlines
))
71 if len(outlines
) != 1 or not _svnmucc_re
.match(outlines
[0]):
72 raise svntest
.main
.SVNLineUnequal(str(outlines
))
74 # Now, run 'svn log -vq -rHEAD'
76 exit_code
, outlines
, errlines
= \
77 svntest
.main
.run_svn(None, 'log', '-vqrHEAD', repos_url
)
79 raise svntest
.Failure("Unable to verify commit with 'svn log': %s"
82 match
= _log_re
.match(line
)
84 changed_paths
.append(match
.group(1).rstrip('\n\r'))
86 expected_path_changes
.sort()
88 if changed_paths
!= expected_path_changes
:
89 raise svntest
.Failure("Logged path changes differ from expectations\n"
91 " actual: %s" % (str(expected_path_changes
),
104 run_svnmucc(['A /z.c',
106 'put', '/dev/null', 'z.c')
109 run_svnmucc(['A /foo/z.c (from /z.c:2)',
110 'A /foo/bar (from /foo:2)',
112 'cp', '2', 'z.c', 'foo/z.c',
113 'cp', '2', 'foo', 'foo/bar')
116 run_svnmucc(['A /zig (from /foo:3)',
119 'A /zig/zag (from /foo:3)',
121 'cp', '3', 'foo', 'zig',
123 'mv', 'foo', 'zig/zag')
126 run_svnmucc(['D /z.c',
127 'A /zig/zag/bar/y.c (from /z.c:4)',
128 'A /zig/zag/bar/x.c (from /z.c:2)',
130 'mv', 'z.c', 'zig/zag/bar/y.c',
131 'cp', '2', 'z.c', 'zig/zag/bar/x.c')
134 run_svnmucc(['D /zig/zag/bar/y.c',
135 'A /zig/zag/bar/y y.c (from /zig/zag/bar/y.c:5)',
136 'A /zig/zag/bar/y%20y.c (from /zig/zag/bar/y.c:5)',
138 'mv', 'zig/zag/bar/y.c', 'zig/zag/bar/y%20y.c',
139 'cp', 'HEAD', 'zig/zag/bar/y.c', 'zig/zag/bar/y%2520y.c')
142 run_svnmucc(['D /zig/zag/bar/y y.c',
143 'A /zig/zag/bar/z z1.c (from /zig/zag/bar/y y.c:6)',
144 'A /zig/zag/bar/z%20z.c (from /zig/zag/bar/y%20y.c:6)',
145 'A /zig/zag/bar/z z2.c (from /zig/zag/bar/y y.c:6)',
147 'mv', 'zig/zag/bar/y%20y.c', 'zig/zag/bar/z z1.c',
148 'cp', 'HEAD', 'zig/zag/bar/y%2520y.c', 'zig/zag/bar/z%2520z.c',
149 'cp', 'HEAD', 'zig/zag/bar/y y.c', 'zig/zag/bar/z z2.c')
152 run_svnmucc(['D /zig/zag',
153 'A /zig/foo (from /zig/zag:7)',
154 'D /zig/foo/bar/z%20z.c',
155 'D /zig/foo/bar/z z2.c',
156 'R /zig/foo/bar/z z1.c (from /zig/zag/bar/x.c:5)',
158 'mv', 'zig/zag', 'zig/foo',
159 'rm', 'zig/foo/bar/z z1.c',
160 'rm', 'zig/foo/bar/z%20z2.c',
161 'rm', 'zig/foo/bar/z%2520z.c',
162 'cp', '5', 'zig/zag/bar/x.c', 'zig/foo/bar/z%20z1.c')
165 run_svnmucc(['R /zig/foo/bar (from /zig/z.c:8)',
168 'cp', '8', 'zig/z.c', 'zig/foo/bar')
171 run_svnmucc(['R /zig/foo/bar (from /zig/foo/bar:8)',
172 'D /zig/foo/bar/z z1.c',
175 'cp', '8', 'zig/foo/bar', 'zig/foo/bar',
176 'rm', 'zig/foo/bar/z%20z1.c')
179 run_svnmucc(['R /zig/foo (from /zig/foo/bar:10)',
182 'cp', 'head', 'zig/foo/bar', 'zig/foo')
185 run_svnmucc(['D /zig',
186 'A /foo (from /foo:3)',
187 'A /foo/foo (from /foo:3)',
188 'A /foo/foo/foo (from /foo:3)',
190 'R /foo/foo/foo/bar (from /foo:3)',
193 'cp', '3', 'foo', 'foo',
194 'cp', '3', 'foo', 'foo/foo',
195 'cp', '3', 'foo', 'foo/foo/foo',
197 'rm', 'foo/foo/foo/bar',
198 'cp', '3', 'foo', 'foo/foo/foo/bar')
201 run_svnmucc(['A /boozle (from /foo:3)',
205 'cp', '3', 'foo', 'boozle',
206 'mkdir', 'boozle/buz',
207 'mkdir', 'boozle/buz/nuz')
210 run_svnmucc(['A /boozle/buz/svnmucc-test.py',
211 'A /boozle/guz (from /boozle/buz:13)',
212 'A /boozle/guz/svnmucc-test.py',
214 'put', '/dev/null', 'boozle/buz/svnmucc-test.py',
215 'cp', '13', 'boozle/buz', 'boozle/guz',
216 'put', '/dev/null', 'boozle/guz/svnmucc-test.py')
219 run_svnmucc(['M /boozle/buz/svnmucc-test.py',
220 'R /boozle/guz/svnmucc-test.py',
222 'put', sys
.argv
[0], 'boozle/buz/svnmucc-test.py',
223 'rm', 'boozle/guz/svnmucc-test.py',
224 'put', sys
.argv
[0], 'boozle/guz/svnmucc-test.py')
227 run_svnmucc(['R /foo/bar (from /foo/foo:15)'], #---------
229 'cp', '15', 'foo/foo', 'foo/bar',
230 'propset', 'testprop', 'true', 'foo/bar')
233 run_svnmucc(['M /foo/bar'], #---------
234 'propdel', 'testprop', 'foo/bar')
236 if __name__
== "__main__":
238 # remove any previously existing repository, then create a new one
239 if os
.path
.exists(repos_path
):
240 shutil
.rmtree(repos_path
)
241 exit_code
, outlines
, errlines
= \
242 svntest
.main
.run_svnadmin('create', '--fs-type',
245 raise svntest
.main
.SVNRepositoryCreateFailure(repos_path
)
246 fp
= open(os
.path
.join(repos_path
, 'conf', 'svnserve.conf'), 'w')
247 fp
.write('[general]\nauth-access = write\npassword-db = passwd\n')
249 fp
= open(os
.path
.join(repos_path
, 'conf', 'passwd'), 'w')
250 fp
.write('[users]\nsvnmuccuser = svnmuccpass\n')
253 except SystemExit, e
:
255 except svntest
.main
.SVNCommitFailure
, e
:
256 die("Error committing via svnmucc: %s" % (str(e
)))
257 except svntest
.main
.SVNLineUnequal
, e
:
258 die("Unexpected svnmucc output line: %s" % (str(e
)))
259 except svntest
.main
.SVNRepositoryCreateFailure
, e
:
260 die("Error creating test repository: %s" % (str(e
)))
261 except svntest
.Failure
, e
:
262 die("Test failed: %s" % (str(e
)))
264 die("Something bad happened: %s" % (str(e
)))
266 # cleanup the repository on a successful run
268 if os
.path
.exists(repos_path
):
269 shutil
.rmtree(repos_path
)