blob: f25db4564b3597d66f2a4bef406e0ca786be5e2e [file] [log] [blame]
Tom Sepez30762ce2015-04-09 13:37:02 -07001#!/usr/bin/env python
2# Copyright 2015 The PDFium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import os
7
8import common
9
10class Suppressor:
Tom Sepez30762ce2015-04-09 13:37:02 -070011 def __init__(self, finder):
Tom Sepezacfe9a72016-01-19 11:28:59 -080012 with open(os.path.join(finder.TestingDir(), 'SUPPRESSIONS')) as f:
13 self.suppression_set = set(self._FilterSuppressions(
14 common.os_name(), "v8", "xfa", self._ExtractSuppressions(f)))
Tom Sepez30762ce2015-04-09 13:37:02 -070015
Tom Sepezacfe9a72016-01-19 11:28:59 -080016 def _ExtractSuppressions(self, f):
17 return [y.split(' ') for y in
18 [x.split('#')[0].strip() for x in
19 f.readlines()] if y]
20
21 def _FilterSuppressions(self, os, js, xfa, unfiltered_list):
22 return [x[0] for x in unfiltered_list
23 if self._MatchSuppression(x, os, js, xfa)]
24
25 def _MatchSuppression(self, item, os, js, xfa):
26 os_column = item[1].split(",");
27 js_column = item[2].split(",");
28 xfa_column = item[3].split(",");
29 return (('*' in os_column or os in os_column) and
30 ('*' in js_column or js in js_column) and
31 ('*' in xfa_column or xfa in xfa_column))
Tom Sepez30762ce2015-04-09 13:37:02 -070032
33 def IsSuppressed(self, input_filename):
Tom Sepezacfe9a72016-01-19 11:28:59 -080034 if input_filename in self.suppression_set:
35 print "%s is suppressed" % input_filename
Tom Sepez30762ce2015-04-09 13:37:02 -070036 return True
37 return False