Fix compiler warning due to missing function prototype.
[svn.git] / subversion / tests / cmdline / svndumpfilter_tests.py
blob389335545a07f761ed907503dcf4e5013d7bec8a
1 #!/usr/bin/env python
3 # svndumpfilter_tests.py: testing the 'svndumpfilter' tool.
5 # Subversion is a tool for revision control.
6 # See http://subversion.tigris.org for more information.
8 # ====================================================================
9 # Copyright (c) 2007 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 ######################################################################
19 # General modules
20 import os
21 import sys
23 # Our testing module
24 import svntest
25 from svntest.verify import SVNExpectedStdout, SVNExpectedStderr
27 # Get some helper routines from svnadmin_tests
28 from svnadmin_tests import load_and_verify_dumpstream, test_create
30 # (abbreviation)
31 Skip = svntest.testcase.Skip
32 SkipUnless = svntest.testcase.SkipUnless
33 XFail = svntest.testcase.XFail
34 Item = svntest.wc.StateItem
37 ######################################################################
38 # Helper routines
41 def filter_and_return_output(dump, *varargs):
42 """Filter the array of lines passed in 'dump' and return the output"""
44 if type(dump) is type(""):
45 dump = [ dump ]
47 ## TODO: Should we need to handle errput and exit_code?
48 exit_code, output, errput = svntest.main.run_command_stdin(
49 svntest.main.svndumpfilter_binary, None, 1, dump, *varargs)
51 return output
54 ######################################################################
55 # Tests
58 def reflect_dropped_renumbered_revs(sbox):
59 "reflect dropped renumbered revs in svn:mergeinfo"
61 ## See http://subversion.tigris.org/issues/show_bug.cgi?id=2982. ##
63 # Test svndumpfilter with include option
64 test_create(sbox)
65 dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
66 'svndumpfilter_tests_data',
67 'with_merges.dump')
68 dumpfile = svntest.main.file_read(dumpfile_location)
70 filtered_out = filter_and_return_output(dumpfile, "include",
71 "trunk", "branch1",
72 "--skip-missing-merge-sources",
73 "--drop-empty-revs",
74 "--renumber-revs", "--quiet")
75 load_and_verify_dumpstream(sbox, [], [], None, filtered_out)
77 # Verify the svn:mergeinfo properties
78 svntest.actions.run_and_verify_svn(None,
79 [sbox.repo_url+"/trunk - /branch1:4-5\n"],
80 [], 'propget', 'svn:mergeinfo', '-R',
81 sbox.repo_url + '/trunk')
82 svntest.actions.run_and_verify_svn(None,
83 [sbox.repo_url+"/branch1 - /trunk:1-2\n"],
84 [], 'propget', 'svn:mergeinfo', '-R',
85 sbox.repo_url + '/branch1')
87 # Test svndumpfilter with exclude option
88 test_create(sbox)
89 filtered_out = filter_and_return_output(dumpfile, "exclude",
90 "branch1",
91 "--skip-missing-merge-sources",
92 "--drop-empty-revs",
93 "--renumber-revs", "--quiet")
94 load_and_verify_dumpstream(sbox, [], [], None, filtered_out)
96 # Verify the svn:mergeinfo properties
97 svntest.actions.run_and_verify_svn(None,
98 [sbox.repo_url+"/trunk - \n"],
99 [], 'propget', 'svn:mergeinfo', '-R',
100 sbox.repo_url + '/trunk')
101 svntest.actions.run_and_verify_svn(None,
102 [sbox.repo_url+"/branch2 - /trunk:1-2\n"],
103 [], 'propget', 'svn:mergeinfo', '-R',
104 sbox.repo_url + '/branch2')
106 def svndumpfilter_loses_mergeinfo(sbox):
107 "svndumpfilter loses mergeinfo"
108 #svndumpfilter loses mergeinfo if invoked without --renumber-revs
110 ## See http://subversion.tigris.org/issues/show_bug.cgi?id=3181. ##
112 test_create(sbox)
113 dumpfile_location = os.path.join(os.path.dirname(sys.argv[0]),
114 'svndumpfilter_tests_data',
115 'with_merges.dump')
116 dumpfile = svntest.main.file_read(dumpfile_location)
118 filtered_out = filter_and_return_output(dumpfile, "include",
119 "trunk", "branch1", "--quiet")
120 load_and_verify_dumpstream(sbox, [], [], None, filtered_out)
122 # Verify the svn:mergeinfo properties
123 svntest.actions.run_and_verify_svn(None,
124 [sbox.repo_url+"/trunk - /branch1:4-8\n"],
125 [], 'propget', 'svn:mergeinfo', '-R',
126 sbox.repo_url + '/trunk')
127 svntest.actions.run_and_verify_svn(None,
128 [sbox.repo_url+"/branch1 - /trunk:1-2\n"],
129 [], 'propget', 'svn:mergeinfo', '-R',
130 sbox.repo_url + '/branch1')
133 ########################################################################
134 # Run the tests
137 # list all tests here, starting with None:
138 test_list = [ None,
139 reflect_dropped_renumbered_revs,
140 svndumpfilter_loses_mergeinfo,
143 if __name__ == '__main__':
144 svntest.main.run_tests(test_list)
145 # NOTREACHED
148 ### End of file.