Sha256: bace0e03f1ee3e94c238cb08705b7a291de8c29b0646e65b524283bc26aa9141

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import hashlib

from recipe_engine import recipe_test_api

class GclientTestApi(recipe_test_api.RecipeTestApi):
  def output_json(self, projects, git_mode=False):
    """Deterministically synthesize json.output test data for gclient's
    --output-json option.

    Args:
      projects - a list of project paths (e.g. ['src', 'src/dependency'])
      git_mode - Return git hashes instead of svn revs.
    """
    # TODO(iannucci): Account for parent_got_revision_mapping. Right now the
    # synthesized json output from this method will always use
    # gen_revision(project), but if parent_got_revision and its ilk are
    # specified, we should use those values instead.
    return self.m.json.output({
      'solutions': dict(
        (p+'/', {'revision': self.gen_revision(p, git_mode)})
        for p in projects
      )
    })

  @staticmethod
  def gen_revision(project, GIT_MODE):
    """Hash project to bogus deterministic revision values."""
    h = hashlib.sha1(project)
    if GIT_MODE:
      return h.hexdigest()
    else:
      import struct
      return struct.unpack('!I', h.digest()[:4])[0] % 300000

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
libv8-5.2.361.43.1 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.2.361.43.0 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.1.281.59.1 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.1.281.59.0 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.1.281.59.0beta3 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.0.71.48.3 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.0.71.48.2 vendor/depot_tools/recipe_modules/gclient/test_api.py
libv8-5.0.71.48.0beta2 vendor/depot_tools/recipe_modules/gclient/test_api.py