diff mbox

Fix parsing bug in validate_patches.py

Message ID 51AF84BA.505@google.com
State New
Headers show

Commit Message

Brooks Moses June 5, 2013, 6:34 p.m. UTC
On 06/04/2013 03:57 PM, Diego Novillo wrote:
> OK with this predicate factored into a predicate function (maybe
> SummaryLineHasAttributes?)

Thanks!  Once I dove into that, I ended up doing a bit more refactoring; 
it really makes sense to pull the whole line-splitting into a separate 
function along with this.

Thus, I'm attaching an updated patch file that reflects that, along with 
a couple of other trivial changes I added since submitting the initial 
patch.

I've tested the adjusted line-stripping parts of the refactored code by 
adding and removing spaces in lines in my xfails file and confirming 
that things are still correctly matched.

Is this refactoring also OK to commit?

Thanks,
- Brooks

Comments

Diego Novillo June 6, 2013, 1:45 p.m. UTC | #1
On 2013-06-05 14:34 , Brooks Moses wrote:
>
> I've tested the adjusted line-stripping parts of the refactored code 
> by adding and removing spaces in lines in my xfails file and 
> confirming that things are still correctly matched.
>
> Is this refactoring also OK to commit?

Ah, thanks.  That's a better refactoring.

OK to commit.


Diego.
diff mbox

Patch

This patch implements a bit of refactoring of the validate_failures.py script
in contrib/testsuite-management.  In the script, there are two separate 
locations where a (potential) summary line is split off from any preceding
attributes and extraneous whitespace is stripped.  This patch refactors those
into calls to a single SplitAttributesFromSummaryLine function.

In addition, a couple of bugs are fixed in the process.

First, validate_failures.py has problems with test lines that contain a "|"
character in the actual message, because the DejaGnu output will be split
at the "|" as if it is prefixed by attributes, and the remainder is then
discarded as it does not match the pattern for a valid summary line.  Thus,
we only split a line if it is not already valid.

Second, we do not correctly handle xfailing of lines where the description
is empty, as occurs occasionally in tests such as the libstdc++-abi/abi_check
test.  This patch fixes that by adjusting the regular-expression matching to
allow for the absence of whitespace after the name.

Finally, the comment for "expected results not present" has been clarified to
account for the cases such as when a given testsuite simply wasn't run.

Index: contrib/testsuite-management/validate_failures.py
===================================================================
--- contrib/testsuite-management/validate_failures.py	(revision 199615)
+++ contrib/testsuite-management/validate_failures.py	(working copy)
@@ -119,20 +119,15 @@ 
 
   def __init__(self, summary_line, ordinal=-1):
     try:
-      self.attrs = ''
-      if '|' in summary_line:
-        (self.attrs, summary_line) = summary_line.split('|', 1)
+      (self.attrs, summary_line) = SplitAttributesFromSummaryLine(summary_line)
       try:
         (self.state,
          self.name,
-         self.description) = re.match(r' *([A-Z]+):\s*(\S+)\s+(.*)',
+         self.description) = re.match(r'([A-Z]+):\s*(\S+)\s*(.*)',
                                       summary_line).groups()
       except:
         print 'Failed to parse summary line: "%s"' % summary_line
         raise
-      self.attrs = self.attrs.strip()
-      self.state = self.state.strip()
-      self.description = self.description.strip()
       self.ordinal = ordinal
     except ValueError:
       Error('Cannot parse summary line "%s"' % summary_line)
@@ -208,11 +203,20 @@ 
   return line.startswith('#')
 
 
+def SplitAttributesFromSummaryLine(line):
+  """Splits off attributes from a summary line, if present."""
+  if '|' in line and not _VALID_TEST_RESULTS_REX.match(line):
+    (attrs, line) = line.split('|', 1)
+    attrs = attrs.strip()
+  else:
+    attrs = ''
+  line = line.strip()
+  return (attrs, line)
+
+
 def IsInterestingResult(line):
   """Return True if line is one of the summary lines we care about."""
-  if '|' in line:
-    (_, line) = line.split('|', 1)
-    line = line.strip()
+  (_, line) = SplitAttributesFromSummaryLine(line)
   return bool(_VALID_TEST_RESULTS_REX.match(line))
 
 
@@ -416,8 +420,9 @@ 
   if not ignore_missing_failures and len(expected_vs_actual) > 0:
     PrintSummary('Expected results not present in this build (fixed tests)'
                  '\n\nNOTE: This is not a failure.  It just means that these '
-                 'tests were expected\nto fail, but they worked in this '
-                 'configuration.\n', expected_vs_actual)
+                 'tests were expected\nto fail, but either they worked in '
+                 'this configuration or they were not\npresent at all.\n',
+                 expected_vs_actual)
 
   if tests_ok:
     print '\nSUCCESS: No unexpected failures.'