Author: julianfoad
Date: Wed Feb  4 12:57:06 2015
New Revision: 1657182

URL: http://svn.apache.org/r1657182
Log:
Expand the tests for 'svnsync' stripping r0 from mergeinfo, following the
embarrassing bug introduced in r1646250 and fixed in r1656893.

The approach taken here also moves the test case data from the dumpfiles to
the Python test code which arguably makes it easier to read.

* subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
  Reduce this to a stub.

* 
subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump
  Delete.

* subversion/tests/cmdline/svnsync_tests.py
  (mergeinfo_contains_r0): Create the input and expected dumpfile contents
    by constructing node records containing mergeinfo and appending them to
    the dumpfile stub. Add test cases where no change is expected, and more
    thorough test cases where a change is expected.

Removed:
    
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.expected.dump
Modified:
    subversion/trunk/subversion/tests/cmdline/svnsync_tests.py
    
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump

Modified: subversion/trunk/subversion/tests/cmdline/svnsync_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnsync_tests.py?rev=1657182&r1=1657181&r2=1657182&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnsync_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnsync_tests.py Wed Feb  4 
12:57:06 2015
@@ -578,9 +578,72 @@ def fd_leak_sync_from_serf_to_local(sbox
 @Issue(4476)
 def mergeinfo_contains_r0(sbox):
   "mergeinfo contains r0"
-  run_test(sbox, "mergeinfo-contains-r0.dump",
-           exp_dump_file_name="mergeinfo-contains-r0.expected.dump",
-           bypass_prop_validation=True)
+
+  def make_node_record(node_name, mi):
+    """Return a dumpfile node-record for adding a (directory) node named
+       NODE_NAME with mergeinfo MI. Return it as a list of newline-terminated
+       lines.
+    """
+    headers_tmpl = """\
+Node-path: %s
+Node-kind: dir
+Node-action: add
+Prop-content-length: %d
+Content-length: %d
+"""
+    content_tmpl = """\
+K 13
+svn:mergeinfo
+V %d
+%s
+PROPS-END
+"""
+    content = content_tmpl % (len(mi), mi)
+    headers = headers_tmpl % (node_name, len(content), len(content))
+    record = headers + '\n' + content + '\n\n'
+    return record.splitlines(True)
+
+  # The test case mergeinfo (before, after) syncing, separated here with
+  # spaces instead of newlines
+  test_mi = [
+    ("",            ""),  # unchanged
+    ("/a:1",        "/a:1"),
+    ("/a:1 /b:1*,2","/a:1 /b:1*,2"),
+    ("/:0:1",       "/:0:1"),  # unchanged; colon-zero in filename
+    ("/a:0",        ""),  # dropped entirely
+    ("/a:0*",       ""),
+    ("/a:0 /b:0*",  ""),
+    ("/a:1 /b:0",   "/a:1"),  # one kept, one dropped
+    ("/a:0 /b:1",   "/b:1"),
+    ("/a:0,1 /b:1", "/a:1 /b:1"),  # one kept, one changed
+    ("/a:1 /b:0,1", "/a:1 /b:1"),
+    ("/a:0,1 /b:0*,1 /c:0,2 /d:0-1 /e:0-1,3 /f:0-2 /g:0-3",
+     "/a:1 /b:1 /c:2 /d:1 /e:1,3 /f:1-2 /g:1-3"),  # all changed
+    ("/a:0:0-1",    "/a:0:1"),  # changed; colon-zero in filename
+    ]
+
+  # Get the constant prefix for each dumpfile
+  dump_file_name = "mergeinfo-contains-r0.dump"
+  svnsync_tests_dir = os.path.join(os.path.dirname(sys.argv[0]),
+                                   'svnsync_tests_data')
+  dump_in = open(os.path.join(svnsync_tests_dir, dump_file_name),
+                 'rb').readlines()
+  dump_out = list(dump_in)  # duplicate the list
+
+  # Add dumpfile node records containing the test mergeinfo
+  for n, mi in enumerate(test_mi):
+    node_name = "D" + str(n)
+
+    mi_in = mi[0].replace(' ', '\n')
+    mi_out = mi[1].replace(' ', '\n')
+    dump_in.extend(make_node_record(node_name, mi_in))
+    dump_out.extend(make_node_record(node_name, mi_out))
+
+  # Run the sync
+  dest_sbox = setup_and_sync(sbox, dump_in, bypass_prop_validation=True)
+
+  # Compare the dump produced by the mirror repository with expected
+  verify_mirror(dest_sbox, dump_out)
 
 
 ########################################################################

Modified: 
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump?rev=1657182&r1=1657181&r2=1657182&view=diff
==============================================================================
--- 
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
 (original)
+++ 
subversion/trunk/subversion/tests/cmdline/svnsync_tests_data/mergeinfo-contains-r0.dump
 Wed Feb  4 12:57:06 2015
@@ -13,8 +13,8 @@ V 27
 PROPS-END
 
 Revision-number: 1
-Prop-content-length: 101
-Content-length: 101
+Prop-content-length: 84
+Content-length: 84
 
 K 10
 svn:author
@@ -24,113 +24,5 @@ K 8
 svn:date
 V 27
 2000-01-01T00:00:00.000000Z
-K 7
-svn:log
-V 0
-
-PROPS-END
-
-Node-path: 
-Node-kind: dir
-Node-action: change
-Prop-content-length: 22
-Content-length: 22
-
-K 1
-p
-V 1
-v
-PROPS-END
-
-
-Revision-number: 2
-Prop-content-length: 113
-Content-length: 113
-
-K 10
-svn:author
-V 7
-jrandom
-K 8
-svn:date
-V 27
-2005-11-07T23:37:17.705159Z
-K 7
-svn:log
-V 11
-add foo.txt
-PROPS-END
-
-Node-path: foo.txt
-Node-kind: file
-Node-action: add
-Text-content-md5: d41d8cd98f00b204e9800998ecf8427e
-Text-content-sha1: da39a3ee5e6b4b0d3255bfef95601890afd80709
-Prop-content-length: 86
-Text-content-length: 0
-Content-length: 86
-
-K 13
-svn:mergeinfo
-V 51
-/a:0,1
-/b:0*,1
-/c:0,2
-/d:0-1
-/e:0-1,3
-/f:0-2
-/g:0-3
 PROPS-END
 
-
-Revision-number: 3
-Prop-content-length: 97
-Content-length: 97
-
-K 10
-svn:author
-V 2
-pm
-K 8
-svn:date
-V 27
-2015-02-03T18:38:47.017031Z
-K 7
-svn:log
-V 1
-m
-PROPS-END
-
-Node-path: zag
-Node-kind: dir
-Node-action: add
-Prop-content-length: 76
-Content-length: 76
-
-K 13
-svn:mergeinfo
-V 45
-/a:1,4
-/b:0,4
-/c:2-3
-/d:0-3
-/e:2,5-6
-/f:0,5-6
-PROPS-END
-
-
-Node-path: zig
-Node-kind: dir
-Node-action: add
-Prop-content-length: 55
-Content-length: 55
-
-K 13
-svn:mergeinfo
-V 20
-/a:1
-/b:2-3
-/c:4,7-8
-PROPS-END
-
-


Reply via email to