1
# Copyright (C) 2010 Google Inc. All rights reserved.
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions are
7
# * Redistributions of source code must retain the above copyright
8
# notice, this list of conditions and the following disclaimer.
9
# * Redistributions in binary form must reproduce the above
10
# copyright notice, this list of conditions and the following disclaimer
11
# in the documentation and/or other materials provided with the
13
# * Neither the name of Google Inc. nor the names of its
14
# contributors may be used to endorse or promote products derived from
15
# this software without specific prior written permission.
17
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
# FIXME: This probably belongs in the buildbot module.
31
class FailureMap(object):
35
def add_regression_window(self, builder, regression_window):
36
self._failures.append({
38
'regression_window': regression_window,
42
return not self._failures
44
def failing_revisions(self):
45
failing_revisions = [failure_info['regression_window'].revisions()
46
for failure_info in self._failures]
47
return sorted(set(sum(failing_revisions, [])))
49
def builders_failing_for(self, revision):
50
return self._builders_failing_because_of([revision])
52
def tests_failing_for(self, revision):
53
tests = [failure_info['regression_window'].failing_tests()
54
for failure_info in self._failures
55
if revision in failure_info['regression_window'].revisions()
56
and failure_info['regression_window'].failing_tests()]
59
result = result.union(test)
62
def failing_tests(self):
63
return set(sum([self.tests_failing_for(revision) for revision in self.failing_revisions()], []))
65
def _old_failures(self, is_old_failure):
66
return filter(lambda revision: is_old_failure(revision),
67
self.failing_revisions())
69
def _builders_failing_because_of(self, revisions):
70
revision_set = set(revisions)
71
return [failure_info['builder'] for failure_info in self._failures
72
if revision_set.intersection(
73
failure_info['regression_window'].revisions())]
75
# FIXME: We should re-process old failures after some time delay.
76
# https://bugs.webkit.org/show_bug.cgi?id=36581
77
def filter_out_old_failures(self, is_old_failure):
78
old_failures = self._old_failures(is_old_failure)
79
old_failing_builder_names = set([builder.name()
80
for builder in self._builders_failing_because_of(old_failures)])
82
# We filter out all the failing builders that could have been caused
83
# by old_failures. We could miss some new failures this way, but
84
# emperically, this reduces the amount of spam we generate.
85
failures = self._failures
86
self._failures = [failure_info for failure_info in failures
87
if failure_info['builder'].name() not in old_failing_builder_names]