Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: tko/parsers/version_0.py

Issue 3713002: tko/parsers: make status_line parsing more robust to bad inputs (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tko/parsers/version_0_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tko/parsers/version_0.py
diff --git a/tko/parsers/version_0.py b/tko/parsers/version_0.py
index 7e8a5d884c598c69a2eb41a2a48e9d062ca4c20f..b061f2a75cb9b410840a2fd38d5d45c360ad0f0a 100644
--- a/tko/parsers/version_0.py
+++ b/tko/parsers/version_0.py
@@ -251,17 +251,26 @@ class status_line(object):
def parse_line(cls, line):
if not status_line.is_status_line(line):
return None
- indent, line = re.search(r"^(\t*)(.*)$", line).groups()
+ # We sometimes get multi-line input, bug?
+ lines = line.splitlines()
+ if len(lines) > 1:
+ tko_utils.dprint('Got multi-line input to parse_line().')
+ tko_utils.dprint('Input lines: %s' % repr(lines))
+ indent, line = re.search(r"^(\t*)(.*)$", line, re.DOTALL).groups()
indent = len(indent)
# split the line into the fixed and optional fields
- parts = line.split("\t")
+ parts = line.rstrip().split("\t")
status, subdir, testname = parts[0:3]
reason = parts[-1]
optional_parts = parts[3:-1]
# all the optional parts should be of the form "key=value"
- assert sum('=' not in part for part in optional_parts) == 0
+ if sum('=' not in part for part in optional_parts) != 0:
+ # this may not have been a status line
+ tko_utils.dprint('This does not look like a status line, skipping.')
+ tko_utils.dprint('Line: %s' % line)
+ return None
optional_fields = dict(part.split("=", 1)
for part in optional_parts)
« no previous file with comments | « no previous file | tko/parsers/version_0_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698