You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2012/02/21 18:50:32 UTC
svn commit: r1291941 - in /subversion/trunk/subversion/tests/cmdline:
stat_tests.py svntest/actions.py
Author: philip
Date: Tue Feb 21 17:50:31 2012
New Revision: 1291941
URL: http://svn.apache.org/viewvc?rev=1291941&view=rev
Log:
Tweak two regression tests so that they do not depend on APR hash order.
Parse 'status --xml' output into hashes.
* subversion/tests/cmdline/stat.py
(status_in_xml, status_update_with_incoming_props): Use the new
run_and_verify_status_xml.
* subversion/tests/cmdline/svntest/actions.py
(run_and_verify_status_xml): New.
Modified:
subversion/trunk/subversion/tests/cmdline/stat_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/actions.py
Modified: subversion/trunk/subversion/tests/cmdline/stat_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/stat_tests.py?rev=1291941&r1=1291940&r2=1291941&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/stat_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/stat_tests.py Tue Feb 21 17:50:31 2012
@@ -924,38 +924,13 @@ def status_in_xml(sbox):
else:
raise svntest.Failure
- template = ['<?xml version="1.0" encoding="UTF-8"?>\n',
- "<status>\n",
- "<target\n",
- " path=\"%s\">\n" % (file_path),
- "<entry\n",
- " path=\"%s\">\n" % (file_path),
- "<wc-status\n",
- " props=\"none\"\n",
- " item=\"modified\"\n",
- " revision=\"1\">\n",
- "<commit\n",
- " revision=\"1\">\n",
- "<author>%s</author>\n" % svntest.main.wc_author,
- time_str,
- "</commit>\n",
- "</wc-status>\n",
- "</entry>\n",
- "<against\n",
- " revision=\"1\"/>\n",
- "</target>\n",
- "</status>\n",
- ]
+ expected_entries = {file_path : {'wcprops' : 'none',
+ 'wcitem' : 'modified',
+ 'wcrev' : '1',
+ 'crev' : '1',
+ 'author' : svntest.main.wc_author}}
- exit_code, output, error = svntest.actions.run_and_verify_svn(None, None, [],
- 'status',
- file_path,
- '--xml', '-u')
-
- for i in range(0, len(output)):
- if output[i] != template[i]:
- print("ERROR: expected: %s actual: %s" % (template[i], output[i]))
- raise svntest.Failure
+ svntest.actions.run_and_verify_status_xml(expected_entries, file_path, '-u')
svntest.actions.run_and_verify_svn(None, None, [],
'cp', '-m', 'repo-to-repo copy',
@@ -964,36 +939,12 @@ def status_in_xml(sbox):
file_path = sbox.ospath('iota2')
- template = ['<?xml version="1.0" encoding="UTF-8"?>\n',
- "<status>\n",
- "<target\n",
- " path=\"%s\">\n" % (file_path),
- "<entry\n",
- " path=\"%s\">\n" % (file_path),
- "<wc-status\n",
- " props=\"none\"\n",
- " item=\"none\">\n",
- "</wc-status>\n",
- "<repos-status\n",
- " props=\"none\"\n",
- " item=\"added\">\n",
- "</repos-status>\n",
- "</entry>\n",
- "<against\n",
- " revision=\"2\"/>\n",
- "</target>\n",
- "</status>\n",
- ]
+ expected_entries = {file_path : {'wcprops' : 'none',
+ 'wcitem' : 'none',
+ 'rprops' : 'none',
+ 'ritem' : 'added'}}
- exit_code, output, error = svntest.actions.run_and_verify_svn(None, None, [],
- 'status',
- file_path,
- '--xml', '-u')
-
- for i in range(0, len(output)):
- if output[i] != template[i]:
- print("ERROR: expected: %s actual: %s" % (template[i], output[i]))
- raise svntest.Failure
+ svntest.actions.run_and_verify_status_xml(expected_entries, file_path, '-u')
#----------------------------------------------------------------------
@@ -1269,53 +1220,23 @@ def status_update_with_incoming_props(sb
else:
raise svntest.Failure
- xout = ['<?xml version="1.0" encoding="UTF-8"?>\n',
- "<status>\n",
- "<target\n",
- " path=\"%s\">\n" % (wc_dir),
- "<entry\n",
- " path=\"%s\">\n" % (A_path),
- "<wc-status\n",
- " props=\"none\"\n",
- " item=\"normal\"\n",
- " revision=\"1\">\n",
- "<commit\n",
- " revision=\"1\">\n",
- "<author>%s</author>\n" % svntest.main.wc_author,
- time_str,
- "</commit>\n",
- "</wc-status>\n",
- "<repos-status\n",
- " props=\"modified\"\n",
- " item=\"none\">\n",
- "</repos-status>\n",
- "</entry>\n",
- "<entry\n",
- " path=\"%s\">\n" % (wc_dir),
- "<wc-status\n",
- " props=\"none\"\n",
- " item=\"normal\"\n",
- " revision=\"1\">\n",
- "<commit\n",
- " revision=\"1\">\n",
- "<author>%s</author>\n" % svntest.main.wc_author,
- time_str,
- "</commit>\n",
- "</wc-status>\n",
- "<repos-status\n",
- " props=\"modified\"\n",
- " item=\"none\">\n",
- "</repos-status>\n",
- "</entry>\n",
- "<against\n",
- " revision=\"2\"/>\n",
- "</target>\n",
- "</status>\n",]
-
- exit_code, output, error = svntest.actions.run_and_verify_svn(None, xout, [],
- 'status',
- wc_dir,
- '--xml', '-uN')
+ expected_entries ={wc_dir : {'wcprops' : 'none',
+ 'wcitem' : 'normal',
+ 'wcrev' : '1',
+ 'crev' : '1',
+ 'author' : svntest.main.wc_author,
+ 'rprops' : 'modified',
+ 'ritem' : 'none'},
+ A_path : {'wcprops' : 'none',
+ 'wcitem' : 'normal',
+ 'wcrev' : '1',
+ 'crev' : '1',
+ 'author' : svntest.main.wc_author,
+ 'rprops' : 'modified',
+ 'ritem' : 'none'},
+ }
+
+ svntest.actions.run_and_verify_status_xml(expected_entries, wc_dir, '-uN')
# more incoming prop updates.
def status_update_verbose_with_incoming_props(sbox):
Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1291941&r1=1291940&r2=1291941&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Tue Feb 21 17:50:31 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.
"""
if self.changed_paths != changed_paths:
raise Failure('\n' + '\n'.join(difflib.ndiff(
@@ -1518,6 +1519,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 = [],