summaryrefslogtreecommitdiff
path: root/tko/parsers/version_0.py
diff options
context:
space:
mode:
authorlmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4>2011-06-25 17:19:16 +0000
committerlmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4>2011-06-25 17:19:16 +0000
commit8ea2aa8ff02426b3b248a7e3d48efb215a55904b (patch)
treebd1f47abab88b59085ae5b9480d2b3cf886f9b85 /tko/parsers/version_0.py
parentb0b45fb92c6f79af2b1e2bce8c332e4f19d4d19b (diff)
tko.parsers: Support multiline, tabbed reasons. Improve parser robustness.HEADmaster
Allowing reasons with multiple lines and tabs provides more flexibility in error messages. The parser is also more robust, as any invalid fields are moved into the reason and can be fixed offline without impacting the rest of the system. Signed-off-by: Dale Curtis <dalecurtis@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@5452 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko/parsers/version_0.py')
-rw-r--r--tko/parsers/version_0.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/tko/parsers/version_0.py b/tko/parsers/version_0.py
index c690d211..ed12cb48 100644
--- a/tko/parsers/version_0.py
+++ b/tko/parsers/version_0.py
@@ -251,7 +251,7 @@ class status_line(object):
def parse_line(cls, line):
if not status_line.is_status_line(line):
return None
- match = re.search(r"^(\t*)(.*)$", line)
+ match = re.search(r"^(\t*)(.*)$", line, flags=re.DOTALL)
if not match:
# A more useful error message than:
# AttributeError: 'NoneType' object has no attribute 'groups'
@@ -261,15 +261,23 @@ class status_line(object):
indent = len(indent)
# split the line into the fixed and optional fields
- parts = line.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
- optional_fields = dict(part.split("=", 1)
- for part in optional_parts)
+ parts = line.rstrip("\n").split("\t")
+
+ part_index = 3
+ status, subdir, testname = parts[0:part_index]
+
+ # all optional parts should be of the form "key=value". once we've found
+ # a non-matching part, treat it and the rest of the parts as the reason.
+ optional_fields = {}
+ while part_index < len(parts):
+ kv = parts[part_index].split('=', 1)
+ if len(kv) < 2:
+ break
+
+ optional_fields[kv[0]] = kv[1]
+ part_index += 1
+
+ reason = "\t".join(parts[part_index:])
# build up a new status_line and return it
return cls(indent, status, subdir, testname, reason,