Fix GPU pixel inexact matching
Re-enables GPU pixel test inexact matching, which was erroneously disabled when refactoring some code. This requires making the shared Skia Gold code accept an optional list of strings for extra arguments. Also drive-by fixes the OWNERS file for the shared code, as it was incorrectly using the @google.com account instead of the @chromium.org one. Bug: 1099423 Change-Id: Ie4005d3bc0c633b36f4a1328772a43d26c673707 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2268224 Auto-Submit: Brian Sheedy <bsheedy@chromium.org> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/master@{#782832} GitOrigin-RevId: 1af3ec97d41e92058ed3188f1bd1fedf4c331bba
This commit is contained in:
Родитель
fd46c4d6cd
Коммит
3a81878d28
|
@ -1 +1 @@
|
|||
bsheedy@google.com
|
||||
bsheedy@chromium.org
|
||||
|
|
|
@ -71,7 +71,12 @@ class SkiaGoldSession(object):
|
|||
self._authenticated = False
|
||||
self._initialized = False
|
||||
|
||||
def RunComparison(self, name, png_file, output_manager, use_luci=True):
|
||||
def RunComparison(self,
|
||||
name,
|
||||
png_file,
|
||||
output_manager,
|
||||
inexact_matching_args=None,
|
||||
use_luci=True):
|
||||
"""Helper method to run all steps to compare a produced image.
|
||||
|
||||
Handles authentication, itnitialization, comparison, and, if necessary,
|
||||
|
@ -80,10 +85,13 @@ class SkiaGoldSession(object):
|
|||
Args:
|
||||
name: The name of the image being compared.
|
||||
png_file: A path to a PNG file containing the image to be compared.
|
||||
output_manager: An output manager to use to store diff links. The
|
||||
output_manager: An output manager to use to store diff links. The
|
||||
argument's type depends on what type a subclasses' _StoreDiffLinks
|
||||
implementation expects. Can be None even if _StoreDiffLinks expects
|
||||
a valid input, but will fail if it ever actually needs to be used.
|
||||
inexact_matching_args: A list of strings containing extra command line
|
||||
arguments to pass to Gold for inexact matching. Can be omitted to use
|
||||
exact matching.
|
||||
use_luci: If true, authentication will use the service account provided by
|
||||
the LUCI context. If false, will attempt to use whatever is set up in
|
||||
gsutil, which is only supported for local runs.
|
||||
|
@ -101,7 +109,10 @@ class SkiaGoldSession(object):
|
|||
if init_rc:
|
||||
return self.StatusCodes.INIT_FAILURE, init_stdout
|
||||
|
||||
compare_rc, compare_stdout = self.Compare(name=name, png_file=png_file)
|
||||
compare_rc, compare_stdout = self.Compare(
|
||||
name=name,
|
||||
png_file=png_file,
|
||||
inexact_matching_args=inexact_matching_args)
|
||||
if not compare_rc:
|
||||
return self.StatusCodes.SUCCESS, None
|
||||
|
||||
|
@ -210,7 +221,7 @@ class SkiaGoldSession(object):
|
|||
self._initialized = True
|
||||
return rc, stdout
|
||||
|
||||
def Compare(self, name, png_file):
|
||||
def Compare(self, name, png_file, inexact_matching_args=None):
|
||||
"""Compares the given image to images known to Gold.
|
||||
|
||||
Triage links can later be retrieved using GetTriageLink().
|
||||
|
@ -218,6 +229,9 @@ class SkiaGoldSession(object):
|
|||
Args:
|
||||
name: The name of the image being compared.
|
||||
png_file: A path to a PNG file containing the image to be compared.
|
||||
inexact_matching_args: A list of strings containing extra command line
|
||||
arguments to pass to Gold for inexact matching. Can be omitted to use
|
||||
exact matching.
|
||||
|
||||
Returns:
|
||||
A tuple (return_code, output). |return_code| is the return code of the
|
||||
|
@ -242,6 +256,10 @@ class SkiaGoldSession(object):
|
|||
]
|
||||
if self._gold_properties.local_pixel_tests:
|
||||
compare_cmd.append('--dryrun')
|
||||
if inexact_matching_args:
|
||||
logging.info('Using inexact matching arguments for image %s: %s', name,
|
||||
inexact_matching_args)
|
||||
compare_cmd.extend(inexact_matching_args)
|
||||
|
||||
self._ClearTriageLinkFile()
|
||||
rc, stdout = self._RunCmdForRcAndOutput(compare_cmd)
|
||||
|
|
|
@ -144,6 +144,37 @@ class SkiaGoldSessionRunComparisonTest(fake_filesystem_unittest.TestCase):
|
|||
self.assertEqual(compare_mock.call_count, 1)
|
||||
self.assertEqual(diff_mock.call_count, 1)
|
||||
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Diff')
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Compare')
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Initialize')
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Authenticate')
|
||||
def test_compareInexactMatching(self, auth_mock, init_mock, compare_mock,
|
||||
diff_mock):
|
||||
auth_mock.return_value = (0, None)
|
||||
init_mock.return_value = (0, None)
|
||||
compare_mock.return_value = (0, None)
|
||||
diff_mock.return_value = (0, None)
|
||||
args = createSkiaGoldArgs(local_pixel_tests=False)
|
||||
sgp = skia_gold_properties.SkiaGoldProperties(args)
|
||||
keys_file = os.path.join(self._working_dir, 'keys.json')
|
||||
with open(os.path.join(self._working_dir, 'keys.json'), 'w') as f:
|
||||
json.dump({}, f)
|
||||
session = skia_gold_session.SkiaGoldSession(self._working_dir, sgp,
|
||||
keys_file, None, None)
|
||||
status, _ = session.RunComparison(None,
|
||||
None,
|
||||
None,
|
||||
inexact_matching_args=['--inexact'])
|
||||
self.assertEqual(status,
|
||||
skia_gold_session.SkiaGoldSession.StatusCodes.SUCCESS)
|
||||
self.assertEqual(auth_mock.call_count, 1)
|
||||
self.assertEqual(init_mock.call_count, 1)
|
||||
self.assertEqual(compare_mock.call_count, 1)
|
||||
self.assertEqual(diff_mock.call_count, 0)
|
||||
compare_mock.assert_called_with(name=None,
|
||||
png_file=mock.ANY,
|
||||
inexact_matching_args=['--inexact'])
|
||||
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Diff')
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Compare')
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, 'Initialize')
|
||||
|
@ -473,6 +504,17 @@ class SkiaGoldSessionCompareTest(fake_filesystem_unittest.TestCase):
|
|||
session.Compare(None, None)
|
||||
self.assertNotIn('--dryrun', cmd_mock.call_args[0][0])
|
||||
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, '_RunCmdForRcAndOutput')
|
||||
def test_commandWithInexactArgs(self, cmd_mock):
|
||||
cmd_mock.return_value = (None, None)
|
||||
args = createSkiaGoldArgs(git_revision='a')
|
||||
sgp = skia_gold_properties.SkiaGoldProperties(args)
|
||||
session = skia_gold_session.SkiaGoldSession(self._working_dir, sgp, None,
|
||||
None, None)
|
||||
session.Compare(None, None, inexact_matching_args=['--inexact', 'foobar'])
|
||||
self.assertIn('--inexact', cmd_mock.call_args[0][0])
|
||||
self.assertIn('foobar', cmd_mock.call_args[0][0])
|
||||
|
||||
@mock.patch.object(skia_gold_session.SkiaGoldSession, '_RunCmdForRcAndOutput')
|
||||
def test_commandCommonArgs(self, cmd_mock):
|
||||
cmd_mock.return_value = (None, None)
|
||||
|
|
Загрузка…
Ссылка в новой задаче