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

Side by Side Diff: tko/parsers/version_0.py

Issue 3885001: Change Autotest status parser from fail-hard to fail-safe. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tko/parsers/version_0_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import re, os 1 import re, os
2 2
3 from autotest_lib.client.common_lib import utils as common_utils 3 from autotest_lib.client.common_lib import utils as common_utils
4 from autotest_lib.tko import utils as tko_utils, models, status_lib 4 from autotest_lib.tko import utils as tko_utils, models, status_lib
5 from autotest_lib.tko.parsers import base 5 from autotest_lib.tko.parsers import base
6 6
7 7
8 class NoHostnameError(Exception): 8 class NoHostnameError(Exception):
9 pass 9 pass
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 def is_status_line(line): 246 def is_status_line(line):
247 return re.search(r"^\t*(\S[^\t]*\t){3}", line) is not None 247 return re.search(r"^\t*(\S[^\t]*\t){3}", line) is not None
248 248
249 249
250 @classmethod 250 @classmethod
251 def parse_line(cls, line): 251 def parse_line(cls, line):
252 if not status_line.is_status_line(line): 252 if not status_line.is_status_line(line):
253 return None 253 return None
254 indent, line = re.search(r"^(\t*)(.*)$", line, flags=re.DOTALL).groups() 254 indent, line = re.search(r"^(\t*)(.*)$", line, flags=re.DOTALL).groups()
255 indent = len(indent) 255 indent = len(indent)
256 line = line.strip()
257 256
258 # split the line into the fixed and optional fields 257 # split the line into the fixed and optional fields
259 parts = line.split("\t") 258 parts = line.rstrip("\n").split("\t")
260 status, subdir, testname = parts[0:3]
261 reason = parts[-1]
262 optional_parts = parts[3:-1]
263 259
264 # all the optional parts should be of the form "key=value" 260 part_index = 3
265 assert sum('=' not in part for part in optional_parts) == 0 261 status, subdir, testname = parts[0:part_index]
266 optional_fields = dict(part.split("=", 1) 262
267 for part in optional_parts) 263 # all optional parts should be of the form "key=value". once we've found
264 # a non-matching part, treat it and the rest of the parts as the reason.
265 optional_fields = {}
266 while part_index < len(parts):
267 kv = re.search(r"^(\w+)=(.+)", parts[part_index])
268 if not kv:
269 break
270
271 optional_fields[kv.group(1)] = kv.group(2)
272 part_index += 1
273
274 reason = "\t".join(parts[part_index:])
268 275
269 # build up a new status_line and return it 276 # build up a new status_line and return it
270 return cls(indent, status, subdir, testname, reason, 277 return cls(indent, status, subdir, testname, reason,
271 optional_fields) 278 optional_fields)
272 279
273 280
274 class parser(base.parser): 281 class parser(base.parser):
275 @staticmethod 282 @staticmethod
276 def make_job(dir): 283 def make_job(dir):
277 return job(dir) 284 return job(dir)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 testname = "boot.%d" % boot_count 445 testname = "boot.%d" % boot_count
439 reason = "machine did not return from reboot" 446 reason = "machine did not return from reboot"
440 tko_utils.dprint(("Adding: ABORT\nSubdir:----\n" 447 tko_utils.dprint(("Adding: ABORT\nSubdir:----\n"
441 "Testname:%s\n%s") 448 "Testname:%s\n%s")
442 % (testname, reason)) 449 % (testname, reason))
443 new_test = test.parse_test(self.job, None, testname, 450 new_test = test.parse_test(self.job, None, testname,
444 "ABORT", reason, 451 "ABORT", reason,
445 current_kernel, None, None) 452 current_kernel, None, None)
446 new_tests.append(new_test) 453 new_tests.append(new_test)
447 yield new_tests 454 yield new_tests
OLDNEW
« 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