From 6ce87f3e283a2cf44cacbcea7f0dc72633682b5b Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 3 Apr 2015 13:21:53 -0700 Subject: Refactor PDFium python test utilities. Extract a common portions for determining suppressions and comparing pngs. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1057983003 --- testing/tools/suppressor.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 testing/tools/suppressor.py (limited to 'testing/tools/suppressor.py') diff --git a/testing/tools/suppressor.py b/testing/tools/suppressor.py new file mode 100755 index 0000000000..fff9bc8381 --- /dev/null +++ b/testing/tools/suppressor.py @@ -0,0 +1,34 @@ +#!/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 common + +class Suppressor: + SUPPRESSIONS_FILENAME = 'SUPPRESSIONS' + PLATFORM_SUPPRESSIONS_FILENAME = 'SUPPRESSIONS_%s' % common.os_name() + + def __init__(self, finder): + testing_dir = finder.TestingDir() + self.suppression_list = self._ExtractSuppressions( + os.path.join(testing_dir, self.SUPPRESSIONS_FILENAME)) + self.platform_suppression_list = self._ExtractSuppressions( + os.path.join(testing_dir, 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 -- cgit v1.2.3