Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 from waterfall import extractor_util | 9 from waterfall import extractor_util |
| 10 from waterfall import waterfall_config | 10 from waterfall import waterfall_config |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 # can be removed, but if not then we want to replace the target group with | 118 # can be removed, but if not then we want to replace the target group with |
| 119 # ("([^"]+)"|([^\s-]+)) instead. | 119 # ("([^"]+)"|([^\s-]+)) instead. |
| 120 LINUX_FAILED_SOURCE_TARGET_PATTERN = re.compile( | 120 LINUX_FAILED_SOURCE_TARGET_PATTERN = re.compile( |
| 121 r'(?:-c ([^\s-]+))? -o (("[^"]+")|([^\s-]+))') | 121 r'(?:-c ([^\s-]+))? -o (("[^"]+")|([^\s-]+))') |
| 122 WINDOWS_FAILED_SOURCE_TARGET_PATTERN = re.compile( | 122 WINDOWS_FAILED_SOURCE_TARGET_PATTERN = re.compile( |
| 123 r'/c ([^\s-]+)\s+/Fo([^\s-]+)') | 123 r'/c ([^\s-]+)\s+/Fo([^\s-]+)') |
| 124 WINDOWS_LINK_FAILURE_PATTERN = re.compile(r'/OUT:([^\s-]+)') | 124 WINDOWS_LINK_FAILURE_PATTERN = re.compile(r'/OUT:([^\s-]+)') |
| 125 | 125 |
| 126 NINJA_FAILURE_END_LINE_PREFIX = 'ninja: build stopped' | 126 NINJA_FAILURE_END_LINE_PREFIX = 'ninja: build stopped' |
| 127 NINJA_ERROR_LINE_PREFIX = 'ninja: error' | 127 NINJA_ERROR_LINE_PREFIX = 'ninja: error' |
| 128 ERROR_LINE_END_PATTERN = re.compile(r'^\d+ errors? generated.') | 128 ERROR_LINE_END_PATTERN1 = re.compile(r'^\d+ errors? generated.') |
| 129 ERROR_LINE_END_PATTERN2 = re.compile(r'failed with exit code \d+') | |
|
chanli
2016/04/29 18:26:34
Question: in the stdio file of the example(https:/
lijeffrey
2016/04/29 19:23:35
The example for "failed with exit code" was from h
| |
| 130 OUTSIDE_FAILURE_LINE_PATTERN = re.compile(r'\[\d+/\d+\]') | |
| 131 | |
| 129 IOS_ERROR_LINE_START_PREFIX = 'CompileC' | 132 IOS_ERROR_LINE_START_PREFIX = 'CompileC' |
| 130 | 133 |
| 131 IOS_BUILDER_NAMES_FOR_COMPILE = ['iOS_Simulator_(dbg)', 'iOS_Device'] | 134 IOS_BUILDER_NAMES_FOR_COMPILE = ['iOS_Simulator_(dbg)', 'iOS_Device'] |
| 132 MAC_MASTER_NAME_FOR_COMPILE = 'chromium.mac' | 135 MAC_MASTER_NAME_FOR_COMPILE = 'chromium.mac' |
| 133 | 136 |
| 134 GOMA_COMPILER_PREFIX = ( | 137 GOMA_COMPILER_PREFIX = ( |
| 135 r'\S*/gomacc ' | 138 r'\S*/gomacc ' |
| 136 '\S+(?:clang\+\+|androideabi-gcc|androideabi-g\+\+)' | 139 '\S+(?:clang\+\+|androideabi-gcc|androideabi-g\+\+)' |
| 137 ) | 140 ) |
| 138 STRICT_COMPILE_FAILURE_PATTEN = re.compile( | 141 STRICT_COMPILE_FAILURE_PATTEN = re.compile( |
| 139 r'^FAILED: %s -MMD -MF (obj/[^\s-]+\.o)\.d .* ' | 142 r'^%s -MMD -MF (obj/[^\s-]+\.o)\.d .* ' |
| 140 '-c ([^\s-]+(?:cc|c|cpp|m|mm)) -o \\1$' % ( | 143 '-c ([^\s-]+(?:cc|c|cpp|m|mm)) -o \\1$' % GOMA_COMPILER_PREFIX) |
| 141 GOMA_COMPILER_PREFIX)) | |
| 142 | 144 |
| 143 STRICT_LINK_FAILURE_PATTEN = re.compile( | 145 STRICT_LINK_FAILURE_PATTEN = re.compile( |
| 144 r'^FAILED: %s -Wl,.* -o (\S+) -Wl,--start-group .*$' % ( | 146 r'^%s -Wl,.* -o (\S+) -Wl,--start-group .*$' % ( |
| 145 GOMA_COMPILER_PREFIX)) | 147 GOMA_COMPILER_PREFIX)) |
| 146 | 148 |
| 147 def ExtractFailedOutputNodes(self, line, signal): | 149 def ExtractFailedOutputNodes(self, line, signal): |
| 148 match = self.STRICT_COMPILE_FAILURE_PATTEN.match(line) | 150 match = self.STRICT_COMPILE_FAILURE_PATTEN.match(line) |
| 149 if match: | 151 if match: |
| 150 target = match.group(1) | 152 target = match.group(1) |
| 151 source = match.group(2) | 153 source = match.group(2) |
| 152 signal.AddTarget({ | 154 signal.AddTarget({ |
| 153 'target': target, | 155 'target': target, |
| 154 'source': source, | 156 'source': source, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 else: | 209 else: |
| 208 match = self.WINDOWS_LINK_FAILURE_PATTERN.search(line) | 210 match = self.WINDOWS_LINK_FAILURE_PATTERN.search(line) |
| 209 if match: | 211 if match: |
| 210 # Failure is a linker error. | 212 # Failure is a linker error. |
| 211 target = match.group(1) | 213 target = match.group(1) |
| 212 signal.AddTarget({'target': target}) | 214 signal.AddTarget({'target': target}) |
| 213 | 215 |
| 214 def Extract(self, failure_log, test_name, step_name, bot_name, master_name): | 216 def Extract(self, failure_log, test_name, step_name, bot_name, master_name): |
| 215 signal = FailureSignal() | 217 signal = FailureSignal() |
| 216 failure_started = False | 218 failure_started = False |
| 219 is_build_command_line = False | |
| 217 | 220 |
| 218 if (master_name == self.MAC_MASTER_NAME_FOR_COMPILE and | 221 if (master_name == self.MAC_MASTER_NAME_FOR_COMPILE and |
| 219 bot_name in self.IOS_BUILDER_NAMES_FOR_COMPILE): | 222 bot_name in self.IOS_BUILDER_NAMES_FOR_COMPILE): |
| 220 error_lines = [] | 223 error_lines = [] |
| 221 for line in reversed(failure_log.splitlines()): | 224 for line in reversed(failure_log.splitlines()): |
| 222 if (not failure_started and | 225 if (not failure_started and |
| 223 self.ERROR_LINE_END_PATTERN.match(line)): | 226 self.ERROR_LINE_END_PATTERN1.match(line)): |
| 224 failure_started = True | 227 failure_started = True |
| 225 continue | 228 continue |
| 226 | 229 |
| 227 if failure_started: | 230 if failure_started: |
| 228 if line.startswith(self.IOS_ERROR_LINE_START_PREFIX): | 231 if line.startswith(self.IOS_ERROR_LINE_START_PREFIX): |
| 229 failure_started = False | 232 failure_started = False |
| 230 for l in error_lines[:-4]: | 233 for l in error_lines[:-4]: |
| 231 self.ExtractFiles(l, signal) | 234 self.ExtractFiles(l, signal) |
| 232 error_lines = [] | 235 error_lines = [] |
| 233 else: | 236 else: |
| 234 error_lines.append(line) | 237 error_lines.append(line) |
| 235 else: | 238 else: |
| 236 strict_regex = waterfall_config.EnableStrictRegexForCompileLinkFailures( | 239 strict_regex = waterfall_config.EnableStrictRegexForCompileLinkFailures( |
| 237 master_name, bot_name) | 240 master_name, bot_name) |
| 238 for line in failure_log.splitlines(): | 241 for line in failure_log.splitlines(): |
| 239 if line.startswith(self.FAILURE_START_LINE_PREFIX): | 242 if line.startswith(self.FAILURE_START_LINE_PREFIX): |
| 243 is_build_command_line = True | |
| 244 if not failure_started: | |
| 245 failure_started = True | |
| 246 continue # pragma: no cover | |
|
stgao
2016/04/29 16:38:24
Hm, I think this should be executed in a common te
lijeffrey
2016/04/29 19:23:35
It seems there's a bug in coverage
a = False
for
| |
| 247 elif is_build_command_line: | |
| 240 if strict_regex: | 248 if strict_regex: |
| 241 self.ExtractFailedOutputNodes(line, signal) | 249 self.ExtractFailedOutputNodes(line, signal) |
| 242 else: | 250 else: |
| 243 self.GetFailedTarget(line, signal) | 251 self.GetFailedTarget(line, signal) |
| 244 if not failure_started: | 252 is_build_command_line = False |
| 245 failure_started = True | 253 continue |
| 246 continue # pragma: no cover | |
| 247 elif self.FAILURE_WITH_ERROR_PATTERN.match(line): | 254 elif self.FAILURE_WITH_ERROR_PATTERN.match(line): |
| 248 # It is possible the target and source file associated with a compile | 255 # It is possible the target and source file associated with a compile |
| 249 # failure is logged outside a 'FAILED: ... 1 error generated' block, | 256 # failure is logged outside a 'FAILED: ... 1 error generated' block, |
| 250 # so extract regardless of failure_started. | 257 # so extract targets regardless of failure_started. |
| 251 if not strict_regex: | 258 if not strict_regex: |
| 252 self.GetFailedTarget(line, signal) | 259 self.GetFailedTarget(line, signal) |
| 253 elif failure_started and self.ERROR_LINE_END_PATTERN.match(line): | 260 elif (failure_started and |
| 261 (self.ERROR_LINE_END_PATTERN1.match(line) or | |
| 262 self.ERROR_LINE_END_PATTERN2.search(line) or | |
| 263 self.OUTSIDE_FAILURE_LINE_PATTERN.match(line))): | |
| 254 failure_started = False | 264 failure_started = False |
| 255 elif failure_started and line.startswith( | 265 elif failure_started and line.startswith( |
| 256 self.NINJA_FAILURE_END_LINE_PREFIX): # pragma: no cover | 266 self.NINJA_FAILURE_END_LINE_PREFIX): # pragma: no cover |
| 257 break | 267 break |
| 268 | |
| 258 if failure_started or line.startswith(self.NINJA_ERROR_LINE_PREFIX): | 269 if failure_started or line.startswith(self.NINJA_ERROR_LINE_PREFIX): |
| 259 # either within the compile errors or is a ninja error. | 270 # either within the compile errors or is a ninja error. |
| 260 self.ExtractFiles(line, signal) | 271 self.ExtractFiles(line, signal) |
| 261 | 272 |
| 262 return signal | 273 return signal |
| 263 | 274 |
| 264 | 275 |
| 265 class CheckPermExtractor(Extractor): | 276 class CheckPermExtractor(Extractor): |
| 266 """For CheckPerm, only extracts files.""" | 277 """For CheckPerm, only extracts files.""" |
| 267 | 278 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 def ExtractSignal(master_name, bot_name, step_name, test_name, failure_log): | 525 def ExtractSignal(master_name, bot_name, step_name, test_name, failure_log): |
| 515 """Uses an appropriate extractor to extract failure signals. | 526 """Uses an appropriate extractor to extract failure signals. |
| 516 | 527 |
| 517 Returns: | 528 Returns: |
| 518 A FailureSignal. | 529 A FailureSignal. |
| 519 """ | 530 """ |
| 520 # Fall back to a general-but-maybe-not-accurate extractor. | 531 # Fall back to a general-but-maybe-not-accurate extractor. |
| 521 extractor_class = EXTRACTORS.get(step_name, GeneralExtractor) | 532 extractor_class = EXTRACTORS.get(step_name, GeneralExtractor) |
| 522 return extractor_class().Extract( | 533 return extractor_class().Extract( |
| 523 failure_log, test_name, step_name, bot_name, master_name) | 534 failure_log, test_name, step_name, bot_name, master_name) |
| OLD | NEW |