Example #1
0
  def test_reasons_for_failure(self):
    cache = buildbot.DiskCache(self.cache_path)

    build = AlertBuilderTest.k_example_failing_build
    step = build['steps'][0]
    builder_name = build['builderName']
    master_url = 'https://build.chromium.org/p/chromium.lkgr'

    old_splitter_for_step = reasons_splitter.splitter_for_step

    split_step_invoked = [False]

    def mock_splitter_for_step(step):
      class MockSplitter(object):
        @classmethod
        def split_step(cls, step, build, builder_name, master_url):
          split_step_invoked[0] = True
          return {}

      return MockSplitter()

    try:
      reasons_splitter.splitter_for_step = mock_splitter_for_step

      alert_builder.reasons_for_failure(cache, step, build,
          builder_name, master_url)
      self.assertTrue(split_step_invoked[0])
      split_step_invoked[0] = False

      alert_builder.reasons_for_failure(cache, step, build,
          builder_name, master_url)
      self.assertFalse(split_step_invoked[0])
    finally:
      reasons_splitter.splitter_for_step = old_splitter_for_step
Example #2
0
  def test_reasons_for_failure_no_splitter(self):
    cache = buildbot.DiskCache(self.cache_path)

    build = AlertBuilderTest.k_example_failing_build
    step = build['steps'][0]
    builder_name = build['builderName']
    master_url = 'https://build.chromium.org/p/chromium.lkgr'

    old_splitter_for_step = reasons_splitter.splitter_for_step

    def mock_splitter_for_step(step):
      return None

    try:
      reasons_splitter.splitter_for_step = mock_splitter_for_step

      reasons = alert_builder.reasons_for_failure(cache, step, build,
          builder_name, master_url)
      self.assertTrue(not reasons)
    finally:
      reasons_splitter.splitter_for_step = old_splitter_for_step