From fa05e97fc4d796bd12e21c32634d9614f8edf607 Mon Sep 17 00:00:00 2001 From: stephana Date: Mon, 2 Jan 2017 06:19:41 -0800 Subject: Gold support in PDFium Extends the PDFium tests to collect images and meta data to be uploaded to Gold. This feature is triggered by adding the --gold_* flags. It extends pdfium_test to output the MD5 hash of the underlying pixel buffer for each page it renders. That output is then processed by test_runner.py to generate the gold meta data. This behavior is modeled after the 'dm' tool in skia. See https://skia.googlesource.com/skia/+/master/dm/DM.cpp#1090 This should not cause any change in the current behavior of the tests, it will be trigger once we update the buildbot recipe. BUG=skia:5973 Review-Url: https://codereview.chromium.org/2578893004 --- testing/tools/common.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'testing/tools/common.py') diff --git a/testing/tools/common.py b/testing/tools/common.py index 1e1d257f48..a0cc946f1a 100755 --- a/testing/tools/common.py +++ b/testing/tools/common.py @@ -25,6 +25,24 @@ def RunCommand(cmd): except subprocess.CalledProcessError as e: return e +# RunCommandExtractHashedFiles returns a tuple: (raised_exception, hashed_files) +# It runs the given command. If it fails it will return an exception and None. +# If it succeeds it will return None and the list of processed files extracted +# from the output of the command. It expects lines in this format: +# MD5:: +# The returned hashed_files is a list of (file_path, MD5-hash) pairs. +def RunCommandExtractHashedFiles(cmd): + try: + output = subprocess.check_output(cmd, universal_newlines=True) + ret = [] + for line in output.split('\n'): + line = line.strip() + if line.startswith("MD5:"): + ret.append([x.strip() for x in line.lstrip("MD5:").rsplit(":", 1)]) + return None, ret + except subprocess.CalledProcessError as e: + return e, None + # Adjust Dr. Memory wrapper to have separate log directory for each test # for better error reporting. def DrMemoryWrapper(wrapper, pdf_name): -- cgit v1.2.3