content/test/gpu/gpu_tests/skia_gold_integration_test_base.py
def _UploadTestResultToSkiaGold(self, image_name, screenshot, page):
    """Compares the given image using Skia Gold and uploads the result.

    No uploading is done if the test is being run in local run mode. Compares
    the given screenshot to baselines provided by Gold, raising an Exception if
    a match is not found.

    Args:
      image_name: the name of the image being checked.
      screenshot: the image being checked as a Telemetry Bitmap.
      page: the GPU PixelTestPage object for the test.
    """
    # Write screenshot to PNG file on local disk.
    png_temp_file = tempfile.NamedTemporaryFile(
        suffix='.png', dir=self._skia_gold_temp_dir).name
    image_util.WritePngFile(screenshot, png_temp_file)

    gpu_keys = self.GetGoldJsonKeys(page)
    gold_session = self.GetSkiaGoldSessionManager().GetSkiaGoldSession(
        gpu_keys, corpus=SKIA_GOLD_CORPUS)
    gold_properties = self.GetSkiaGoldProperties()
    use_luci = not (gold_properties.local_pixel_tests
                    or gold_properties.no_luci_auth)

    inexact_matching_args = page.matching_algorithm.GetCmdline()

    # TODO(skbug.com/12149): Remove this once Gold stops clobbering earlier
    # results when running retry steps.
    force_dryrun = False
    # "Retry without patch" steps automatically pass in a test filter, which
    # should be the only time these tests are run with a test filter on trybots.
    if (gold_properties.IsTryjobRun()
        and self.GetParsedCommandLineOptions().has_test_filter):
      force_dryrun = True

    status, error = gold_session.RunComparison(
        name=image_name,
        png_file=png_temp_file,
        inexact_matching_args=inexact_matching_args,
        use_luci=use_luci,
        force_dryrun=force_dryrun)
    if not status:
      return

    status_codes =\
        self.GetSkiaGoldSessionManager().GetSessionClass().StatusCodes
    if status == status_codes.AUTH_FAILURE:
      logging.error('Gold authentication failed with output %s', error)
    elif status == status_codes.INIT_FAILURE:
      logging.error('Gold initialization failed with output %s', error)
    elif status == status_codes.COMPARISON_FAILURE_REMOTE:
      # We currently don't have an internal instance + public mirror like the
      # general Chrome Gold instance, so just report the "internal" link, which
      # points to the correct instance.
      _, triage_link = gold_session.GetTriageLinks(image_name)
      if not triage_link:
        logging.error('Failed to get triage link for %s, raw output: %s',
                      image_name, error)
        logging.error('Reason for no triage link: %s',
                      gold_session.GetTriageLinkOmissionReason(image_name))
      elif gold_properties.IsTryjobRun():
        self.artifacts.CreateLink('triage_link_for_entire_cl', triage_link)
      else:
        self.artifacts.CreateLink('gold_triage_link', triage_link)
    elif status == status_codes.COMPARISON_FAILURE_LOCAL:
      logging.error('Local comparison failed. Local diff files:')
      _OutputLocalDiffFiles(gold_session, image_name)
    elif status == status_codes.LOCAL_DIFF_FAILURE:
      logging.error(
          'Local comparison failed and an error occurred during diff '
          'generation: %s', error)
      # There might be some files, so try outputting them.
      logging.error('Local diff files:')
      _OutputLocalDiffFiles(gold_session, image_name)
    else:
      logging.error(
          'Given unhandled SkiaGoldSession StatusCode %s with error %s', status,
          error)
    if self._ShouldReportGoldFailure(page):
      raise Exception(
          'goldctl command returned non-zero exit code, see above for details. '
          'This probably just means that the test produced an image that has '
          'not been triaged as positive.')
Compares the given image using Skia Gold and uploads the result.

    No uploading is done if the test is being run in local run mode. Compares
    the given screenshot to baselines provided by Gold, raising an Exception if
    a match is not found.

    Args:
      image_name: the name of the image being checked.
      screenshot: the image being checked as a Telemetry Bitmap.
      page: the GPU PixelTestPage object for the test.
    
