def GetFailedMessage(exceptions, stage='Build', internal=False, bot='daisy_spring-paladin'): """Returns a BuildFailureMessage object.""" tracebacks = [] for ex in exceptions: tracebacks.append( results_lib.RecordedTraceback(stage, stage, ex, str(ex))) reason = 'failure reason string' return failures_lib.BuildFailureMessage('Stage %s failed' % stage, tracebacks, internal, reason, bot)
def testAnnotateFailingBuilders(self): """Tests that _AnnotateFailingBuilders is free of syntax errors.""" stage = self.ConstructStage() failing = {'a'} inflight = {} failed_msg = failures_lib.BuildFailureMessage( 'message', [], True, 'reason', 'bot') status = manifest_version.BuilderStatus('failed', failed_msg, 'url') statuses = {'a' : status} no_stat = set() stage._AnnotateFailingBuilders(failing, inflight, no_stat, statuses)
def testUnpickleBuildStatus(self): """Tests that _UnpickleBuildStatus returns the correct values.""" failed_msg = failures_lib.BuildFailureMessage('you failed', ['traceback'], True, 'taco', 'bot') failed_input_status = manifest_version.BuilderStatus( constants.BUILDER_STATUS_FAILED, failed_msg) passed_input_status = manifest_version.BuilderStatus( constants.BUILDER_STATUS_PASSED, None) failed_output_status = self.manager._UnpickleBuildStatus( failed_input_status.AsPickledDict()) passed_output_status = self.manager._UnpickleBuildStatus( passed_input_status.AsPickledDict()) empty_string_status = self.manager._UnpickleBuildStatus('') self.assertEqual(failed_input_status.AsFlatDict(), failed_output_status.AsFlatDict()) self.assertEqual(passed_input_status.AsFlatDict(), passed_output_status.AsFlatDict()) self.assertTrue(empty_string_status.Failed())
def CreateBuildFailureMessage(overlays, builder_name, dashboard_url): """Creates a message summarizing the failures. Args: overlays: The overlays used for the build. builder_name: The name of the builder. dashboard_url: The URL of the build. Returns: A failures_lib.BuildFailureMessage object. """ internal = overlays in [ constants.PRIVATE_OVERLAYS, constants.BOTH_OVERLAYS ] details = [] tracebacks = tuple(results_lib.Results.GetTracebacks()) for x in tracebacks: if isinstance(x.exception, failures_lib.CompoundFailure): # We do not want the textual tracebacks included in the # stringified CompoundFailure instance because this will be # printed on the waterfall. ex_str = x.exception.ToSummaryString() else: ex_str = str(x.exception) # Truncate displayed failure reason to 1000 characters. ex_str = ex_str[:200] details.append('The %s stage failed: %s' % (x.failed_stage, ex_str)) if not details: details = ['cbuildbot failed'] # reason does not include builder name or URL. This is mainly for # populating the "failure message" column in the stats sheet. reason = ' '.join(details) details.append('in %s' % dashboard_url) msg = '%s: %s' % (builder_name, ' '.join(details)) return failures_lib.BuildFailureMessage(msg, tracebacks, internal, reason, builder_name)