Author: brane
Date: Mon May 26 19:56:54 2025
New Revision: 1925842

URL: http://svn.apache.org/viewvc?rev=1925842&view=rev
Log:
Add more XML schema vaildation, and fix an error handling bug.

* subversion/tests/cmdline/prop_tests.py
  (xml_unsafe_author2): Add schema validation. Mark XFail unless over
   DAV, because the XML output is invalid and the schema validation fails.
* subversion/tests/cmdline/svntest/actions.py
  (run_and_verify_log_xml, run_and_verify_status_xml): Add schema validation.
  (run_and_verify_inherited_prop_xml): Note that we don't have a schema for 
props.
  (run_and_verify_diff_summarize_xml): Add schema validation.
* subversion/tests/cmdline/svntest/main.py
  (unless_ra_type_dav): New predicate.
* subversion/tests/cmdline/svntest/verify.py
  (validate_xml_schema): Better output on validation failure; also do not use
   an unbound local variable.

Modified:
    subversion/trunk/subversion/tests/cmdline/prop_tests.py
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py
    subversion/trunk/subversion/tests/cmdline/svntest/main.py
    subversion/trunk/subversion/tests/cmdline/svntest/verify.py

Modified: subversion/trunk/subversion/tests/cmdline/prop_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/prop_tests.py?rev=1925842&r1=1925841&r2=1925842&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/prop_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/prop_tests.py Mon May 26 19:56:54 
2025
@@ -2640,6 +2640,8 @@ def xml_unsafe_author(sbox):
                                      wc_dir)
 
 @Issue(4415)
+@Issue(4919)
+@XFail(svntest.main.unless_ra_type_dav)
 def xml_unsafe_author2(sbox):
   "svn:author with XML unsafe chars 2"
 
@@ -2694,8 +2696,8 @@ def xml_unsafe_author2(sbox):
     '</lists>\n'
     ]
 
-  svntest.actions.run_and_verify_svn(expected_output, [],
-                                     'ls', '--xml', repo_url)
+  svntest.actions.run_and_verify_svn_xml(expected_output, [],
+                                         'list', '--xml', repo_url)
 
   expected_info = [{
       'Repository Root' : sbox.repo_url,

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1925842&r1=1925841&r2=1925842&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Mon May 26 
19:56:54 2025
@@ -797,11 +797,11 @@ def run_and_verify_log_xml(expected_log_
   # We'll parse the output unless the caller specifies expected_stderr or
   # expected_stdout for run_and_verify_svn.
   parse = True
-  if expected_stderr == None:
+  if expected_stderr is None:
     expected_stderr = []
   else:
     parse = False
-  if expected_stdout != None:
+  if expected_stdout is not None:
     parse = False
 
   log_args = list(args)
@@ -813,6 +813,7 @@ def run_and_verify_log_xml(expected_log_
     'log', '--xml', *log_args)
   if not parse:
     return
+  verify.validate_xml_schema('log', stdout)
 
   entries = LogParser().parse(stdout)
   for index in range(len(entries)):
@@ -1647,9 +1648,9 @@ def run_and_verify_status_xml(expected_e
 
   exit_code, output, errput = run_and_verify_svn(None, [],
                                                  'status', '--xml', *args)
-
   if len(errput) > 0:
     raise Failure
+  verify.validate_xml_schema('status', output)
 
   doc = parseString(''.join(output))
   entries = doc.getElementsByTagName('entry')
@@ -1726,6 +1727,7 @@ def run_and_verify_inherited_prop_xml(pa
 
   if len(errput) > 0:
     raise Failure
+  ## FIXME: Need XML schema: verify.validate_xml_schema('props', output)
 
   # Props inherited from within the WC are keyed on absolute paths.
   expected_iprops = {}
@@ -1798,10 +1800,10 @@ def run_and_verify_diff_summarize_xml(er
                                                  'diff', '--summarize',
                                                  '--xml', *args)
 
-
   # Return if errors are present since they were expected
   if len(errput) > 0:
     return
+  verify.validate_xml_schema('diff', output)
 
   doc = parseString(''.join(output))
   paths = doc.getElementsByTagName("path")

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1925842&r1=1925841&r2=1925842&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Mon May 26 
19:56:54 2025
@@ -1614,6 +1614,9 @@ def tests_verify_dump_load_cross_check()
 def is_ra_type_dav():
   return options.test_area_url.startswith('http')
 
+def unless_ra_type_dav():
+  return not is_ra_type_dav()
+
 def is_ra_type_dav_neon():
   """Return True iff running tests over RA-Neon.
      CAUTION: Result is only valid if svn was built to support both."""

Modified: subversion/trunk/subversion/tests/cmdline/svntest/verify.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/verify.py?rev=1925842&r1=1925841&r2=1925842&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/verify.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/verify.py Mon May 26 
19:56:54 2025
@@ -1062,8 +1062,12 @@ def validate_xml_schema(name: str, lines
     source = ''.join(lines)
     document = etree.parse(BytesIO(source.encode("utf-8")))
     if not schema.validate(document):
-      raise SVNXMLSchemaValidationError("schema %s" % schema_name)
+      print(schema.error_log)
+      raise SVNXMLSchemaValidationError("Schema: %s" % schema_name)
+  except ImportError:
+    print("ERROR: Pyhton module lxml.etree is required for XML validation")
+    raise svntest.Failure()
   except Exception:
-    print("ERROR: XML output does not conform to schema", schema_name)
-    print(source)
+    print("ERROR: invalid XML")
+    print("\n".join(repr(line) for line in lines))
     raise


Reply via email to