You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2013/02/07 22:47:07 UTC

svn commit: r1443742 - in /subversion/trunk/subversion/tests/cmdline: prop_tests.py svnadmin_tests.py svntest/verify.py

Author: julianfoad
Date: Thu Feb  7 21:47:07 2013
New Revision: 1443742

URL: http://svn.apache.org/r1443742
Log:
In the test suite, make the 'UnorderedRegexOutput' matcher more strict and
rename it to 'UnorderedRegexListOutput' to reflect its consistency with
'RegexListOutput'. It now matches every given expression to every actual
line one-to-one.

* subversion/tests/cmdline/prop_tests.py
  (rm_of_replaced_file): s/UnorderedRegexOutput/UnorderedRegexListOutput/.

* subversion/tests/cmdline/svnadmin_tests.py
  (test_lslocks_and_rmlocks): Simplify and adjust to use the new
    UnorderedRegexListOutput and the recently added RegexListOutput.

* subversion/tests/cmdline/svntest/verify.py
  (UnorderedRegexOutput): Rename to 'UnorderedRegexListOutput'. Match
    one-to-one instead of first removing duplicates.

Modified:
    subversion/trunk/subversion/tests/cmdline/prop_tests.py
    subversion/trunk/subversion/tests/cmdline/svnadmin_tests.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=1443742&r1=1443741&r2=1443742&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/prop_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/prop_tests.py Thu Feb  7 21:47:07 2013
@@ -1796,7 +1796,7 @@ def rm_of_replaced_file(sbox):
   exit_code, output, errput = svntest.main.run_svn(None,
                                                    'proplist', '-v',
                                                    mu_path + '@base')
-  expected_output = svntest.verify.UnorderedRegexOutput([
+  expected_output = svntest.verify.UnorderedRegexListOutput([
       'Properties on',
       '  yellow',
       '    submarine',

Modified: subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py?rev=1443742&r1=1443741&r2=1443742&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svnadmin_tests.py Thu Feb  7 21:47:07 2013
@@ -1499,44 +1499,31 @@ def test_lslocks_and_rmlocks(sbox):
                                      [], "lock", "-m", "Locking files",
                                      iota_url, lambda_url)
 
-  expected_output_list = [
-      "Path: /A/B/lambda",
+  def expected_output_list(path):
+    return [
+      "Path: " + path,
       "UUID Token: opaquelocktoken",
       "Owner: jrandom",
       "Created:",
       "Expires:",
       "Comment \(1 line\):",
       "Locking files",
-      "Path: /iota",
-      "UUID Token: opaquelocktoken.*",
       "\n", # empty line
       ]
 
   # List all locks
   exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
                                                         sbox.repo_dir)
-
   if errput:
     raise SVNUnexpectedStderr(errput)
   svntest.verify.verify_exit_code(None, exit_code, 0)
 
-  try:
-    expected_output = svntest.verify.UnorderedRegexOutput(expected_output_list)
-    svntest.verify.compare_and_display_lines('lslocks output mismatch',
-                                             'output',
-                                             expected_output, output)
-  except:
-    # Usually both locks have the same timestamp but if the clock
-    # ticks between creating the two locks then the timestamps will
-    # differ.  When the output has two identical "Created" lines
-    # UnorderedRegexOutput must have one matching regex, when the
-    # output has two different "Created" lines UnorderedRegexOutput
-    # must have two regex.
-    expected_output_list.append("Created:.*")
-    expected_output = svntest.verify.UnorderedRegexOutput(expected_output_list)
-    svntest.verify.compare_and_display_lines('lslocks output mismatch',
-                                             'output',
-                                             expected_output, output)
+  expected_output = svntest.verify.UnorderedRegexListOutput(
+                                     expected_output_list('/A/B/lambda') +
+                                     expected_output_list('/iota'))
+  svntest.verify.compare_and_display_lines('lslocks output mismatch',
+                                           'output',
+                                           expected_output, output)
 
   # List lock in path /A
   exit_code, output, errput = svntest.main.run_svnadmin("lslocks",
@@ -1545,18 +1532,10 @@ def test_lslocks_and_rmlocks(sbox):
   if errput:
     raise SVNUnexpectedStderr(errput)
 
-  expected_output = svntest.verify.UnorderedRegexOutput([
-    "Path: /A/B/lambda",
-    "UUID Token: opaquelocktoken",
-    "Owner: jrandom",
-    "Created:",
-    "Expires:",
-    "Comment \(1 line\):",
-    "Locking files",
-    "\n", # empty line
-    ])
-
-  svntest.verify.compare_and_display_lines('message', 'label',
+  expected_output = svntest.verify.RegexListOutput(
+                                     expected_output_list('/A/B/lambda'))
+  svntest.verify.compare_and_display_lines('lslocks output mismatch',
+                                           'output',
                                            expected_output, output)
   svntest.verify.verify_exit_code(None, exit_code, 0)
 

Modified: subversion/trunk/subversion/tests/cmdline/svntest/verify.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/verify.py?rev=1443742&r1=1443741&r2=1443742&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/verify.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/verify.py Thu Feb  7 21:47:07 2013
@@ -282,13 +282,18 @@ class UnorderedOutput(ExpectedOutput):
     display_lines_diff(self.expected, actual, label + ' (unordered)', label)
 
 
-class UnorderedRegexOutput(ExpectedOutput):
+class UnorderedRegexListOutput(ExpectedOutput):
   """Matches an unordered list of regular expressions.
 
-     After removing any duplicate actual lines, each expected regular
-     expression must match one actual line, one-to-one, in any order.
-     If multiple expressions match the same actual line, the behaviour
-     is undefined.
+     The expressions must match all the actual lines, one-to-one, in any
+     order.
+
+     Note: This can give a false negative result (no match) when there is
+     an actual line that matches multiple expressions and a different
+     actual line that matches some but not all of those same
+     expressions.  The implementation matches each expression in turn to
+     the first unmatched actual line that it can match, and does not try
+     all the permutations when there are multiple possible matches.
   """
 
   def __init__(self, expected):
@@ -300,17 +305,13 @@ class UnorderedRegexOutput(ExpectedOutpu
     if not isinstance(actual, list):
       actual = [actual]
 
-    # Disregard the order of ACTUAL lines during comparison.
-    e_set = set(self.expected)
-    a_set = set(actual)
-
-    if len(e_set) != len(a_set):
+    if len(self.expected) != len(actual):
       return False
-    for e in e_set:
+    for e in self.expected:
       expect_re = re.compile(e)
-      for actual_line in a_set:
+      for actual_line in actual:
         if expect_re.match(actual_line):
-          a_set.remove(actual_line)
+          actual.remove(actual_line)
           break
       else:
         # One of the regexes was not found