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

[PATCH] svnrdump: Unittest for revision 0

From: Ramkumar Ramachandra <artagnon_at_gmail.com>
Date: Sat, 24 Jul 2010 14:59:07 +0530

Hi,

Thanks to Stefan and Daniel, I now have a neat patch with a nice log
message.

[[[
svnrdump: Add a regression test which verifies that revision 0 of a
repository is dumped correctly. Revision 0 only has revision
properties, so it's somewhat special.

* subversion/tests/cmdline/svnrdump_tests_data: A new directory to
  keep test data for svnrdump.
* subversion/tests/cmdline/svnrdump_tests_data/revision0.dump: A dump
  of revision zero of the ASF repository as of late July 2010. Used as
  test data in the revision0 test.
* subversion/tests/cmdline/svnrdump_tests.py:
  (build_repos, run_test): The new helper functions.
  (revision0): The new test.
  (test_list): Run the new test.
]]]

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 revision0(sbox):
+ "dump revision zero"
+ run_test(sbox, dumpfile_name = "revision0.dump")
+
 ########################################################################
 # Run the tests
 
@@ -60,6 +112,7 @@ def basic_svnrdump(sbox):
 # list all tests here, starting with None:
 test_list = [ None,
               basic_svnrdump,
+ revision0,
              ]
 
 if __name__ == '__main__':
Index: subversion/tests/cmdline/svnrdump_tests_data/revision0.dump
===================================================================
--- subversion/tests/cmdline/svnrdump_tests_data/revision0.dump (revision 0)
+++ subversion/tests/cmdline/svnrdump_tests_data/revision0.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 11:31:38 CEST

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