You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/03/01 13:22:19 UTC
svn commit: r1295534 [3/3] - in /subversion/branches/1.7.x-issue4087: ./
build/generator/
subversion/bindings/swig/python/tests/trac/versioncontrol/tests/
subversion/include/private/ subversion/libsvn_client/
subversion/libsvn_fs_fs/ subversion/libsvn_...
Modified: subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/actions.py?rev=1295534&r1=1295533&r2=1295534&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/actions.py Thu Mar 1 12:22:17 2012
@@ -556,7 +556,8 @@ class LogEntry:
self.revprops = revprops
def assert_changed_paths(self, changed_paths):
- """Not implemented, so just raises svntest.Failure.
+ """Assert that changed_paths is the same as this entry's changed_paths
+ Raises svntest.Failure if not.
"""
raise Failure('NOT IMPLEMENTED')
@@ -1079,13 +1080,21 @@ def run_and_verify_merge(dir, rev1, rev2
if dry_run and merge_diff_out != out_dry:
# Due to the way ra_serf works, it's possible that the dry-run and
# real merge operations did the same thing, but the output came in
- # a different order. Let's see if maybe that's the case.
+ # a different order. Let's see if maybe that's the case by comparing
+ # the outputs as unordered sets rather than as lists.
+ #
+ # This now happens for other RA layers with modern APR because the
+ # hash order now varies.
#
- # NOTE: Would be nice to limit this dance to serf tests only, but...
- out_copy = merge_diff_out[:]
- out_dry_copy = out_dry[:]
- out_copy.sort()
- out_dry_copy.sort()
+ # The different orders of the real and dry-run merges may cause
+ # the "Merging rX through rY into" lines to be duplicated a
+ # different number of times in the two outputs. The list-set
+ # conversion removes duplicates so these differences are ignored.
+ # It also removes "U some/path" duplicate lines. Perhaps we
+ # should avoid that?
+ out_copy = set(merge_diff_out[:])
+ out_dry_copy = set(out_dry[:])
+
if out_copy != out_dry_copy:
print("=============================================================")
print("Merge outputs differ")
@@ -1198,16 +1207,11 @@ def run_and_verify_patch(dir, patch_path
raise verify.SVNUnexpectedStderr
if dry_run and out != out_dry:
- print("=============================================================")
- print("Outputs differ")
- print("'svn patch --dry-run' output:")
- for x in out_dry:
- sys.stdout.write(x)
- print("'svn patch' output:")
- for x in out:
- sys.stdout.write(x)
- print("=============================================================")
- raise main.SVNUnmatchedError
+ # APR hash order means the output order can vary, assume everything is OK
+ # if only the order changes.
+ out_dry_expected = svntest.verify.UnorderedOutput(out)
+ verify.compare_and_display_lines('dry-run patch output not as expected',
+ '', out_dry_expected, out_dry)
def missing_skip(a, b):
print("=============================================================")
@@ -1230,7 +1234,8 @@ def run_and_verify_patch(dir, patch_path
# when the expected output is a list, we want a line-by-line
# comparison to happen instead of a tree comparison
- if isinstance(output_tree, list):
+ if (isinstance(output_tree, list)
+ or isinstance(output_tree, verify.UnorderedOutput)):
verify.verify_outputs(None, out, err, output_tree, error_re_string)
output_tree = None
@@ -1503,6 +1508,56 @@ def run_and_verify_unquiet_status(wc_dir
tree.dump_tree_script(actual, wc_dir_name + os.sep)
raise
+def run_and_verify_status_xml(expected_entries = [],
+ *args):
+ """ Run 'status --xml' with arguments *ARGS. If successful the output
+ is parsed into an XML document and will be verified by comparing against
+ EXPECTED_ENTRIES.
+ """
+
+ exit_code, output, errput = run_and_verify_svn(None, None, [],
+ 'status', '--xml', *args)
+
+ if len(errput) > 0:
+ raise Failure
+
+ doc = parseString(''.join(output))
+ entries = doc.getElementsByTagName('entry')
+
+ def getText(nodelist):
+ rc = []
+ for node in nodelist:
+ if node.nodeType == node.TEXT_NODE:
+ rc.append(node.data)
+ return ''.join(rc)
+
+ actual_entries = {}
+ for entry in entries:
+ wcstatus = entry.getElementsByTagName('wc-status')[0]
+ commit = entry.getElementsByTagName('commit')
+ author = entry.getElementsByTagName('author')
+ rstatus = entry.getElementsByTagName('repos-status')
+
+ actual_entry = {'wcprops' : wcstatus.getAttribute('props'),
+ 'wcitem' : wcstatus.getAttribute('item'),
+ }
+ if wcstatus.hasAttribute('revision'):
+ actual_entry['wcrev'] = wcstatus.getAttribute('revision')
+ if (commit):
+ actual_entry['crev'] = commit[0].getAttribute('revision')
+ if (author):
+ actual_entry['author'] = getText(author[0].childNodes)
+ if (rstatus):
+ actual_entry['rprops'] = rstatus[0].getAttribute('props')
+ actual_entry['ritem'] = rstatus[0].getAttribute('item')
+
+ actual_entries[entry.getAttribute('path')] = actual_entry
+
+ if expected_entries != actual_entries:
+ raise Failure('\n' + '\n'.join(difflib.ndiff(
+ pprint.pformat(expected_entries).splitlines(),
+ pprint.pformat(actual_entries).splitlines())))
+
def run_and_verify_diff_summarize_xml(error_re_string = [],
expected_prefix = None,
expected_paths = [],
Modified: subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/verify.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/verify.py?rev=1295534&r1=1295533&r2=1295534&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/verify.py (original)
+++ subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/svntest/verify.py Thu Mar 1 12:22:17 2012
@@ -25,7 +25,8 @@
######################################################################
import re, sys
-from difflib import unified_diff
+from difflib import unified_diff, ndiff
+import pprint
import svntest
@@ -68,6 +69,10 @@ class SVNIncorrectDatatype(SVNUnexpected
run_and_verify_* API"""
pass
+class SVNDumpParseError(svntest.Failure):
+ """Exception raised if parsing a dump file fails"""
+ pass
+
######################################################################
# Comparison of expected vs. actual output
@@ -397,3 +402,193 @@ def verify_exit_code(message, actual, ex
display_lines(message, "Exit Code",
str(expected) + '\n', str(actual) + '\n')
raise raisable
+
+# A simple dump file parser. While sufficient for the current
+# testsuite it doesn't cope with all valid dump files.
+class DumpParser:
+ def __init__(self, lines):
+ self.current = 0
+ self.lines = lines
+ self.parsed = {}
+
+ def parse_line(self, regex, required=True):
+ m = re.match(regex, self.lines[self.current])
+ if not m:
+ if required:
+ raise SVNDumpParseError("expected '%s' at line %d\n%s"
+ % (regex, self.current,
+ self.lines[self.current]))
+ else:
+ return None
+ self.current += 1
+ return m.group(1)
+
+ def parse_blank(self, required=True):
+ if self.lines[self.current] != '\n': # Works on Windows
+ if required:
+ raise SVNDumpParseError("expected blank at line %d\n%s"
+ % (self.current, self.lines[self.current]))
+ else:
+ return False
+ self.current += 1
+ return True
+
+ def parse_format(self):
+ return self.parse_line('SVN-fs-dump-format-version: ([0-9]+)$')
+
+ def parse_uuid(self):
+ return self.parse_line('UUID: ([0-9a-z-]+)$')
+
+ def parse_revision(self):
+ return self.parse_line('Revision-number: ([0-9]+)$')
+
+ def parse_prop_length(self, required=True):
+ return self.parse_line('Prop-content-length: ([0-9]+)$', required)
+
+ def parse_content_length(self, required=True):
+ return self.parse_line('Content-length: ([0-9]+)$', required)
+
+ def parse_path(self):
+ path = self.parse_line('Node-path: (.+)$', required=False)
+ if not path and self.lines[self.current] == 'Node-path: \n':
+ self.current += 1
+ path = ''
+ return path
+
+ def parse_kind(self):
+ return self.parse_line('Node-kind: (.+)$', required=False)
+
+ def parse_action(self):
+ return self.parse_line('Node-action: ([0-9a-z-]+)$')
+
+ def parse_copyfrom_rev(self):
+ return self.parse_line('Node-copyfrom-rev: ([0-9]+)$', required=False)
+
+ def parse_copyfrom_path(self):
+ path = self.parse_line('Node-copyfrom-path: (.+)$', required=False)
+ if not path and self.lines[self.current] == 'Node-copyfrom-path: \n':
+ self.current += 1
+ path = ''
+ return path
+
+ def parse_copy_md5(self):
+ return self.parse_line('Text-copy-source-md5: ([0-9a-z]+)$', required=False)
+
+ def parse_copy_sha1(self):
+ return self.parse_line('Text-copy-source-sha1: ([0-9a-z]+)$', required=False)
+
+ def parse_text_md5(self):
+ return self.parse_line('Text-content-md5: ([0-9a-z]+)$', required=False)
+
+ def parse_text_sha1(self):
+ return self.parse_line('Text-content-sha1: ([0-9a-z]+)$', required=False)
+
+ def parse_text_length(self):
+ return self.parse_line('Text-content-length: ([0-9]+)$', required=False)
+
+ # One day we may need to parse individual property name/values into a map
+ def get_props(self):
+ props = []
+ while not re.match('PROPS-END$', self.lines[self.current]):
+ props.append(self.lines[self.current])
+ self.current += 1
+ self.current += 1
+ return props
+
+ def get_content(self, length):
+ content = ''
+ while len(content) < length:
+ content += self.lines[self.current]
+ self.current += 1
+ if len(content) == length + 1:
+ content = content[:-1]
+ elif len(content) != length:
+ raise SVNDumpParseError("content length expected %d actual %d at line %d"
+ % (length, len(content), self.current))
+ return content
+
+ def parse_one_node(self):
+ node = {}
+ node['kind'] = self.parse_kind()
+ action = self.parse_action()
+ node['copyfrom_rev'] = self.parse_copyfrom_rev()
+ node['copyfrom_path'] = self.parse_copyfrom_path()
+ node['copy_md5'] = self.parse_copy_md5()
+ node['copy_sha1'] = self.parse_copy_sha1()
+ node['prop_length'] = self.parse_prop_length(required=False)
+ node['text_length'] = self.parse_text_length()
+ node['text_md5'] = self.parse_text_md5()
+ node['text_sha1'] = self.parse_text_sha1()
+ node['content_length'] = self.parse_content_length(required=False)
+ self.parse_blank()
+ if node['prop_length']:
+ node['props'] = self.get_props()
+ if node['text_length']:
+ node['content'] = self.get_content(int(node['text_length']))
+ # Hard to determine how may blanks is 'correct' (a delete that is
+ # followed by an add that is a replace and a copy has one fewer
+ # than expected but that can't be predicted until seeing the add)
+ # so allow arbitrary number
+ blanks = 0
+ while self.current < len(self.lines) and self.parse_blank(required=False):
+ blanks += 1
+ node['blanks'] = blanks
+ return action, node
+
+ def parse_all_nodes(self):
+ nodes = {}
+ while True:
+ if self.current >= len(self.lines):
+ break
+ path = self.parse_path()
+ if not path and not path is '':
+ break
+ if not nodes.get(path):
+ nodes[path] = {}
+ action, node = self.parse_one_node()
+ if nodes[path].get(action):
+ raise SVNDumpParseError("duplicate action '%s' for node '%s' at line %d"
+ % (action, path, self.current))
+ nodes[path][action] = node
+ return nodes
+
+ def parse_one_revision(self):
+ revision = {}
+ number = self.parse_revision()
+ revision['prop_length'] = self.parse_prop_length()
+ revision['content_length'] = self.parse_content_length()
+ self.parse_blank()
+ revision['props'] = self.get_props()
+ self.parse_blank()
+ revision['nodes'] = self.parse_all_nodes()
+ return number, revision
+
+ def parse_all_revisions(self):
+ while self.current < len(self.lines):
+ number, revision = self.parse_one_revision()
+ if self.parsed.get(number):
+ raise SVNDumpParseError("duplicate revision %d at line %d"
+ % (number, self.current))
+ self.parsed[number] = revision
+
+ def parse(self):
+ self.parsed['format'] = self.parse_format()
+ self.parse_blank()
+ self.parsed['uuid'] = self.parse_uuid()
+ self.parse_blank()
+ self.parse_all_revisions()
+ return self.parsed
+
+def compare_dump_files(message, label, expected, actual):
+ """Parse two dump files EXPECTED and ACTUAL, both of which are lists
+ of lines as returned by run_and_verify_dump, and check that the same
+ revisions, nodes, properties, etc. are present in both dumps.
+ """
+
+ parsed_expected = DumpParser(expected).parse()
+ parsed_actual = DumpParser(actual).parse()
+
+ if parsed_expected != parsed_actual:
+ raise svntest.Failure('\n' + '\n'.join(ndiff(
+ pprint.pformat(parsed_expected).splitlines(),
+ pprint.pformat(parsed_actual).splitlines())))
Modified: subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/switch_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/switch_tests.py?rev=1295534&r1=1295533&r2=1295534&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/switch_tests.py (original)
+++ subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/switch_tests.py Thu Mar 1 12:22:17 2012
@@ -1532,33 +1532,29 @@ def mergeinfo_switch_elision(sbox):
beta_path = os.path.join(wc_dir, "A", "B", "E", "beta")
# Make branches A/B_COPY_1 and A/B_COPY_2
- svntest.actions.run_and_verify_svn(
- None,
- ["A " + os.path.join(wc_dir, "A", "B_COPY_1", "lambda") + "\n",
+ expected_stdout = verify.UnorderedOutput([
+ "A " + os.path.join(wc_dir, "A", "B_COPY_1", "lambda") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_1", "E") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_1", "E", "alpha") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_1", "E", "beta") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_1", "F") + "\n",
"Checked out revision 1.\n",
- "A " + B_COPY_1_path + "\n"],
- [],
- 'copy',
- sbox.repo_url + "/A/B",
- B_COPY_1_path)
-
- svntest.actions.run_and_verify_svn(
- None,
- ["A " + os.path.join(wc_dir, "A", "B_COPY_2", "lambda") + "\n",
+ "A " + B_COPY_1_path + "\n",
+ ])
+ svntest.actions.run_and_verify_svn(None, expected_stdout, [], 'copy',
+ sbox.repo_url + "/A/B", B_COPY_1_path)
+
+ expected_stdout = verify.UnorderedOutput([
+ "A " + os.path.join(wc_dir, "A", "B_COPY_2", "lambda") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_2", "E") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_2", "E", "alpha") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_2", "E", "beta") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY_2", "F") + "\n",
"Checked out revision 1.\n",
- "A " + B_COPY_2_path + "\n"],
- [],
- 'copy',
- sbox.repo_url + "/A/B",
- B_COPY_2_path)
+ "A " + B_COPY_2_path + "\n",
+ ])
+ svntest.actions.run_and_verify_svn(None, expected_stdout, [], 'copy',
+ sbox.repo_url + "/A/B", B_COPY_2_path)
expected_output = svntest.wc.State(wc_dir, {
'A/B_COPY_1' : Item(verb='Adding'),
Modified: subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/update_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/update_tests.py?rev=1295534&r1=1295533&r2=1295534&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/update_tests.py (original)
+++ subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/update_tests.py Thu Mar 1 12:22:17 2012
@@ -1189,6 +1189,7 @@ def another_hudson_problem(sbox):
# Sigh, I can't get run_and_verify_update to work (but not because
# of issue 919 as far as I can tell)
+ expected_output = svntest.verify.UnorderedOutput(expected_output)
svntest.actions.run_and_verify_svn(None,
expected_output, [],
'up', G_path)
@@ -3142,19 +3143,17 @@ def mergeinfo_update_elision(sbox):
lambda_path = os.path.join(wc_dir, "A", "B", "lambda")
# Make a branch A/B_COPY
- svntest.actions.run_and_verify_svn(
- None,
- ["A " + os.path.join(wc_dir, "A", "B_COPY", "lambda") + "\n",
+ expected_stdout = verify.UnorderedOutput([
+ "A " + os.path.join(wc_dir, "A", "B_COPY", "lambda") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY", "E") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY", "E", "alpha") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY", "E", "beta") + "\n",
"A " + os.path.join(wc_dir, "A", "B_COPY", "F") + "\n",
"Checked out revision 1.\n",
- "A " + B_COPY_path + "\n"],
- [],
- 'copy',
- sbox.repo_url + "/A/B",
- B_COPY_path)
+ "A " + B_COPY_path + "\n",
+ ])
+ svntest.actions.run_and_verify_svn(None, expected_stdout, [], 'copy',
+ sbox.repo_url + "/A/B", B_COPY_path)
expected_output = wc.State(wc_dir, {'A/B_COPY' : Item(verb='Adding')})
Modified: subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/upgrade_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/upgrade_tests.py?rev=1295534&r1=1295533&r2=1295534&view=diff
==============================================================================
--- subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/upgrade_tests.py (original)
+++ subversion/branches/1.7.x-issue4087/subversion/tests/cmdline/upgrade_tests.py Thu Mar 1 12:22:17 2012
@@ -1079,7 +1079,7 @@ def upgrade_with_missing_subdir(sbox):
svntest.main.safe_rmtree(sbox.ospath('A/B'))
# Now upgrade the working copy and expect a missing subdir
- expected_output = [
+ expected_output = svntest.verify.UnorderedOutput([
"Upgraded '%s'\n" % sbox.wc_dir,
"Upgraded '%s'\n" % sbox.ospath('A'),
"Skipped '%s'\n" % sbox.ospath('A/B'),
@@ -1087,7 +1087,7 @@ def upgrade_with_missing_subdir(sbox):
"Upgraded '%s'\n" % sbox.ospath('A/D'),
"Upgraded '%s'\n" % sbox.ospath('A/D/G'),
"Upgraded '%s'\n" % sbox.ospath('A/D/H'),
- ]
+ ])
svntest.actions.run_and_verify_svn(None, expected_output, [],
'upgrade', sbox.wc_dir)