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

Side by Side Diff: testing/tools/gold.py

Issue 2629943002: Ensures that the gold output directory exists (Closed)
Patch Set: Fixed bug for failing pdfium_test runs Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | testing/tools/test_runner.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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()
OLDNEW
« no previous file with comments | « no previous file | testing/tools/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698