OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The PDFium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 | 7 |
8 import common | 8 import common |
9 | 9 |
10 class Suppressor: | 10 class Suppressor: |
11 def __init__(self, finder): | 11 def __init__(self, finder, feature_string): |
| 12 feature_vector = feature_string.strip().split(",") |
| 13 v8_option = ["nov8", "v8"]["V8" in feature_vector] |
| 14 xfa_option = ["noxfa", "xfa"]["XFA" in feature_vector] |
12 with open(os.path.join(finder.TestingDir(), 'SUPPRESSIONS')) as f: | 15 with open(os.path.join(finder.TestingDir(), 'SUPPRESSIONS')) as f: |
13 self.suppression_set = set(self._FilterSuppressions( | 16 self.suppression_set = set(self._FilterSuppressions( |
14 common.os_name(), "v8", "xfa", self._ExtractSuppressions(f))) | 17 common.os_name(), v8_option, xfa_option, self._ExtractSuppressions(f))) |
15 | 18 |
16 def _ExtractSuppressions(self, f): | 19 def _ExtractSuppressions(self, f): |
17 return [y.split(' ') for y in | 20 return [y.split(' ') for y in |
18 [x.split('#')[0].strip() for x in | 21 [x.split('#')[0].strip() for x in |
19 f.readlines()] if y] | 22 f.readlines()] if y] |
20 | 23 |
21 def _FilterSuppressions(self, os, js, xfa, unfiltered_list): | 24 def _FilterSuppressions(self, os, js, xfa, unfiltered_list): |
22 return [x[0] for x in unfiltered_list | 25 return [x[0] for x in unfiltered_list |
23 if self._MatchSuppression(x, os, js, xfa)] | 26 if self._MatchSuppression(x, os, js, xfa)] |
24 | 27 |
25 def _MatchSuppression(self, item, os, js, xfa): | 28 def _MatchSuppression(self, item, os, js, xfa): |
26 os_column = item[1].split(","); | 29 os_column = item[1].split(","); |
27 js_column = item[2].split(","); | 30 js_column = item[2].split(","); |
28 xfa_column = item[3].split(","); | 31 xfa_column = item[3].split(","); |
29 return (('*' in os_column or os in os_column) and | 32 return (('*' in os_column or os in os_column) and |
30 ('*' in js_column or js in js_column) and | 33 ('*' in js_column or js in js_column) and |
31 ('*' in xfa_column or xfa in xfa_column)) | 34 ('*' in xfa_column or xfa in xfa_column)) |
32 | 35 |
33 def IsSuppressed(self, input_filename): | 36 def IsSuppressed(self, input_filename): |
34 if input_filename in self.suppression_set: | 37 if input_filename in self.suppression_set: |
35 print "%s is suppressed" % input_filename | 38 print "%s is suppressed" % input_filename |
36 return True | 39 return True |
37 return False | 40 return False |
OLD | NEW |