Follow-up to r29036: Now that the "mergeinfo" transaction file is no
[svn.git] / contrib / client-side / svnmucc / svnmucc-test.py
blob9c407f1e8bb8e45872d476208bf53222717e2baa
1 #!/usr/bin/env python
3 # Usage: svnmucc-test.py [build-dir-top [base-url]]
5 import sys
6 import os
7 import re
8 import shutil
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))
15 import svntest
17 # calculate the top of the build tree
18 if len(sys.argv) > 1:
19 build_top = os.path.abspath(sys.argv[1])
20 else:
21 build_top = os.path.abspath('%s/../../../' % (this_dir))
23 # where lives svnmucc?
24 svnmucc_binary = \
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?
36 repos_path = \
37 os.path.abspath(('%s/contrib/client-side/svnmucc/svnmucc-test-repos'
38 % (build_top)))
40 if (len(sys.argv) > 2):
41 repos_url = sys.argv[2] + '/svnmucc-test-repos'
42 else:
43 repos_url = 'file://' + repos_path
45 def die(msg):
46 """Write MSG (formatted as a failure) to stderr, and exit with a
47 non-zero errorcode."""
49 sys.stderr.write("FAIL: " + msg + "\n")
50 sys.exit(1)
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."""
61 # First, run svnmucc.
62 outlines, errlines = svntest.main.run_command(svnmucc_binary, 1, 0,
63 '-U', repos_url,
64 '-u', 'svnmuccuser',
65 '-p', 'svnmuccpass',
66 '--config-dir', 'dummy',
67 *varargs)
68 if errlines:
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'
74 changed_paths = []
75 outlines, errlines = svntest.main.run_svn(None, 'log', '-vqrHEAD', repos_url)
76 if errlines:
77 raise svntest.Failure("Unable to verify commit with 'svn log': %s"
78 % (str(errlines)))
79 for line in outlines:
80 match = _log_re.match(line)
81 if match:
82 changed_paths.append(match.group(1).rstrip('\n\r'))
84 expected_path_changes.sort()
85 changed_paths.sort()
86 if changed_paths != expected_path_changes:
87 raise svntest.Failure("Logged path changes differ from expectations\n"
88 " expected: %s\n"
89 " actual: %s" % (str(expected_path_changes),
90 str(changed_paths)))
93 def main():
94 """Test svnmucc."""
96 # revision 1
97 run_svnmucc(['A /foo'
98 ], # ---------
99 'mkdir', 'foo')
101 # revision 2
102 run_svnmucc(['A /z.c',
103 ], # ---------
104 'put', '/dev/null', 'z.c')
106 # revision 3
107 run_svnmucc(['A /foo/z.c (from /z.c:2)',
108 'A /foo/bar (from /foo:2)',
109 ], # ---------
110 'cp', '2', 'z.c', 'foo/z.c',
111 'cp', '2', 'foo', 'foo/bar')
113 # revision 4
114 run_svnmucc(['A /zig (from /foo:3)',
115 'D /zig/bar',
116 'D /foo',
117 'A /zig/zag (from /foo:3)',
118 ], # ---------
119 'cp', '3', 'foo', 'zig',
120 'rm', 'zig/bar',
121 'mv', 'foo', 'zig/zag')
123 # revision 5
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)',
127 ], # ---------
128 'mv', 'z.c', 'zig/zag/bar/y.c',
129 'cp', '2', 'z.c', 'zig/zag/bar/x.c')
131 # revision 6
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)',
135 ], # ---------
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')
139 # revision 7
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)',
144 ], #---------
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')
149 # revision 8
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)',
155 ], #---------
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')
162 # revision 9
163 run_svnmucc(['R /zig/foo/bar (from /zig/z.c:8)',
164 ], #---------
165 'rm', 'zig/foo/bar',
166 'cp', '8', 'zig/z.c', 'zig/foo/bar')
168 # revision 10
169 run_svnmucc(['R /zig/foo/bar (from /zig/foo/bar:8)',
170 'D /zig/foo/bar/z z1.c',
171 ], #---------
172 'rm', 'zig/foo/bar',
173 'cp', '8', 'zig/foo/bar', 'zig/foo/bar',
174 'rm', 'zig/foo/bar/z%20z1.c')
176 # revision 11
177 run_svnmucc(['R /zig/foo (from /zig/foo/bar:10)',
178 ], #---------
179 'rm', 'zig/foo',
180 'cp', 'head', 'zig/foo/bar', 'zig/foo')
182 # revision 12
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)',
187 'D /foo/foo/bar',
188 'R /foo/foo/foo/bar (from /foo:3)',
189 ], #---------
190 'rm', 'zig',
191 'cp', '3', 'foo', 'foo',
192 'cp', '3', 'foo', 'foo/foo',
193 'cp', '3', 'foo', 'foo/foo/foo',
194 'rm', 'foo/foo/bar',
195 'rm', 'foo/foo/foo/bar',
196 'cp', '3', 'foo', 'foo/foo/foo/bar')
198 # revision 13
199 run_svnmucc(['A /boozle (from /foo:3)',
200 'A /boozle/buz',
201 'A /boozle/buz/nuz',
202 ], #---------
203 'cp', '3', 'foo', 'boozle',
204 'mkdir', 'boozle/buz',
205 'mkdir', 'boozle/buz/nuz')
207 # revision 14
208 run_svnmucc(['A /boozle/buz/svnmucc-test.py',
209 'A /boozle/guz (from /boozle/buz:13)',
210 'A /boozle/guz/svnmucc-test.py',
211 ], #---------
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')
216 # revision 15
217 run_svnmucc(['M /boozle/buz/svnmucc-test.py',
218 'R /boozle/guz/svnmucc-test.py',
219 ], #---------
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')
224 # revision 16
225 run_svnmucc(['R /foo/bar (from /foo/foo:15)'], #---------
226 'rm', 'foo/bar',
227 'cp', '15', 'foo/foo', 'foo/bar',
228 'propset', 'testprop', 'true', 'foo/bar')
230 # revision 17
231 run_svnmucc(['M /foo/bar'], #---------
232 'propdel', 'testprop', 'foo/bar')
234 if __name__ == "__main__":
235 try:
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',
240 'fsfs', repos_path)
241 if errlines:
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')
245 fp.close()
246 fp = open(os.path.join(repos_path, 'conf', 'passwd'), 'w')
247 fp.write('[users]\nsvnmuccuser = svnmuccpass\n')
248 fp.close()
249 main()
250 except SystemExit, e:
251 raise
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)))
260 except Exception, e:
261 die("Something bad happened: %s" % (str(e)))
263 # cleanup the repository on a successful run
264 try:
265 if os.path.exists(repos_path):
266 shutil.rmtree(repos_path)
267 except:
268 pass
269 print "SUCCESS!"