<commit_before># Copyright 2013 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 os
import re
import urllib

from infra.libs.infra_types import freeze
from recipe_engine import recipe_api

INSTRUMENTATION_TESTS = freeze([
  {
    'test': 'AndroidWebViewTest',
    'gyp_target': 'android_webview_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.android_webview.shell',
        'apk': 'AndroidWebView.apk'
      },
      'isolate_file_path': 'android_webview/android_webview_test_apk.isolate',
    },
  },
  {
    'test': 'ChromeShellTest',
    'gyp_target': 'chrome_shell_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.chrome.shell',
        'apk': 'ChromeShell.apk',
      },
      'isolate_file_path': 'chrome/chrome_shell_test_apk.isolate',
    },
  },
  {
    'test': 'ContentShellTest',
    'gyp_target': 'content_shell_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.content_shell_apk',
        'apk': 'ContentShell.apk',
      },
      'isolate_file_path': 'content/content_shell_test_apk.isolate',
    },
  },
  {
    'test': 'ChromeSyncShellTest',
    'gyp_target': 'chrome_sync_shell_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.chrome.browser.sync',
        'apk': 'ChromeSyncShell.apk',
      },
    },
  },
  {
    'test': 'ChromotingTest',
    'gyp_target': 'remoting_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.chromoting',
        'apk': 'Chromoting.apk',
      },
    },
  },
])


class AndroidApi(recipe_api.RecipeApi):
  def __init__(self, **kwargs):
    super(AndroidApi, self).__init__(**kwargs)
    self._devices = None

  def get_config_defaults(self):
    return {
      'REVISION': self.m.properties.get('revision', '')
    }

  def get_env(self):
    return self.m.chromium.get_env()

  @property
  def devices(self):
    assert self._devices is not None,\
        'devices is only available after device_status_check()'
    return self._devices

  @property
  def out_path(self):
    return self.m.path['checkout'].join('out')

  @property
  def coverage_dir(self):
    return self.out_path.join(self.c.BUILD_CONFIG, 'coverage')

  def configure_from_properties(self, config_name, **kwargs):
    self.set_config(config_name, **kwargs)

  def make_zip_archive(self, step_name, archive_name, files=None,
                       preserve_paths=True, filters=None, **kwargs):
    """Creates and stores the archive file.

    Args:
      step_name: Name of the step.
      archive_name: Name of the archive file.
      files: If specified, only include files here instead of out/<target>.
      filters: List of globs to be included in the archive.
      preserve_paths: If True, files will be stored using the subdolders
        in the archive.
    """
    archive_args = ['--target', self.m.chromium.c.BUILD_CONFIG,
                    '--name', archive_name]

    # TODO(luqui): Clean up when these are covered by the external builders.
    if files:              # pragma: no cover
      archive_args.extend(['--files', ','.join(files)])
    if filters:
      archive_args.extend(['--filters', ','.join(filters)])
    if not preserve_paths: # pragma: no cover
      archive_args.append('--ignore-subfolder-names')

    self.m.python(
      step_name,
      str(self.m.path['build'].join(
          'scripts', 'slave', 'android', 'archive_build.py')),
      archive_args,
      infra_step=True,
      **kwargs
    )

  def init_and_sync(self, gclient_config='android_bare'):
    # TODO(sivachandra): Move the setting of the gclient spec below to an
    # internal config extension when they are supported by the recipe system.
    spec = self.m.gclient.make_config(gclient_config)
    spec.target_os = ['android']
    s = spec.solutions[0]
    s.name = self.c.deps_dir
    s.url = self.c.REPO_URL
    s.custom_deps = self.c.gclient_custom_deps or {}
    s.deps_file = self.c.deps_file
    s.custom_vars = self.c.gclient_custom_vars or {}
    s.managed = self.c.managed
    s.revision = self.c.revision
    spec.revisions = self.c.revisions

    self.m.gclient.break_locks()
    refs = self.m.properties.get('event.patchSet.ref')
    if refs:
      refs = [refs]
    result = self.m.bot_update.ensure_checkout(spec, refs=refs)
    if not result.json.output['did_run']:
      result = self.m.gclient.checkout(spec)

    # TODO(sivachandra): Manufacture gclient spec such that it contains "src"
    # solution + repo_name solution. Then checkout will be automatically
    # correctly set by gclient.checkout
    self.m.path['checkout'] = self.m.path['slave_build'].join('src')

    self.clean_local_files()<commit_msg>[Android] Expose with_branch_heads in api.chromium_android.init_and_sync.<commit_after># Copyright 2013 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 os
import re
import urllib

from infra.libs.infra_types import freeze
from recipe_engine import recipe_api

