Commit 7f3661fd authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Restrict manage_render_test_goldens to golden images

Restricts manage_render_test_goldens.py to only uploading images that
are expected to be golden images. This is achieved by looking for
device/SDK pairs in the filename.

This is to prevent random images that happen to be in the directory from
being uploaded when they shouldn't be.

Bug: 1022632
Change-Id: Iead7b574f38b73a88994d2a6e9f61fdcd72b4ea5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913571
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714769}
parent 2d97e5b1
......@@ -41,6 +41,11 @@ to the results_details/Render Results pages that you grabbed the new goldens
from. This will help reviewers confirm that the changes to the goldens are
acceptable.
If you add a new device/SDK combination that you expect golden images for, be
sure to add it to `ALLOWED_DEVICE_SDK_COMBINATIONS` in
`//chrome/test/data/android/manage_render_test_goldens.py`, otherwise the
goldens for it will not be uploaded.
### Failing locally
Follow the steps in [*Running the tests locally*](#running-the-tests-locally)
......
......@@ -34,6 +34,16 @@ GOLDEN_DIRECTORIES = [
'render_tests'),
]
# This is to prevent accidentally uploading random, non-golden images that
# might be in the directory.
ALLOWED_DEVICE_SDK_COMBINATIONS = [
# From RenderTestRule.java
'Nexus_5-19',
# For VR tests.
'Pixel_XL-25',
'Pixel_XL-26',
]
# Assume a quad core if we can't get the actual core count.
try:
......@@ -63,9 +73,20 @@ def download(directory):
def upload(directory):
def is_file_of_interest(f):
if not f.endswith('.png'):
return False
for combo in ALLOWED_DEVICE_SDK_COMBINATIONS:
if combo in f:
return True
return False
files_to_upload = []
for f in os.listdir(directory):
if f.endswith('.png'):
# Skip any files that we don't care about.
if not is_file_of_interest(f):
continue
png_path = os.path.join(directory, f)
# upload_to_google_storage will upload a file even if it already exists
# in the bucket. As an optimization, hash locally and only pass files to
......@@ -79,6 +100,7 @@ def upload(directory):
if sha_file.read() == h.hexdigest():
continue
files_to_upload.append(png_path)
if len(files_to_upload):
subprocess.check_call([
'upload_to_google_storage.py',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment