def testPrintBuildbotFunctionsWithMarker(self):
     """PrintBuildbot* with markers should be recognized by buildbot."""
     logging.EnableBuildbotMarkers()
     self.AssertLogContainsMsg(
         '@@@STEP_LINK@name@url@@@',
         lambda: logging.PrintBuildbotLink('name', 'url'),
         check_stderr=True)
     self.AssertLogContainsMsg(
         '@@@STEP_TEXT@text@@@',
         lambda: logging.PrintBuildbotStepText('text'),
         check_stderr=True)
     self.AssertLogContainsMsg('@@@STEP_WARNINGS@@@',
                               logging.PrintBuildbotStepWarnings,
                               check_stderr=True)
     self.AssertLogContainsMsg('@@@STEP_FAILURE@@@',
                               logging.PrintBuildbotStepFailure,
                               check_stderr=True)
     self.AssertLogContainsMsg(
         '@@@BUILD_STEP@name@@@',
         lambda: logging.PrintBuildbotStepName('name'),
         check_stderr=True)
     self.AssertLogContainsMsg(
         '@@@SET_BUILD_PROPERTY@name@"value"@@@',
         lambda: logging.PrintKitchenSetBuildProperty('name', 'value'),
         check_stderr=True)
 def testPrintBuildbotFunctionsNoMarker(self):
     """PrintBuildbot* without markers should not be recognized by buildbot."""
     self.AssertLogContainsMsg(
         '@@@STEP_LINK@',
         lambda: logging.PrintBuildbotLink('name', 'url'),
         check_stderr=True,
         invert=True)
     self.AssertLogContainsMsg(
         '@@@@STEP_TEXT@',
         lambda: logging.PrintBuildbotStepText('text'),
         check_stderr=True,
         invert=True)
     self.AssertLogContainsMsg('@@@STEP_WARNINGS@@@',
                               logging.PrintBuildbotStepWarnings,
                               check_stderr=True,
                               invert=True)
     self.AssertLogContainsMsg('@@@STEP_FAILURE@@@',
                               logging.PrintBuildbotStepFailure,
                               check_stderr=True,
                               invert=True)
     self.AssertLogContainsMsg(
         '@@@BUILD_STEP',
         lambda: logging.PrintBuildbotStepName('name'),
         check_stderr=True,
         invert=True)
     self.AssertLogContainsMsg('@@@SET_BUILD_PROPERTY',
                               lambda: logging.PrintKitchenSetBuildProperty(
                                   'name', {'a': 'value'}),
                               check_stderr=True,
                               invert=True)
  def _Begin(self):
    """Called before a stage is performed. May be overriden."""

    # Tell the buildbot we are starting a new step for the waterfall
    logging.PrintBuildbotStepName(self.name)

    self._PrintLoudly('Start Stage %s - %s\n\n%s' % (
        self.name, cros_build_lib.UserDateTimeFormat(), self.__doc__))
    def wrapped_functor(*args, **kwargs):
        try:
            logging.PrintBuildbotStepName(functor.__name__)
            result = functor(*args, **kwargs)
        except Exception:
            logging.PrintBuildbotStepFailure()
            raise

        if result:
            logging.PrintBuildbotStepFailure()
        return result
    def _BeginStepForBuildbot(self, tag=None):
        """Called before a stage is performed.

    Args:
      tag: Extra tag to add to the stage name on the waterfall.
    """
        waterfall_name = self.name
        if tag is not None:
            waterfall_name += tag
        logging.PrintBuildbotStepName(waterfall_name)

        self._PrintLoudly(
            'Start Stage %s - %s\n\n%s' %
            (self.name, cros_build_lib.UserDateTimeFormat(), self.__doc__))