Tom Sepez | 30762ce | 2015-04-09 13:37:02 -0700 | [diff] [blame] | 1 | #!/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 | |
| 6 | import os |
| 7 | |
| 8 | import common |
| 9 | |
| 10 | class Suppressor: |
Tom Sepez | 30762ce | 2015-04-09 13:37:02 -0700 | [diff] [blame] | 11 | def __init__(self, finder): |
Tom Sepez | acfe9a7 | 2016-01-19 11:28:59 -0800 | [diff] [blame^] | 12 | 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 Sepez | 30762ce | 2015-04-09 13:37:02 -0700 | [diff] [blame] | 15 | |
Tom Sepez | acfe9a7 | 2016-01-19 11:28:59 -0800 | [diff] [blame^] | 16 | 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 Sepez | 30762ce | 2015-04-09 13:37:02 -0700 | [diff] [blame] | 32 | |
| 33 | def IsSuppressed(self, input_filename): |
Tom Sepez | acfe9a7 | 2016-01-19 11:28:59 -0800 | [diff] [blame^] | 34 | if input_filename in self.suppression_set: |
| 35 | print "%s is suppressed" % input_filename |
Tom Sepez | 30762ce | 2015-04-09 13:37:02 -0700 | [diff] [blame] | 36 | return True |
| 37 | return False |