Commit fc2f5dd8 authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Workaround Gold diff issues

Works around two separate issues in the Gold Python code caused by
`goldctl diff` misbehaving:

1. Creates a copy of the working directory to pass to `goldctl diff`, as
   it currently clobbers the auth files in the given working directory.
2. Uses the public version of the Gold instance for `goldctl diff`, as
   authentication does not currently work for the non-public instance.

Bug: skia:10610, skia:10611, skia:10587
Change-Id: Idff3202c048f4e7baa986cfc8ad21fb918382603
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416861
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808197}
parent ad1cc52d
...@@ -47,10 +47,18 @@ class AndroidSkiaGoldSessionDiffTest(fake_filesystem_unittest.TestCase): ...@@ -47,10 +47,18 @@ class AndroidSkiaGoldSessionDiffTest(fake_filesystem_unittest.TestCase):
call_args = cmd_mock.call_args[0][0] call_args = cmd_mock.call_args[0][0]
self.assertIn('diff', call_args) self.assertIn('diff', call_args)
assertArgWith(self, call_args, '--corpus', 'corpus') assertArgWith(self, call_args, '--corpus', 'corpus')
assertArgWith(self, call_args, '--instance', 'instance') # TODO(skbug.com/10610): Remove the -public once we go back to using the
# non-public instance, or add a second test for testing that the correct
# instance is chosen if we decide to support both depending on what the
# user is authenticated for.
assertArgWith(self, call_args, '--instance', 'instance-public')
assertArgWith(self, call_args, '--input', 'png_file') assertArgWith(self, call_args, '--input', 'png_file')
assertArgWith(self, call_args, '--test', 'name') assertArgWith(self, call_args, '--test', 'name')
assertArgWith(self, call_args, '--work-dir', self._working_dir) # TODO(skbug.com/10611): Re-add this assert and remove the check for the
# absence of the directory once we switch back to using the proper working
# directory.
# assertArgWith(self, call_args, '--work-dir', self._working_dir)
self.assertNotIn(self._working_dir, call_args)
i = call_args.index('--out-dir') i = call_args.index('--out-dir')
# The output directory should be a subdirectory of the working directory. # The output directory should be a subdirectory of the working directory.
self.assertIn(self._working_dir, call_args[i + 1]) self.assertIn(self._working_dir, call_args[i + 1])
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import logging import logging
import os import os
import shutil
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
...@@ -325,25 +326,39 @@ class SkiaGoldSession(object): ...@@ -325,25 +326,39 @@ class SkiaGoldSession(object):
'tests locally.') 'tests locally.')
output_dir = self._CreateDiffOutputDir() output_dir = self._CreateDiffOutputDir()
diff_cmd = [ # TODO(skbug.com/10611): Remove this temporary work dir and instead just use
GOLDCTL_BINARY, # self._working_dir once `goldctl diff` stops clobbering the auth files in
'diff', # the provided work directory.
'--corpus', temp_work_dir = tempfile.mkdtemp()
self._corpus, # shutil.copytree() fails if the destination already exists, so use a
'--instance', # subdirectory of the temporary directory.
self._instance, temp_work_dir = os.path.join(temp_work_dir, 'diff_work_dir')
'--input', try:
png_file, shutil.copytree(self._working_dir, temp_work_dir)
'--test', diff_cmd = [
name, GOLDCTL_BINARY,
'--work-dir', 'diff',
self._working_dir, '--corpus',
'--out-dir', self._corpus,
output_dir, '--instance',
] # TODO(skbug.com/10610): Decide whether to use the public or
rc, stdout = self._RunCmdForRcAndOutput(diff_cmd) # non-public instance once authentication is fixed for the non-public
self._StoreDiffLinks(name, output_manager, output_dir) # instance.
return rc, stdout str(self._instance) + '-public',
'--input',
png_file,
'--test',
name,
'--work-dir',
temp_work_dir,
'--out-dir',
output_dir,
]
rc, stdout = self._RunCmdForRcAndOutput(diff_cmd)
self._StoreDiffLinks(name, output_manager, output_dir)
return rc, stdout
finally:
shutil.rmtree(os.path.realpath(os.path.join(temp_work_dir, '..')))
def GetTriageLinks(self, name): def GetTriageLinks(self, name):
"""Gets the triage links for the given image. """Gets the triage links for the given image.
......
...@@ -48,10 +48,18 @@ class GpuSkiaGoldSessionDiffTest(fake_filesystem_unittest.TestCase): ...@@ -48,10 +48,18 @@ class GpuSkiaGoldSessionDiffTest(fake_filesystem_unittest.TestCase):
call_args = cmd_mock.call_args[0][0] call_args = cmd_mock.call_args[0][0]
self.assertIn('diff', call_args) self.assertIn('diff', call_args)
assertArgWith(self, call_args, '--corpus', 'corpus') assertArgWith(self, call_args, '--corpus', 'corpus')
assertArgWith(self, call_args, '--instance', 'instance') # TODO(skbug.com/10610): Remove the -public once we go back to using the
# non-public instance, or add a second test for testing that the correct
# instance is chosen if we decide to support both depending on what the
# user is authenticated for.
assertArgWith(self, call_args, '--instance', 'instance-public')
assertArgWith(self, call_args, '--input', 'png_file') assertArgWith(self, call_args, '--input', 'png_file')
assertArgWith(self, call_args, '--test', 'name') assertArgWith(self, call_args, '--test', 'name')
assertArgWith(self, call_args, '--work-dir', self._working_dir) # TODO(skbug.com/10611): Re-add this assert and remove the check for the
# absence of the directory once we switch back to using the proper working
# directory.
# assertArgWith(self, call_args, '--work-dir', self._working_dir)
self.assertNotIn(self._working_dir, call_args)
i = call_args.index('--out-dir') i = call_args.index('--out-dir')
# The output directory should not be a subdirectory of the working # The output directory should not be a subdirectory of the working
# directory. # directory.
......
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