[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svnrdump: New unittest

From: Ramkumar Ramachandra <artagnon_at_gmail.com>
Date: Sat, 24 Jul 2010 13:08:33 +0530

Hi,

After Bert pointed out some problems with my patch on IRC, I've
updated it. Here's the new patch including the original basic_svnrdump
test as well.

Thanks.

Index: subversion/tests/cmdline/svnrdump_tests.py
===================================================================
--- subversion/tests/cmdline/svnrdump_tests.py (revision 978817)
+++ subversion/tests/cmdline/svnrdump_tests.py (working copy)
@@ -41,6 +41,54 @@ XFail = svntest.testcase.XFail
 Item = svntest.wc.StateItem
 Wimp = svntest.testcase.Wimp
 
+######################################################################
+# Helper routines
+
+def build_repos(sbox):
+ """Build an empty sandbox repository"""
+
+ # Cleanup after the last run by removing any left-over repository.
+ svntest.main.safe_rmtree(sbox.repo_dir)
+
+ # Create an empty repository.
+ svntest.main.create_repos(sbox.repo_dir)
+
+def run_test(sbox, dumpfile_name):
+ """Load a dumpfile using svnadmin load, dump it with svnrdump and
+ check that the same dumpfile is produced"""
+
+ # Create an empty sanbox repository
+ build_repos(sbox)
+
+ # This directory contains all the dump files
+ svnsync_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
+ 'svnrdump_tests_data')
+
+ # Load the specified dump file into the repository
+ svnadmin_dumpfile = open(os.path.join(svnsync_tests_dir,
+ dumpfile_name),
+ 'rb').readlines()
+
+ # Create the revprop-change hook for this test
+ svntest.actions.enable_revprop_changes(sbox.repo_dir)
+
+ # Load dumpfile_contents into the sbox repository
+ svntest.actions.run_and_verify_load(sbox.repo_dir, svnadmin_dumpfile)
+
+ # Create a dump file using svnrdump
+ r, svnrdump_dumpfile, err = svntest.main.run_svnrdump(sbox.repo_url)
+
+ # Check error code
+ if (r != 0):
+ raise svntest.Failure('Result code not 0')
+
+ # Compare the output
+ svntest.verify.compare_and_display_lines(
+ "Dump files", "DUMP", svnadmin_dumpfile, svnrdump_dumpfile)
+
+######################################################################
+# Tests
+
 def basic_svnrdump(sbox):
   "dump the standard sbox repos"
   sbox.build(read_only = True, create_wc = False)
@@ -53,6 +101,10 @@ def basic_svnrdump(sbox):
   if not out[0].startswith('SVN-fs-dump-format-version:'):
     raise svntest.Failure('No valid output')
 
+def asf_0(sbox):
+ "dump the zeroth revision of the ASF repository"
+ run_test(sbox, dumpfile_name = "asf-0.dump")
+
 ########################################################################
 # Run the tests
 
@@ -60,6 +112,7 @@ def basic_svnrdump(sbox):
 # list all tests here, starting with None:
 test_list = [ None,
               basic_svnrdump,
+ asf_0,
              ]
 
 if __name__ == '__main__':
Index: subversion/tests/cmdline/svnrdump_tests_data/asf-0.dump
===================================================================
--- subversion/tests/cmdline/svnrdump_tests_data/asf-0.dump (revision 0)
+++ subversion/tests/cmdline/svnrdump_tests_data/asf-0.dump (working copy)
@@ -0,0 +1,30 @@
+SVN-fs-dump-format-version: 3
+
+UUID: 95f5730d-843b-4fe3-8879-f46da52f2123
+
+Revision-number: 0
+Prop-content-length: 258
+Content-length: 258
+
+K 8
+svn:date
+V 27
+2003-01-08T10:33:40.549533Z
+K 26
+svn:sync-currently-copying
+V 2
+15
+K 17
+svn:sync-from-url
+V 31
+http://svn.apache.org/repos/asf
+K 18
+svn:sync-from-uuid
+V 36
+13f79535-47bb-0310-9956-ffa450edef68
+K 24
+svn:sync-last-merged-rev
+V 2
+14
+PROPS-END
+
Received on 2010-07-24 09:40:51 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.