Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _testConsumer_5(self, res, l2, s):
self.failUnlessEqual(s.chunks, [(builder.HEADER, "HEADER\n"),
(builder.STDOUT, 1000*"a"),
(builder.STDOUT, 600*"a"),
(builder.STDOUT, 1000*"b"),
(builder.STDOUT, 600*"b"),
(builder.STDOUT, 200*"c")])
l2.addStdout(1000*"c") # HEADER,1600*a,1600*b,1200*c on disk
self.failUnlessEqual(s.chunks, [(builder.HEADER, "HEADER\n"),
(builder.STDOUT, 1000*"a"),
(builder.STDOUT, 600*"a"),
(builder.STDOUT, 1000*"b"),
(builder.STDOUT, 600*"b"),
(builder.STDOUT, 200*"c"),
(builder.STDOUT, 1000*"c")])
l2.finish()
self.failUnlessEqual(s.chunks, [(builder.HEADER, "HEADER\n"),
(builder.STDOUT, 1000*"a"),
(builder.STDOUT, 600*"a"),
(builder.STDOUT, 1000*"b"),
(builder.STDOUT, 600*"b"),
(builder.STDOUT, 200*"c"),
(builder.STDOUT, 1000*"c")])
self.failIf(s.producer)
self.failUnless(s.finished)
def setupBuildStepStatus(basedir):
"""Return a BuildStep with a suitable BuildStepStatus object, ready to
use."""
os.mkdir(basedir)
botmaster = None
s0 = builder.Status(botmaster, basedir)
s1 = s0.builderAdded("buildername", "buildername")
s2 = builder.BuildStatus(s1, 1)
s3 = builder.BuildStepStatus(s2)
s3.setName("foostep")
s3.started = True
s3.stepStarted()
return s3
def testAddResults(self):
b = builder.BuildStatus(builder.BuilderStatus("test"), 12)
testname = ("buildbot", "test", "test_status", "Results",
"testAddResults")
r1 = builder.TestResult(name=testname,
results=builder.SUCCESS,
text=["passed"],
logs={'output': ""},
)
b.addTestResult(r1)
res = b.getTestResults()
self.failUnlessEqual(res.keys(), [testname])
t = res[testname]
self.failUnless(interfaces.ITestResult.providedBy(t))
self.failUnlessEqual(t.getName(), testname)
self.failUnlessEqual(t.getResults(), builder.SUCCESS)
self.failUnlessEqual(t.getText(), ["passed"])
self.failUnlessEqual(t.getLogs(), {'output': ""})
def _getFinishStatusText(self, code, elapsed):
meaning = builder.Results[code]
text = [self.name+":",
"upstream %s" % meaning,
"after %.1f sec" % elapsed]
if code != builder.SUCCESS:
text += self._getFullnames()
return text
def buildSetFinished(self, bss):
if not self.running:
return
if bss.getResults() == builder.SUCCESS:
ss = bss.getSourceStamp()
for w in self.successWatchers:
w(ss)
self.addCompleteLog('fail.%s' % type, '\n'.join(items) + '\n')
num_fails += len(items)
for type,items in xfailures.items():
self.addCompleteLog('xfail.%s' % type, '\n'.join(items) + '\n')
num_xfails += len(items)
for type,items in xpasses.items():
self.addCompleteLog('xpass.%s' % type, '\n'.join(items) + '\n')
num_xpasses += len(items)
self.setTestResults(total=(num_passes + num_fails + num_xfails +
num_xpasses),
failed=num_fails,
passed=num_passes + num_xpasses,
warnings=num_xfails + num_xpasses)
if num_fails:
return buildbot.status.builder.FAILURE
return buildbot.status.builder.SUCCESS
# FIXME: this getResults duplicity might need to be fixed
result = b.getResults()
if isinstance(b, build.BuildStatus):
result = b.getResults()
elif isinstance(b, buildstep.BuildStepStatus):
result = b.getResults()[0]
# after forcing a build, b.getResults() returns ((None, []), []), ugh
if isinstance(result, tuple):
result = result[0]
else:
raise TypeError("%r is not a BuildStatus or BuildStepStatus" % b)
if result is None:
# FIXME: this happens when a buildstep is running ?
return "running"
return builder.Results[result]
def ShouldRetryWithoutWarnings(step):
""" Determine whether the retry-without-warnings-as-errors step should
run. """
if not retry_without_werr_on_failure:
return False
gyp_or_compile_failed = False
retry_failed = False
no_warning_retry_failed = False
for build_step in step.build.getStatus().getSteps():
if (build_step.isFinished() and
build_step.getResults()[0] == builder.FAILURE):
if build_step.getName().startswith(_COMPILE_STEP_PREFIX):
gyp_or_compile_failed = True
elif build_step.getName().startswith(_COMPILE_RETRY_PREFIX):
retry_failed = True
elif build_step.getName().startswith(
_COMPILE_NO_WERR_PREFIX):
no_warning_retry_failed = True
# If we've already failed a previous retry without warnings, just give up.
if no_warning_retry_failed:
return False
# If we're retrying with clobber, only retry without warnings if a clobber
# retry has failed.
if maybe_retry_with_clobber:
return retry_failed
# Only run the retry if the initial compile has failed.
return gyp_or_compile_failed
def updateStepStatus(self, status):
"""Update current step status and annotation status based on a new event."""
self.annotate_status = BuilderStatus.combine(self.annotate_status, status)
last = self.sections[-1]
last['status'] = BuilderStatus.combine(last['status'], status)
if self.halt_on_failure and last['status'] in [
builder.FAILURE, builder.EXCEPTION]:
self.fixupLast()
self.command.finished(last['status'])
def getResultsClass(results, prevResults, inProgress, inBuilder):
"""Given the current and past results, return the class that will be used
by the css to display the right color for a box."""
if inProgress:
return "running"
if results is None:
if inBuilder:
return "notstarted"
else:
return "notinbuilder"
if results == builder.SUCCESS:
return "success"
if results == builder.WARNINGS:
return "warnings"
if results == builder.FAILURE:
if not prevResults:
# This is the bottom box. We don't know if the previous one failed
# or not. We assume it did not.
return "failure"
if prevResults != builder.FAILURE:
# This is a new failure.
return "failure"
else:
# The previous build also failed.