| OLD | NEW |
| 1 # Copyright 2015 The PDFium Authors. All rights reserved. | 1 # Copyright 2015 The PDFium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import shlex | 8 import shlex |
| 9 import shutil | 9 import shutil |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 is used to set the top level fields in the output JSON file. | 60 is used to set the top level fields in the output JSON file. |
| 61 keyStr is a string with space separated key/value pairs that | 61 keyStr is a string with space separated key/value pairs that |
| 62 is used to set the 'key' field in the output JSON file. | 62 is used to set the 'key' field in the output JSON file. |
| 63 """ | 63 """ |
| 64 self._source_type = source_type | 64 self._source_type = source_type |
| 65 self._properties = self._parseKeyValuePairs(propertiesStr) | 65 self._properties = self._parseKeyValuePairs(propertiesStr) |
| 66 self._properties["key"] = self._parseKeyValuePairs(keyStr) | 66 self._properties["key"] = self._parseKeyValuePairs(keyStr) |
| 67 self._results = [] | 67 self._results = [] |
| 68 self._outputDir = outputDir | 68 self._outputDir = outputDir |
| 69 | 69 |
| 70 # make sure the output directory exists. |
| 71 if not os.path.exists(outputDir): |
| 72 os.makedirs(outputDir) |
| 73 |
| 70 def AddTestResult(self, testName, md5Hash, outputImagePath): | 74 def AddTestResult(self, testName, md5Hash, outputImagePath): |
| 71 # Copy the image to <output_dir>/<md5Hash>.<image_extension> | 75 # Copy the image to <output_dir>/<md5Hash>.<image_extension> |
| 72 imgExt = os.path.splitext(outputImagePath)[1].lstrip(".") | 76 imgExt = os.path.splitext(outputImagePath)[1].lstrip(".") |
| 73 if not imgExt: | 77 if not imgExt: |
| 74 raise ValueError("File %s does not have an extension" % outputImagePath) | 78 raise ValueError("File %s does not have an extension" % outputImagePath) |
| 75 newFilePath = os.path.join(self._outputDir, md5Hash + '.' + imgExt) | 79 newFilePath = os.path.join(self._outputDir, md5Hash + '.' + imgExt) |
| 76 shutil.copy2(outputImagePath, newFilePath) | 80 shutil.copy2(outputImagePath, newFilePath) |
| 77 | 81 |
| 78 # Add an entry to the list of test results | 82 # Add an entry to the list of test results |
| 79 self._results.append({ | 83 self._results.append({ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 # Create an instance and add results. | 121 # Create an instance and add results. |
| 118 propStr = """build_number 2 "builder name" Builder-Name gitHash a4a338179013b0
29d6dd55e737b5bd648a9fb68c""" | 122 propStr = """build_number 2 "builder name" Builder-Name gitHash a4a338179013b0
29d6dd55e737b5bd648a9fb68c""" |
| 119 | 123 |
| 120 keyStr = "arch arm64 compiler Clang configuration Debug" | 124 keyStr = "arch arm64 compiler Clang configuration Debug" |
| 121 | 125 |
| 122 gr = GoldResults("pdfium", testDir, propStr, keyStr) | 126 gr = GoldResults("pdfium", testDir, propStr, keyStr) |
| 123 gr.AddTestResult("test-1", "hash-1", os.path.join(testDir, "image1.png")) | 127 gr.AddTestResult("test-1", "hash-1", os.path.join(testDir, "image1.png")) |
| 124 gr.AddTestResult("test-2", "hash-2", os.path.join(testDir, "image2.png")) | 128 gr.AddTestResult("test-2", "hash-2", os.path.join(testDir, "image2.png")) |
| 125 gr.AddTestResult("test-3", "hash-3", os.path.join(testDir, "image3.png")) | 129 gr.AddTestResult("test-3", "hash-3", os.path.join(testDir, "image3.png")) |
| 126 gr.WriteResults() | 130 gr.WriteResults() |
| OLD | NEW |