Compares the given image using Skia Gold and uploads the result.
No uploading is done if the test is being run in local run mode. Compares
the given screenshot to baselines provided by Gold, raising an Exception if
a match is not found.
Compares the given image using Skia Gold and uploads the result . No uploading is done if the test is being run in local run mode . Compares the given screenshot to baselines provided by Gold raising an Exception if a match is not found .
def _UploadTestResultToSkiaGold(self, image_name, screenshot, page):
    png_temp_file = tempfile.NamedTemporaryFile(
        suffix='.png', dir=self._skia_gold_temp_dir).name
    image_util.WritePngFile(screenshot, png_temp_file)
    gpu_keys = self.GetGoldJsonKeys(page)
    gold_session = self.GetSkiaGoldSessionManager().GetSkiaGoldSession(
        gpu_keys, corpus=SKIA_GOLD_CORPUS)
    gold_properties = self.GetSkiaGoldProperties()
    use_luci = not (gold_properties.local_pixel_tests
                    or gold_properties.no_luci_auth)
    inexact_matching_args = page.matching_algorithm.GetCmdline()
    force_dryrun = False
    if (gold_properties.IsTryjobRun()
        and self.GetParsedCommandLineOptions().has_test_filter):
      force_dryrun = True
    status, error = gold_session.RunComparison(
        name=image_name,
        png_file=png_temp_file,
        inexact_matching_args=inexact_matching_args,
        use_luci=use_luci,
        force_dryrun=force_dryrun)
    if not status:
      return
    status_codes =\
        self.GetSkiaGoldSessionManager().GetSessionClass().StatusCodes
    if status == status_codes.AUTH_FAILURE:
      logging.error('Gold authentication failed with output %s', error)
    elif status == status_codes.INIT_FAILURE:
      logging.error('Gold initialization failed with output %s', error)
    elif status == status_codes.COMPARISON_FAILURE_REMOTE:
      _, triage_link = gold_session.GetTriageLinks(image_name)
      if not triage_link:
        logging.error('Failed to get triage link for %s, raw output: %s',
                      image_name, error)
        logging.error('Reason for no triage link: %s',
                      gold_session.GetTriageLinkOmissionReason(image_name))
      elif gold_properties.IsTryjobRun():
        self.artifacts.CreateLink('triage_link_for_entire_cl', triage_link)
      else:
        self.artifacts.CreateLink('gold_triage_link', triage_link)
    elif status == status_codes.COMPARISON_FAILURE_LOCAL:
      logging.error('Local comparison failed. Local diff files:')
      _OutputLocalDiffFiles(gold_session, image_name)
    elif status == status_codes.LOCAL_DIFF_FAILURE:
      logging.error(
          'Local comparison failed and an error occurred during diff '
          'generation: %s', error)
      logging.error('Local diff files:')
      _OutputLocalDiffFiles(gold_session, image_name)
    else:
      logging.error(
          'Given unhandled SkiaGoldSession StatusCode %s with error %s', status,
          error)
    if self._ShouldReportGoldFailure(page):
      raise Exception(
          'goldctl command returned non-zero exit code, see above for details. '
          'This probably just means that the test produced an image that has '
          'not been triaged as positive.')
def _UploadTestResultToSkiaGold ( self , image_name , screenshot , page ) : png_temp_file = tempfile . NamedTemporaryFile ( suffix = '.png' , dir = self . _skia_gold_temp_dir ) . name image_util . WritePngFile ( screenshot , png_temp_file ) gpu_keys = self . GetGoldJsonKeys ( page ) gold_session = self . GetSkiaGoldSessionManager ( ) . GetSkiaGoldSession ( gpu_keys , corpus = SKIA_GOLD_CORPUS ) gold_properties = self . GetSkiaGoldProperties ( ) use_luci = not ( gold_properties . local_pixel_tests or gold_properties . no_luci_auth ) inexact_matching_args = page . matching_algorithm . GetCmdline ( ) force_dryrun = False if ( gold_properties . IsTryjobRun ( ) and self . GetParsedCommandLineOptions ( ) . has_test_filter ) : force_dryrun = True status , error = gold_session . RunComparison ( name = image_name , png_file = png_temp_file , inexact_matching_args = inexact_matching_args , use_luci = use_luci , force_dryrun = force_dryrun ) if not status : return status_codes = self . GetSkiaGoldSessionManager ( ) . GetSessionClass ( ) . StatusCodes if status == status_codes . AUTH_FAILURE : logging . error ( 'Gold authentication failed with output %s' , error ) elif status == status_codes . INIT_FAILURE : logging . error ( 'Gold initialization failed with output %s' , error ) elif status == status_codes . COMPARISON_FAILURE_REMOTE : _ , triage_link = gold_session . GetTriageLinks ( image_name ) if not triage_link : logging . error ( 'Failed to get triage link for %s, raw output: %s' , image_name , error ) logging . error ( 'Reason for no triage link: %s' , gold_session . GetTriageLinkOmissionReason ( image_name ) ) elif gold_properties . IsTryjobRun ( ) : self . artifacts . CreateLink ( 'triage_link_for_entire_cl' , triage_link ) else : self . artifacts . CreateLink ( 'gold_triage_link' , triage_link ) elif status == status_codes . COMPARISON_FAILURE_LOCAL : logging . error ( 'Local comparison failed. Local diff files:' ) _OutputLocalDiffFiles ( gold_session , image_name ) elif status == status_codes . LOCAL_DIFF_FAILURE : logging . error ( 'Local comparison failed and an error occurred during diff ' 'generation: %s' , error ) logging . error ( 'Local diff files:' ) _OutputLocalDiffFiles ( gold_session , image_name ) else : logging . error ( 'Given unhandled SkiaGoldSession StatusCode %s with error %s' , status , error ) if self . _ShouldReportGoldFailure ( page ) : raise Exception ( 'goldctl command returned non-zero exit code, see above for details. ' 'This probably just means that the test produced an image that has ' 'not been triaged as positive.' )
Compares the given image using Skia Gold and uploads the result.
Compares the given image using Skia Gold and uploads the result .
"""Compares the given image using Skia Gold and uploads the result.

    No uploading is done if the test is being run in local run mode. Compares
    the given screenshot to baselines provided by Gold, raising an Exception if
    a match is not found.

    Args:
      image_name: the name of the image being checked.
      screenshot: the image being checked as a Telemetry Bitmap.
      page: the GPU PixelTestPage object for the test.
    """ # Write screenshot to PNG file on local disk. # TODO(skbug.com/12149): Remove this once Gold stops clobbering earlier # results when running retry steps. # "Retry without patch" steps automatically pass in a test filter, which # should be the only time these tests are run with a test filter on trybots. # We currently don't have an internal instance + public mirror like the # general Chrome Gold instance, so just report the "internal" link, which # points to the correct instance. # There might be some files, so try outputting them.
self
image_name
the name of the image being checked.
the name of the image being checked .
screenshot
the image being checked as a Telemetry Bitmap.
the image being checked as a Telemetry Bitmap .
page
the GPU PixelTestPage object for the test.
the GPU PixelTestPage object for the test .