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: |
| 11 | SUPPRESSIONS_FILENAME = 'SUPPRESSIONS' |
| 12 | PLATFORM_SUPPRESSIONS_FILENAME = 'SUPPRESSIONS_%s' % common.os_name() |
| 13 | |
| 14 | def __init__(self, finder): |
| 15 | testing_dir = finder.TestingDir() |
| 16 | self.suppression_list = self._ExtractSuppressions( |
| 17 | os.path.join(testing_dir, self.SUPPRESSIONS_FILENAME)) |
| 18 | self.platform_suppression_list = self._ExtractSuppressions( |
| 19 | os.path.join(testing_dir, self.PLATFORM_SUPPRESSIONS_FILENAME)) |
| 20 | |
| 21 | def _ExtractSuppressions(self, suppressions_filename): |
| 22 | with open(suppressions_filename) as f: |
| 23 | return [y for y in [x.split('#')[0].strip() for x in f.readlines()] if y] |
| 24 | |
| 25 | def IsSuppressed(self, input_filename): |
| 26 | if input_filename in self.suppression_list: |
| 27 | print ("Not running %s, found in %s file" % |
| 28 | (input_filename, self.SUPPRESSIONS_FILENAME)) |
| 29 | return True |
| 30 | if input_filename in self.platform_suppression_list: |
| 31 | print ("Not running %s, found in %s file" % |
| 32 | (input_filename, self.PLATFORM_SUPPRESSIONS_FILENAME)) |
| 33 | return True |
| 34 | return False |