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

svnrdump: New unittest

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

Hi,

Here's a patch for a simple unittest I wrote out- the zeroth revision
of the ASF repository passes with no issues. Since this is outside my
area, I need a +1 to commit this.

Thanks!

Index: subversion/tests/cmdline/svnrdump_tests.py
===================================================================
--- subversion/tests/cmdline/svnrdump_tests.py (revision 967194)
+++ subversion/tests/cmdline/svnrdump_tests.py (working copy)
@@ -41,25 +41,75 @@ XFail = svntest.testcase.XFail
 Item = svntest.wc.StateItem
 Wimp = svntest.testcase.Wimp
 
-def basic_svnrdump(sbox):
- "dump the standard sbox repos"
- sbox.build(read_only = True, create_wc = False)
+######################################################################
+# 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 = None, dumpfile_url = None):
+ """Load either a local or remote dumpfile using svnadmin load, dump
+ it with svnrdump and check that the same dumpfile is produced"""
+
+ # Create the empty master repository.
+ build_repos(sbox)
+
+ # Sanity check
   r, out, err = svntest.main.run_svnrdump(sbox.repo_url)
 
   if (r != 0):
     raise svntest.Failure('Result code not 0')
 
   if not out[0].startswith('SVN-fs-dump-format-version:'):
- raise svntest.Failure('No valid output')
+ raise svntest.Failure('Sanity check failed')
 
+ # 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 master repository.
+ if (dumpfile_name):
+ svnadmin_dumpfile = open(os.path.join(svnsync_tests_dir,
+ dumpfile_name),
+ 'rb').readlines()
+ else:
+ raise svntest.Failure('Unsupported test')
+
+ # 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)
+ if (r != 0):
+ raise svntest.Failure('Result code not 0')
+
+ svntest.verify.compare_and_display_lines(
+ "Dump files", "DUMP", svnadmin_dumpfile, svnrdump_dumpfile)
+
+######################################################################
+# Tests
+
+def asf_0(sbox):
+ "dump the zeroth revision of the ASF repository"
+
+ build_repos(sbox)
+ run_test(sbox, dumpfile_name = "asf-0.dump")
+
 ########################################################################
 # Run the tests
 
 
 # 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 00:06:10 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.