Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 import sys | |
| 8 | |
| 9 class Suppressor: | |
| 10 def __init__(self, os_name, path_to_files): | |
| 11 self.suppressions_filename = 'SUPPRESSIONS' | |
|
Lei Zhang
2015/04/02 23:16:20
class constant
Tom Sepez
2015/04/03 18:13:15
Done.
| |
| 12 self.platform_suppressions_filename = 'SUPPRESSIONS_%s' % os_name | |
| 13 self.suppression_list = self._ExtractSuppressions( | |
| 14 os.path.join(path_to_files, self.suppressions_filename)) | |
| 15 self.platform_suppression_list = self._ExtractSuppressions( | |
| 16 os.path.join(path_to_files, self.platform_suppressions_filename)) | |
| 17 | |
| 18 def _ExtractSuppressions(self, suppressions_filename): | |
| 19 with open(suppressions_filename) as f: | |
| 20 return [y for y in [x.split('#')[0].strip() for x in f.readlines()] if y] | |
| 21 | |
| 22 def IsSuppressed(self, input_filename): | |
| 23 if input_filename in self.suppression_list: | |
| 24 print ("Not running %s, found in %s file" % | |
| 25 (input_filename, self.suppressions_filename)) | |
| 26 return True | |
| 27 if input_filename in self.platform_suppression_list: | |
| 28 print ("Not running %s, found in %s file" % | |
| 29 (input_filename, self.platform_suppressions_filename)) | |
| 30 return True | |
| 31 return False | |
| 32 | |
| 33 | |
| 34 # Testing. | |
| 35 def main(argv): | |
| 36 if len(argv) != 3: | |
| 37 print "usaage: %s <test-file-name> <path-to-files>" % argv[0] | |
| 38 return 1 | |
| 39 if sys.platform.startswith('linux'): | |
| 40 os_name = 'linux' | |
| 41 elif sys.platform.startswith('win'): | |
| 42 os_name = 'win' | |
| 43 elif sys.platform.startswith('darwin'): | |
| 44 os_name = 'mac' | |
| 45 else: | |
| 46 print 'Confused, can not determine OS, aborting.' | |
| 47 return 1 | |
| 48 suppressor = Suppressor(os_name, argv[2]) | |
| 49 if suppressor.IsSuppressed(argv[1]): | |
| 50 print "Result was true" | |
| 51 return 0 | |
| 52 | |
| 53 | |
| 54 if __name__ == '__main__': | |
| 55 sys.exit(main(sys.argv)) | |
| OLD | NEW |