Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_notification_successToException(self):
self.do_x_to_y_notification_test(notify="successToException", previous_result=builder.SUCCESS, new_result=builder.EXCEPTION,
expected_msg="build #862 of builder834 is complete: Exception [step1 step2] Build details are at http://myserver/mypath?build=765" )
self.do_x_to_y_notification_test(notify="successToException", previous_result=builder.SUCCESS, new_result=builder.SUCCESS,
expected_msg = "" )
self.do_x_to_y_notification_test(notify="successToException", previous_result=builder.SUCCESS, new_result=builder.FAILURE,
expected_msg = "" )
self.do_x_to_y_notification_test(notify="successToException", previous_result=builder.SUCCESS, new_result=builder.WARNINGS,
expected_msg = "" )
def _check3(ign):
self.failUnlessEqual(len(success_events), 1)
self.failUnlessEqual(len(finished_events), 1)
self.failUnlessIdentical(bss.__class__,
success_events[0].__class__)
self.failUnlessEqual(success_events[0].isFinished(), True)
self.failUnlessEqual(success_events[0].getResults(), FAILURE)
self.failUnlessEqual(finished_events[0].getResults(), FAILURE)
return flushEventualQueue()
d.addCallback(_check3)
r += " [%s]" % " ".join(b.getText())
self.reply(reply, r)
buildurl = self.status.getURLForThing(b)
if buildurl:
self.reply(reply, "Build details are at %s" % buildurl)
else:
users = b.getResponsibleUsers()
who = None
if users:
for user in users:
if not who:
who = user
else:
who += ', ' + user
for channel in self.channels:
if b.getResults() == FAILURE:
self.msg(channel, '%s: Your recent commit(s) might have broken the build of %s!' % (who, builder.getName()))
buildurl = self.status.getURLForThing(b)
if buildurl:
self.msg(channel, "Build details are at %s" % buildurl)
from buildbot.process.buildstep import LoggingBuildStep, LoggedRemoteCommand, LogLineObserver
from buildbot.status.builder import SUCCESS, FAILURE, WARNINGS, EXCEPTION #, SKIPPED
from buildbot.status.builder import TestResult
from buildbot.process.properties import WithProperties
from bbot_oe.step_iface import StepOE, ports_pool, dbnames_pool
import re
import logging
from openerp_libclient.utils import Pool
from twisted.python import log
blame_severities = { 'pywarn': 1, 'warning': 2, 'error': 3, 'exception': 4,
'critical': 8 , 'blocking': 10 }
# map blame severities to status.builder ones
res_severities = { 0: SUCCESS, 1: SUCCESS, 2: WARNINGS, 3: FAILURE,
4: EXCEPTION, 8: EXCEPTION, 10: EXCEPTION }
def append_fail(flist, blames, suffix=None, fmax=None):
""" Append blames to the flist, in order of severity
@param suffix add that to each blame added
@param max Don't let flist grow more than max
@return True if flist has changed
"""
found = False
for blame, bsev in blames:
fi = 0
while fi < len(flist):
if flist[fi][1] < bsev:
break
def evaluateCommand(self, cmd):
if self.incorrectLayoutLines or cmd.rc != 0:
return FAILURE
return SUCCESS
def evaluateCommand(self, cmd):
# warnings are in stdout, rc is always 0, unless the tools break
if cmd.rc != 0:
return FAILURE
if self.warnings:
return WARNINGS
return SUCCESS
def evaluateCommand(self, cmd):
state = 'pass'
res = SUCCESS
if cmd.rc != 0:
res = FAILURE
state = 'fail'
self.summaries[self.name]['state'] = state
# TODO: send the result to the db
return res
# if b.category != "prod":
# continue
lastnr = lastbuild.getNumber()
totalbuilds = 0
i = lastnr
while i >= 0:
build = b.getBuild(i)
i -= 1
if not build:
continue
results = build.getResults()
# only add entries for failed builds!
if results == FAILURE:
totalbuilds += 1
builds.append(build)
# stop for this builder when our total nr. of feeds is reached
if totalbuilds >= maxFeeds:
break
# Sort build list by date, youngest first.
# builds.sort(key=lambda build: build.getTimes(), reverse=True)
# If you need compatibility with python < 2.4, use this for sorting instead:
# We apply Decorate-Sort-Undecorate
deco = [(build.getTimes(), build) for build in builds]
deco.sort()
deco.reverse()
builds = [build for (b1, build) in deco]
class RpmLint2(LoggedOEmixin, ShellCommand):
name = "RPM Lint Test"
description = ["Checking for RPM/SPEC issues"]
descriptionDone = ["Finished checking RPM/SPEC issues"]
haltOnFailure = False
warnOnFailure = True
renderables = [ 'specfile' ]
_command = ['/usr/bin/rpmlint' ]
known_strs = [ (r'(?P.+?): W: spelling-error (?P.+)$', WARNINGS,
{'module_from_fname': True, 'short': True, 'test_name': 'rpm spelling' }),
(r'(?P.+?): W: (?P.+)$', WARNINGS,
{'module_from_fname': True, 'short': True, 'test_name': 'rpmlint' }),
(r'(?P.+?): E: (?P.+)$', FAILURE,
{'module_from_fname': True, 'short': True, 'test_name': 'rpmlint' }),
(r'.*', SUCCESS),
]
def __init__(self, workdir=None, specfile=None, rpmfiles='RPMs',
part_subs=None, keeper_conf=None, command=_command, **kwargs):
""" performs an RPM Lint check at specfile + rpmfiles
@param rpmfiles the key to the RPMs property, will be looked up
in self.build.properties
@param specfile is a single filename
"""
kwargs.setdefault('logEnviron', False)
ShellCommand.__init__(self, command=command, workdir=workdir, **kwargs)
LoggedOEmixin.__init__(self, workdir=workdir, part_subs=part_subs, keeper_conf=keeper_conf, **kwargs)
self.remote_kwargs['workdir'] = self.workdir
def informative_formatter(self, mode, name, build, results, status):
# Get the standard message.
data = self.defaultMessage(mode, name, build, results, status)['body']
data += '\n' + '='*80 + '\n\n'
# Append additional information on the changes.
data += get_change_string(build)
# Append log files.
if self.num_lines:
data += 'LOGS:\n'
for logf in build.getLogs():
logStep = logf.getStep()
logStatus,_ = logStep.getResults()
if (self.only_failure_logs and logStatus != builder.FAILURE):
continue
trailingLines = logf.getText().splitlines()[-self.num_lines:]
data += "Last %d lines of '%s':\n" % (self.num_lines,
logf.getName())
data += '\t' + '\n\t'.join(trailingLines)
data += '\n\n'
return { 'body' : data,
'type' : 'plain' }