Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: testing/tools/suppressor.py

Issue 1057983003: Refactor PDFium python test utilities. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Line wrap. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« testing/tools/run_corpus_tests.py ('K') | « testing/tools/run_pixel_tests.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/tools/suppressor.py
diff --git a/testing/tools/suppressor.py b/testing/tools/suppressor.py
new file mode 100755
index 0000000000000000000000000000000000000000..949a0b3b613e31343e83b3e39b3ef6b3ed3cc177
--- /dev/null
+++ b/testing/tools/suppressor.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+# Copyright 2015 The PDFium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import sys
+
+class Suppressor:
+ def __init__(self, os_name, path_to_files):
+ self.suppressions_filename = 'SUPPRESSIONS'
Lei Zhang 2015/04/02 23:16:20 class constant
Tom Sepez 2015/04/03 18:13:15 Done.
+ self.platform_suppressions_filename = 'SUPPRESSIONS_%s' % os_name
+ self.suppression_list = self._ExtractSuppressions(
+ os.path.join(path_to_files, self.suppressions_filename))
+ self.platform_suppression_list = self._ExtractSuppressions(
+ os.path.join(path_to_files, self.platform_suppressions_filename))
+
+ def _ExtractSuppressions(self, suppressions_filename):
+ with open(suppressions_filename) as f:
+ return [y for y in [x.split('#')[0].strip() for x in f.readlines()] if y]
+
+ def IsSuppressed(self, input_filename):
+ if input_filename in self.suppression_list:
+ print ("Not running %s, found in %s file" %
+ (input_filename, self.suppressions_filename))
+ return True
+ if input_filename in self.platform_suppression_list:
+ print ("Not running %s, found in %s file" %
+ (input_filename, self.platform_suppressions_filename))
+ return True
+ return False
+
+
+# Testing.
+def main(argv):
+ if len(argv) != 3:
+ print "usaage: %s <test-file-name> <path-to-files>" % argv[0]
+ return 1
+ if sys.platform.startswith('linux'):
+ os_name = 'linux'
+ elif sys.platform.startswith('win'):
+ os_name = 'win'
+ elif sys.platform.startswith('darwin'):
+ os_name = 'mac'
+ else:
+ print 'Confused, can not determine OS, aborting.'
+ return 1
+ suppressor = Suppressor(os_name, argv[2])
+ if suppressor.IsSuppressed(argv[1]):
+ print "Result was true"
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
« testing/tools/run_corpus_tests.py ('K') | « testing/tools/run_pixel_tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698