Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def createSummary(self, log):
""" Try to read the bzr merge output and parse results
"""
severity = SUCCESS
if self.args['workdir'] == 'server':
repo_expr = r'(?:bin|openerp)/addons/([^/]+)/.+$'
else:
repo_expr = r'([^/]+)/.+$'
t_results= {}
repo_re = re.compile(repo_expr)
for line in StringIO(log.getText()).readlines():
for rem, sev in self.known_res:
m = rem.match(line)
if not m:
continue
fname = m.group(1)
if sev > severity:
severity = sev
raise ValueError("upstreamSteps must be a non-empty list")
if self.idlePolicy not in self.VALID_IDLE_POLICIES:
raise ValueError(
"invalid value for idlePolicy: %r (must be one of %s)"
% (self.idlePolicy,
", ".join(map(repr, self.VALID_IDLE_POLICIES))))
# list of build steps (as BuildStepStatus objects) that we're
# currently waiting on
self._blocking_steps = []
# set of builders (as BuilderStatus objects) that have to start
# a Build before we can block on one of their BuildSteps
self._blocking_builders = set()
self._overall_code = builder.SUCCESS # assume the best
self._overall_text = []
self._timer = None # object returned by reactor.callLater()
self._timed_out = False
def start(self):
self._set_fname()
if (not self.overwrite) and os.path.isfile(self.marks_fname):
self.step_status.setText(["No need to export git marks"])
self.finished(SUCCESS)
return
d = threads.deferToThread(self._do_export)
self.step_status.setText(["export git marks", self.marks_fname])
return d
def evaluateCommand(self, cmd):
if cmd.rc != 0: return WARNINGS
return SUCCESS
warnOnWarnings = True
# different pieces of it
# 'cmd' is the original trial command, so cmd.logs['stdio'] is the
# trial output. We don't have access to test.log from here.
output = cmd.logs['stdio'].getText()
counts = countFailedTests(output)
total = counts['total']
failures, errors = counts['failures'], counts['errors']
parsed = (total != None)
text = []
text2 = ""
if cmd.rc == 0:
if parsed:
results = SUCCESS
if total:
text += ["%d %s" % \
(total,
total == 1 and "test" or "tests"),
"passed"]
else:
text += ["no tests", "run"]
else:
results = FAILURE
text += ["testlog", "unparseable"]
text2 = "tests"
else:
# something failed
results = FAILURE
if parsed:
text.append("tests")
if not watched.responsibles:
for responsible in build.getResponsibleUsers():
if not responsible in watched.responsibles: watched.responsibles.append(responsible)
msg.append('%s: %s broken by your recent commits.' % (', '.join(watched.responsibles), builderName))
else:
old_responsibles = []
new_responsibles = []
for responsible in build.getResponsibleUsers():
if responsible in watched.responsibles: old_responsibles.append(responsible)
else: new_responsibles.append(responsible)
if old_responsibles and not new_responsibles: append('%s: %s still broken.' % (', '.join(old_responsibles), builderName))
elif new_responsibles: msg.append('%s: %s still broken (was broken by %s).' % (
', '.join(old_responsibles + new_responsibles), builderName, ' and '.join(watched.responsibles)))
else: msg.append('%s still broken.' % (builderName,))
watched.responsibles.extend(new_responsibles)
elif watched.results == FAILURE and build.getResults() in (SUCCESS, WARNINGS):
msg.append('%s: %s repaired.' % (', '.join(build.getResponsibleUsers()), builderName))
watched.responsibles = []
watched.results = build.getResults()
if watched.results in (FAILURE, WARNINGS, EXCEPTION):
if watched.results == WARNINGS: msg.append('Some warnings occured while building %s.' % builderName)
elif watched.results == EXCEPTION: msg.append('An exception occured while trying to build %s!' % builderName)
url = self._parent_status.getURLForThing(build)
if not url: url = self._parent_status.getBuildbotURL()
if url: msg.append('Build details are at %s' % url)
if len(msg) != 0:
for channel in self.channelMap(builderName):
if not self.irc().quiet.get(channel, False): self.irc().msg(channel, ' '.join(msg).encode('ascii', 'replace'))
def statusDone(self):
if self.printloop:
self.printloop.stop()
print "All Builds Complete"
# TODO: include a URL for all failing builds
names = self.buildRequests.keys()
names.sort()
happy = True
for n in names:
code, text = self.results[n]
t = "%s: %s" % (n, builder.Results[code])
if text:
t += " (%s)" % " ".join(text)
print t
if code != builder.SUCCESS:
happy = False
if happy:
self.exitcode = 0
else:
self.exitcode = 1
self.running.callback(self.exitcode)
else:
if fdict.get('module_persist', False):
last_module = module
else:
last_module = None
# test name, detail after the module
if 'test_name' in mgd:
test_name = mgd['test_name']
elif 'test_name' in fdict:
test_name = fdict['test_name']
module = (module, test_name)
if module not in t_results:
t_results[module] = TestResult(name=module,
results=SUCCESS,
text='', logs={'stdout': u''})
if t_results[module].results < sev:
t_results[module].results = sev
if sev > severity:
severity = sev
last_msgs = [msg,] # and discard lower msgs
elif sev == severity:
last_msgs.append(msg)
if fdict.get('call'):
try:
fn = fdict['call']
fn(self, line, module, mgd, fdict)
except Exception:
twisted_log.err(None, "failed to call %r" % fdict['call'])
for rem, sev in self.known_res:
m = rem.match(line)
if not m:
continue
fname = m.group(1)
if sev > severity:
severity = sev
mf = repo_re.match(fname)
if mf:
module = (mf.group(1), 'merge')
else:
module = ('merge', 'rest')
if module not in t_results:
t_results[module] = TestResult(name=module,
results=SUCCESS,
text='', logs={'stdout': u''})
if t_results[module].results < sev:
t_results[module].results = sev
if line.endswith('\r\n'):
line = line[:-2] + '\n'
elif not line.endswith('\n'):
line += '\n'
if sev > SUCCESS:
t_results[module].text += ustr(line)
else:
t_results[module].logs['stdout'] += ustr(line)
break # don't attempt more matching of the same line
# use t_results
for tr in t_results.values():