INSTRUMENTATION_TESTS = freeze([
  {
    'test': 'AndroidWebViewTest',
    'gyp_target': 'android_webview_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.android_webview.shell',
        'apk': 'AndroidWebView.apk'
      },
      'isolate_file_path': 'android_webview/android_webview_test_apk.isolate',
    },
  },
  {
    'test': 'ChromeShellTest',
    'gyp_target': 'chrome_shell_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.chrome.shell',
        'apk': 'ChromeShell.apk',
      },
      'isolate_file_path': 'chrome/chrome_shell_test_apk.isolate',
    },
  },
  {
    'test': 'ContentShellTest',
    'gyp_target': 'content_shell_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.content_shell_apk',
        'apk': 'ContentShell.apk',
      },
      'isolate_file_path': 'content/content_shell_test_apk.isolate',
    },
  },
  {
    'test': 'ChromeSyncShellTest',
    'gyp_target': 'chrome_sync_shell_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.chrome.browser.sync',
        'apk': 'ChromeSyncShell.apk',
      },
    },
  },
  {
    'test': 'ChromotingTest',
    'gyp_target': 'remoting_test_apk',
    'kwargs': {
      'install_apk': {
        'package': 'org.chromium.chromoting',
        'apk': 'Chromoting.apk',
      },
    },
  },
])


class AndroidApi(recipe_api.RecipeApi):
  def __init__(self, **kwargs):
    super(AndroidApi, self).__init__(**kwargs)
    self._devices = None

  def get_config_defaults(self):
    return {
      'REVISION': self.m.properties.get('revision', '')
    }

  def get_env(self):
    return self.m.chromium.get_env()

  @property
  def devices(self):
    assert self._devices is not None,\
        'devices is only available after device_status_check()'
    return self._devices

  @property
  def out_path(self):
    return self.m.path['checkout'].join('out')

  @property
  def coverage_dir(self):
    return self.out_path.join(self.c.BUILD_CONFIG, 'coverage')

  def configure_from_properties(self, config_name, **kwargs):
    self.set_config(config_name, **kwargs)

  def make_zip_archive(self, step_name, archive_name, files=None,
                       preserve_paths=True, filters=None, **kwargs):
    """Creates and stores the archive file.

    Args:
      step_name: Name of the step.
      archive_name: Name of the archive file.
      files: If specified, only include files here instead of out/<target>.
      filters: List of globs to be included in the archive.
      preserve_paths: If True, files will be stored using the subdolders
        in the archive.
    """
    archive_args = ['--target', self.m.chromium.c.BUILD_CONFIG,
                    '--name', archive_name]

    # TODO(luqui): Clean up when these are covered by the external builders.
    if files:              # pragma: no cover
      archive_args.extend(['--files', ','.join(files)])
    if filters:
      archive_args.extend(['--filters', ','.join(filters)])
    if not preserve_paths: # pragma: no cover
      archive_args.append('--ignore-subfolder-names')

    self.m.python(
      step_name,
      str(self.m.path['build'].join(
          'scripts', 'slave', 'android', 'archive_build.py')),
      archive_args,
      infra_step=True,
      **kwargs
    )

  def init_and_sync(self, gclient_config='android_bare',
                    with_branch_heads=False):
    # TODO(sivachandra): Move the setting of the gclient spec below to an
    # internal config extension when they are supported by the recipe system.
    spec = self.m.gclient.make_config(gclient_config)
    spec.target_os = ['android']
    s = spec.solutions[0]
    s.name = self.c.deps_dir
    s.url = self.c.REPO_URL
    s.custom_deps = self.c.gclient_custom_deps or {}
    s.deps_file = self.c.deps_file
    s.custom_vars = self.c.gclient_custom_vars or {}
    s.managed = self.c.managed
    s.revision = self.c.revision
    spec.revisions = self.c.revisions

    self.m.gclient.break_locks()
    refs = self.m.properties.get('event.patchSet.ref')
    if refs:
      refs = [refs]
    result = self.m.bot_update.ensure_checkout(
        spec, refs=refs, with_branch_heads=with_branch_heads)
    if not result.json.output['did_run']:
      result = self.m.gclient.checkout(spec)

    # TODO(sivachandra): Manufacture gclient spec such that it contains "src"
    # solution + repo_name solution. Then checkout will be automatically
    # correctly set by gclient.checkout
    self.m.path['checkout'] = self.m.path['slave_build'].join('src')

    self.clean_local_files()
{'fraction_non_alphanumeric': 0.12991121543014594, 'fraction_numerical': 0.001020512297173181, 'mean_word_length': 3.018040180401804, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3013737', 'n_tokens_mistral': 3343, 'n_tokens_neox': 3203, 'n_words': 690}