How to use unexpected_error method in prospector

Best Python code snippet using prospector_python

patterns.py

Source:patterns.py Github

copy

Full Screen

1import re2class Severity(object):3 """Set seriousness of an error."""4 FATAL = 05 UNEXPECTED_ERROR = 16 EXPECTED_ERROR = 27 WARNING = 38 INFO = 49class SearchPattern(object):10 # noinspection PyPep8Naming11 """Define the issue's search pattern that was created through a regex match."""12 def __init__(self, name, nlp, pattern, html_template, severity,13 keep_going=True):14 # type: (str, str, str, unicode, bool, int) -> None15 """16 Pattern to search for.17 :param name: short name to identify this pattern.18 :param pattern: a regex to match.19 """20 self.name = name # type: str21 """The display name of the pattern."""22 self.html_template = html_template # type: unicode23 """The HTML template to use to render the pattern."""24 self.pattern_text = pattern # type: str25 """The regex for this pattern."""26 self.nlp = nlp27 """The NLP class to use to render this kind of error."""28 self.pattern = pattern29 """Regular expression for this pattern."""30 self.regex = re.compile(pattern)31 """The compiled regex for this pattern."""32 self.keep_going = keep_going33 """True if we should keep going after hitting one of these issues."""34 self.severity = severity35 """Integer severity level of this kind of pattern."""36 def __repr__(self):37 """Simplify and standardize printing of a search pattern."""38 return self.__class__.__name__ + "(" + self.name + ")"39default_search = [40 SearchPattern("Wrong LLVM Option",41 'GenericNLP',42 r"clang \(LLVM option parsing\): Unknown command line argument (?P<error>'.*')\. "43 r"Try: 'clang \(LLVM option parsing\) -help",44 u"{name}: {error} ",45 Severity.UNEXPECTED_ERROR),46 # Untested47 SearchPattern("CMake Error",48 'GenericNLP',49 r"CMake Error: (?P<error>.*)",50 u"{name}: {error} ",51 Severity.UNEXPECTED_ERROR),52 # Untested53 SearchPattern("Jenkins Shell Script Error",54 'GenericNLP',55 r"Build step (?P<reason>'(?!Trigger).*').*failure",56 u"{name}: {reason} ",57 Severity.INFO),58 # Untested59 SearchPattern("rsync error",60 'GenericNLP',61 r"rsync error(?P<error>.*) at (?P<location>.*)\s*",62 u"{name}: {error} {location} ",63 Severity.UNEXPECTED_ERROR),64 # Tested65 SearchPattern("Clang",66 'Clang',67 r"(?P<file_name>(\w|/|-|@|\.)*):(?P<line_number>\d+)(:\d+)?.*\s+"68 r"(?P<kind>error):\s+(?P<error_msg>.*)",69 u"{file_name} {kind}: {error_msg} ",70 Severity.UNEXPECTED_ERROR),71 SearchPattern("Clang file warning",72 'Clang',73 r"(?P<file_name>(\w|/|-|@|\.)*):(?P<line_number>\d+)(:\d+)?.*\s+"74 r"(?P<kind>warning):\s+(?P<error_msg>.*)",75 u"{file_name} {kind}: {error_msg} ",76 Severity.WARNING),77 # Untested78 SearchPattern("Too many errors emitted",79 'GenericNLP',80 r"fatal error: too many errors emitted.*",81 u"{name}: not good",82 Severity.UNEXPECTED_ERROR),83 SearchPattern("SSH Connection Closed",84 'GenericNLP',85 r'ssh_exchange_identification:(?P<error_message>.*)',86 u"{name}:{error_message}",87 Severity.FATAL,88 ),89 SearchPattern("Clang Warning",90 'Clang_Warning',91 r"clang-(\d+\.)+\d+: warning: *(?P<type>.*): (?P<which_arg>'-.*').*",92 u"{name}: {type} {which_arg}",93 Severity.WARNING),94 SearchPattern("link error",95 'GenericNLP',96 r'.*linker command failed with exit code.*',97 u"{name}",98 Severity.UNEXPECTED_ERROR),99 SearchPattern("node offline",100 'GenericNLP',101 r'ERROR: (?P<node>.*) is offline; cannot locate JDK',102 u"{name}: {node}",103 Severity.FATAL,104 keep_going = False),105 SearchPattern("assertion",106 'GenericNLP',107 r'Assertion failed: \((?P<assert_text>.*)\), function (?P<function>.*), file '108 r'(?P<file_name>[\S]*), line (?P<line_number>\d+).',109 u"{name}: {assert_text}",110 Severity.UNEXPECTED_ERROR),111 SearchPattern("gtest error",112 'GenericNLP',113 r'.*/googletest\.py:\d+: error: (?P<error_msg>.*) in \'(?P<file_name>.*)\':',114 u"{name}: {error_msg} in {file_name}",115 Severity.EXPECTED_ERROR),116 SearchPattern("lit",117 'Lit',118 r'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* TEST \'(?P<test_name>.*)\' FAILED '119 r'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*',120 u"{name}: {test_name}",121 Severity.EXPECTED_ERROR),122 SearchPattern("lint",123 'GenericNLP', # 'lint: %(path)s:%(row)d:%(col)d: %(code)s %(text)s'124 r'lint:\s(?P<file_name>.*):\d+:\d+:\s(?P<error_msg>.*)',125 u"{name}: {error_msg}",126 Severity.EXPECTED_ERROR),127 SearchPattern("lnt",128 'GenericNLP',129 r'FAIL:\s(?P<test_name>.*)\.(?P<test_kind>.*)\s\(',130 u"{name}: {test_name}",131 Severity.EXPECTED_ERROR),132 SearchPattern("Test Case",133 'GenericNLP',134 r'(?P<fail_type>FAIL|ERROR): (?P<test_name>.*)\s\((?P<file_name>.*)\)',135 u"{name}: {fail_type} - {file_name} {test_name}",136 Severity.EXPECTED_ERROR),137 SearchPattern("Cmake Error",138 'GenericNLP',139 r'CMake Error at (?P<file_name>.*) \(message\):',140 u"{name}: {file_name}",141 Severity.UNEXPECTED_ERROR),142 SearchPattern("Segfault",143 'GenericNLP',144 r'clang: error: unable to execute command: Segmentation fault: 11',145 u"{name}",146 Severity.UNEXPECTED_ERROR),147 SearchPattern("Ninja target",148 'GenericNLP',149 r'FAILED: (?P<file_name>.*)\s*',150 u"{name}: {file_name}",151 Severity.INFO),152 SearchPattern("Swift Execute Command Failed",153 'GenericNLP',154 r'FAIL.*command=\"(?P<command>[\w* ]*)-.*, (?P<return_code>returncode=.*)',155 u'{name}: {command} with {return_code}',156 Severity.UNEXPECTED_ERROR),157 SearchPattern("Timeout",158 'GenericNLP',159 r'Build timed out \(after \d+ minutes\)\. Marking the build as failed\.',160 u"{name}",161 Severity.UNEXPECTED_ERROR,162 keep_going=False),163 SearchPattern("Aborted",164 'GenericNLP',165 r'Aborted by (\w+)',166 u"{name}",167 Severity.FATAL,168 keep_going=False),169 SearchPattern("Jenkins Aborted",170 'GenericNLP',171 r'Build was aborted',172 u"{name}",173 Severity.FATAL,174 keep_going=False),175 SearchPattern("Triggered build failed",176 'GenericNLP',177 r'(?i)Build step \'Trigger/call builds on other projects\' (marked|changed) build '178 r'(as|result to) failure$',179 u"{name}",180 Severity.EXPECTED_ERROR),181 SearchPattern("Triggered build unstable",182 'GenericNLP',183 r'Build step \'Trigger/call builds on other projects\' changed build result to UNSTABLE$',184 u"{name}",185 Severity.EXPECTED_ERROR),186 SearchPattern("Ninja error",187 'GenericNLP',188 r'ninja: error: (?P<error_msg>.*)',189 u"{name}: {error_msg}",190 Severity.UNEXPECTED_ERROR),191 SearchPattern("Password expired",192 'GenericNLP',193 r'Password has expired$',194 u"{name}",195 Severity.UNEXPECTED_ERROR),196 SearchPattern("SVN error",197 'GenericNLP',198 r'org\.tmatesoft\.svn\.core\.SVNException: svn: (?P<error_code>.*): (?P<error_msg>.*)',199 u'{name}: {error_msg}',200 Severity.UNEXPECTED_ERROR),201 SearchPattern("Java exception",202 'GenericNLP',203 r'(?P<exception>(hudson|java)\.\S*Exception):\s(?P<error_msg>.*)',204 u'{exception}: {error_msg}',205 Severity.UNEXPECTED_ERROR),206 SearchPattern("Non-specific Java exception",207 'GenericNLP',208 r'(?P<exception>(hudson|java)\.\S*Exception)',209 u'{exception}',210 Severity.UNEXPECTED_ERROR),211 SearchPattern("HTTP Error",212 'Error',213 r'HTTP Error:\s(?P<code>\d+)\s(?P<url>.*)',214 u'{name}: {code}',215 Severity.UNEXPECTED_ERROR),216 SearchPattern("Fatal Error",217 'Error',218 r'(?i)fatal( error)?:\s(?P<error_msg>.*)',219 u'{name}: {error_msg}',220 Severity.UNEXPECTED_ERROR),221 SearchPattern("Warning",222 'Error',223 r'(?i)(warning):\s(?!profile data may be out of date)(?P<warning_msg>.*)',224 u'{name}: {warning_msg}',225 Severity.WARNING),226 SearchPattern("Python exception",227 'GenericNLP',228 r'(?P<exception>(socket\.error|'229 r'SystemExit|'230 r'KeyboardInterrupt|'231 r'GeneratorExit|'232 r'Exception|'233 r'StopIteration|'234 r'StandardError|'235 r'BufferError|'236 r'ArithmeticError|'237 r'FloatingPointError|'238 r'OverflowError|'239 r'ZeroDivisionError|'240 r'AssertionError|'241 r'AttributeError|'242 r'EnvironmentError|'243 r'IOError|'244 r'OSError|'245 r'EOFError|'246 r'ImportError|'247 r'LookupError|'248 r'IndexError|'249 r'KeyError|'250 r'MemoryError|'251 r'NameError|'252 r'UnboundLocalError|'253 r'ReferenceError|'254 r'RuntimeError'255 r'|NotImplementedError|'256 r'SyntaxError|'257 r'IndentationError|'258 r'TabError|'259 r'SystemError|'260 r'TypeError|'261 r'ValueError|'262 r'UnicodeError|'263 r'UnicodeDecodeError|'264 r'UnicodeEncodeError|'265 r'UnicodeTranslateError|'266 r'DeprecationWarning|'267 r'PendingDeprecationWarning|'268 r'RuntimeWarning|'269 r'SyntaxWarning|'270 r'UserWarning|'271 r'FutureWarning|'272 r'requests\.exceptions\.HTTPError|'273 r'ImportWarning|'274 r'UnicodeWarning|'275 r'BytesWarning|'276 r'subprocess\.CalledProcessError|'277 r'common_adopter\.ExecuteCommandFailure|'278 r'urllib2\.HTTPError)):\s(?P<error_msg>.*)',279 u'{exception}: {error_msg}',280 Severity.UNEXPECTED_ERROR),281 SearchPattern("Merge Conflict",282 'GenericNLP',283 r'CONFLICT \([\w\/]+\): Merge conflict in (?P<file_name>.*)',284 u'{name}: {file_name}',285 Severity.EXPECTED_ERROR),286 SearchPattern("Xcode Select Error",287 'GenericNLP',288 r'xcode-select: error:\s(?P<error_msg>.*)',289 u'{name}: {error_msg}',290 Severity.UNEXPECTED_ERROR),291 SearchPattern("ASANError", # Fixes rdar://problem/31719510292 'GenericNLP',293 r'.*SUMMARY:\s(?!\s*\d)AddressSanitizer(?P<error_msg>.*)',294 u'{name}: {error_msg}',295 Severity.UNEXPECTED_ERROR),296 SearchPattern("Proxy Error Message", # Fixes rdar://problem/31719510297 'GenericNLP',298 r'Reason: &lt;strong&gt;(?P<error_msg>.*)&lt;/strong.*&gt;',299 u'{name}: {error_msg}',300 Severity.UNEXPECTED_ERROR),301 SearchPattern("Env No Such File or Directory", # Fixes rdar://problem/32157409302 'GenericNLP',303 r'env:\s*(?P<file_name>(?:/\w+)*):\s*No such file or directory',304 u'{name}: {file_name}',305 Severity.UNEXPECTED_ERROR),306 SearchPattern("Error Low Disk Space", # Fixes rdar://problem/32081011307 'GenericNLP',308 r"Error: (?P<error_msg>low disk space).*scale\(collectd\.(?P<node>.*apple_com).*,\s(?P<free>\d*)",309 u'{name}: {error_msg} on {node}, {free}GB left.',310 Severity.EXPECTED_ERROR),311 SearchPattern("Error Device Name", # Fixes rdar://problem/32081011312 'GenericNLP',313 r".*ERROR: (?P<error_msg>.*Cannot find device named '\w.*)",314 u'{name}: {error_msg}',315 Severity.UNEXPECTED_ERROR),316 # Other errors have stops. If we hit this one, we know we did not match above.317 SearchPattern("Error",318 'Error',319 r'.*(?i)ERROR:\s+'320 r'('321 r'(?!0)' # Do not match "Error: 0", rdar://problem/31564106322 r'(?!AddressSanitizer)' # Covered by ASANError, rdar://problem/31719510323 r'(?!Cannot find device named)' # Covered by Error Device Name, rdar://problem/32081011324 r'(?!: True$)' # Nothing should match on: "Match found for :error: : True"325 r')'326 r'(?P<error_msg>.*)',327 u'{name}: {error_msg}',328 Severity.UNEXPECTED_ERROR),329 SearchPattern("GPU Automerger Conflict",330 'GenericNLP',331 r'Failures in Automerger from (?P<from_branch>\S+) to (?P<to_branch>\S+)',332 u'{name}: {from_branch} to {to_branch}',333 Severity.EXPECTED_ERROR),334 SearchPattern("Kinit Error",335 'GenericNLP',336 r'kinit:\s(?P<msg>.*)',337 u'{name}: {msg}',338 Severity.UNEXPECTED_ERROR),339 SearchPattern("Install-Xcode",340 'GenericNLP',341 r'\((?P<kind>(WARNING|CRITICAL))\)\s(?P<msg>.*)',342 u'{name} {kind}: {msg}',343 Severity.UNEXPECTED_ERROR),...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run prospector automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful