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

Side by Side Diff: chrome/test/functional/ispy/common/ispy_utils.py

Issue 106523003: [I-Spy] Add support for rebaselining expectations from the web UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium 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 """Utilities for managing I-Spy test results in Google Cloud Storage.""" 5 """Internal utilities for managing I-Spy test results in Google Cloud Storage.
6
7 See the ispy.client.chrome_utils module for the external API.
8 """
6 9
7 import collections 10 import collections
8 import itertools 11 import itertools
9 import json 12 import json
10 import os 13 import os
11 import sys 14 import sys
12 15
13 import image_tools 16 import image_tools
14 17
15 18
(...skipping 14 matching lines...) Expand all
30 """Get the path to a failure file in the given test run and test. 33 """Get the path to a failure file in the given test run and test.
31 34
32 Args: 35 Args:
33 test_run: name of the test run. 36 test_run: name of the test run.
34 expectation: name of the expectation. 37 expectation: name of the expectation.
35 file_name: name of the file. 38 file_name: name of the file.
36 39
37 Returns: 40 Returns:
38 the path as a string relative to the bucket. 41 the path as a string relative to the bucket.
39 """ 42 """
40 return 'failures/%s/%s/%s' % (test_run, expectation, file_name) 43 return GetTestRunPath(test_run, '%s/%s' % (expectation, file_name))
44
45
46 def GetTestRunPath(test_run, file_name=''):
47 """Get the path to a the given test run.
48
49 Args:
50 test_run: name of the test run.
51 file_name: name of the file.
52
53 Returns:
54 the path as a string relative to the bucket.
55 """
56 return 'failures/%s/%s' % (test_run, file_name)
41 57
42 58
43 class ISpyUtils(object): 59 class ISpyUtils(object):
44 """Utility functions for working with an I-Spy google storage bucket.""" 60 """Utility functions for working with an I-Spy google storage bucket."""
45 61
46 def __init__(self, cloud_bucket): 62 def __init__(self, cloud_bucket):
47 """Initialize with a cloud bucket instance to supply GS functionality. 63 """Initialize with a cloud bucket instance to supply GS functionality.
48 64
49 Args: 65 Args:
50 cloud_bucket: An object implementing the cloud_bucket.BaseCloudBucket 66 cloud_bucket: An object implementing the cloud_bucket.BaseCloudBucket
(...skipping 27 matching lines...) Expand all
78 94
79 def UpdateImage(self, full_path, image): 95 def UpdateImage(self, full_path, image):
80 """Updates an existing image in GS, preserving permissions and metadata. 96 """Updates an existing image in GS, preserving permissions and metadata.
81 97
82 Args: 98 Args:
83 full_path: the path to the file in GS including the file extension. 99 full_path: the path to the file in GS including the file extension.
84 image: a RGB PIL.Image. 100 image: a RGB PIL.Image.
85 """ 101 """
86 self.cloud_bucket.UpdateFile(full_path, image_tools.EncodePNG(image)) 102 self.cloud_bucket.UpdateFile(full_path, image_tools.EncodePNG(image))
87 103
88
89 def GenerateExpectation(self, expectation, images): 104 def GenerateExpectation(self, expectation, images):
90 """Creates and uploads an expectation to GS from a set of images and name. 105 """Creates and uploads an expectation to GS from a set of images and name.
91 106
92 This method generates a mask from the uploaded images, then 107 This method generates a mask from the uploaded images, then
93 uploads the mask and first of the images to GS as a expectation. 108 uploads the mask and first of the images to GS as a expectation.
94 109
95 Args: 110 Args:
96 expectation: name for this expectation, any existing expectation with the 111 expectation: name for this expectation, any existing expectation with the
97 name will be replaced. 112 name will be replaced.
98 images: a list of RGB encoded PIL.Images 113 images: a list of RGB encoded PIL.Images
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 269
255 Args: 270 Args:
256 prefix: the prefix to filter files in GS by. 271 prefix: the prefix to filter files in GS by.
257 272
258 Returns: 273 Returns:
259 a list containing urls to all objects that started with 274 a list containing urls to all objects that started with
260 the prefix. 275 the prefix.
261 """ 276 """
262 return self.cloud_bucket.GetAllPaths(prefix) 277 return self.cloud_bucket.GetAllPaths(prefix)
263 278
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698