Ejemplo n.º 1
0
def MaybeRelease(revision):
  # Version is embedded as: const char kChromeDriverVersion[] = "0.1";
  # Minimum supported Chrome version is embedded as:
  # const int kMinimumSupportedChromeVersion[] = {27, 0, 1453, 0};
  with open(os.path.join(_THIS_DIR, 'chrome', 'version.cc'), 'r') as f:
    lines = f.readlines()
    version_line = filter(lambda x: 'kChromeDriverVersion' in x, lines)
    chrome_min_version_line = filter(
        lambda x: 'kMinimumSupportedChromeVersion' in x, lines)
  version = version_line[0].split('"')[1]
  chrome_min_version = chrome_min_version_line[0].split('{')[1].split(',')[0]
  with open(os.path.join(chrome_paths.GetSrc(), 'chrome', 'VERSION'), 'r') as f:
    chrome_max_version = f.readlines()[0].split('=')[1]

  bitness = '32'
  if util.IsLinux() and platform.architecture()[0] == '64bit':
    bitness = '64'
  zip_name = 'chromedriver_%s%s_%s.zip' % (
      util.GetPlatformName(), bitness, version)

  site = 'https://code.google.com/p/chromedriver/downloads/list'
  s = urllib2.urlopen(site)
  downloads = s.read()
  s.close()

  if zip_name in downloads:
    return 0

  util.MarkBuildStepStart('releasing %s' % zip_name)
  if util.IsWindows():
    server_orig_name = 'chromedriver2_server.exe'
    server_name = 'chromedriver.exe'
  else:
    server_orig_name = 'chromedriver2_server'
    server_name = 'chromedriver'
  server = os.path.join(chrome_paths.GetBuildDir([server_orig_name]),
                        server_orig_name)

  print 'Zipping ChromeDriver server', server
  temp_dir = util.MakeTempDir()
  zip_path = os.path.join(temp_dir, zip_name)
  f = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
  f.write(server, server_name)
  f.close()

  cmd = [
      sys.executable,
      os.path.join(_THIS_DIR, 'third_party', 'googlecode',
                   'googlecode_upload.py'),
      '--summary',
      'ChromeDriver server for %s%s (v%s.%s.dyu) supports Chrome v%s-%s' % (
          util.GetPlatformName(), bitness, version, revision,
          chrome_min_version, chrome_max_version),
      '--project', 'chromedriver',
      '--user', '*****@*****.**',
      zip_path
  ]
  with open(os.devnull, 'wb') as no_output:
    if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait():
      util.MarkBuildStepError()
Ejemplo n.º 2
0
def _ArchiveGoodBuild(platform, commit_position):
  """Archive chromedriver binary if the build is green."""
  assert platform != 'android'
  util.MarkBuildStepStart('archive build')

  server_name = 'chromedriver'
  if util.IsWindows():
    server_name += '.exe'
  zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir([server_name]),
                                   server_name))

  build_name = 'chromedriver_%s_%s.%s.zip' % (
      platform, _GetVersion(), commit_position)
  build_url = '%s/%s' % (GS_CONTINUOUS_URL, build_name)
  if slave_utils.GSUtilCopy(zip_path, build_url):
    util.MarkBuildStepError()

  if util.IsWindows():
    zip_path = util.Zip(os.path.join(
        chrome_paths.GetBuildDir([server_name + '.pdb']), server_name + '.pdb'))
    pdb_name = 'chromedriver_%s_pdb_%s.%s.zip' % (
        platform, _GetVersion(), commit_position)
    pdb_url = '%s/%s' % (GS_CONTINUOUS_URL, pdb_name)
    if slave_utils.GSUtilCopy(zip_path, pdb_url):
      util.MarkBuildStepError()

  (latest_fd, latest_file) = tempfile.mkstemp()
  os.write(latest_fd, build_name)
  os.close(latest_fd)
  latest_url = '%s/latest_%s' % (GS_CONTINUOUS_URL, platform)
  if slave_utils.GSUtilCopy(latest_file, latest_url, mimetype='text/plain'):
    util.MarkBuildStepError()
  os.remove(latest_file)
Ejemplo n.º 3
0
def RunReplayTests(chromedriver,
                   chrome=None,
                   chrome_version=None,
                   chrome_version_name=None):
    version_info = ''
    if chrome_version_name:
        version_info = '(%s)' % chrome_version_name
    util.MarkBuildStepStart('replay_tests%s' % version_info)

    _, log_path = tempfile.mkstemp(prefix='chromedriver_log_')
    print 'chromedriver server log: %s' % log_path
    cmd = [
        sys.executable,
        os.path.join(_PARENT_DIR, 'log_replay', 'client_replay_test.py'),
        chromedriver,
        '--output-log-path=%s' % log_path
    ]
    if chrome:
        cmd.append('--chrome=%s' % chrome)
    if chrome_version:
        cmd.append('--chrome-version=%s' % chrome_version)
    code = util.RunCommand(cmd)

    if code:
        util.MarkBuildStepError()
    return code
Ejemplo n.º 4
0
def _AddToolsToPath(platform_name):
  """Add some tools like Ant and Java to PATH for testing steps to use."""
  paths = []
  error_message = ''
  if platform_name == 'win32':
    paths = [
        # Path to Ant and Java, required for the java acceptance tests.
        'C:\\Program Files (x86)\\Java\\ant\\bin',
        'C:\\Program Files (x86)\\Java\\jre\\bin',
    ]
    error_message = ('Java test steps will fail as expected and '
                     'they can be ignored.\n'
                     'Ant, Java or others might not be installed on bot.\n'
                     'Please refer to page "WATERFALL" on site '
                     'go/chromedriver.')
  if paths:
    util.MarkBuildStepStart('Add tools to PATH')
    path_missing = False
    for path in paths:
      if not os.path.isdir(path) or not os.listdir(path):
        print 'Directory "%s" is not found or empty.' % path
        path_missing = True
    if path_missing:
      print error_message
      util.MarkBuildStepError()
      return
    os.environ['PATH'] += os.pathsep + os.pathsep.join(paths)
Ejemplo n.º 5
0
def _MaybeUpdateLatestRelease(version):
  """Update the file LATEST_RELEASE with the latest release version number."""
  latest_release_fname = 'LATEST_RELEASE'
  latest_release_url = '%s/%s' % (GS_CHROMEDRIVER_BUCKET, latest_release_fname)

  # Check if LATEST_RELEASE is up to date.
  latest_released_version = _GetWebPageContent(
      '%s/%s' % (GS_CHROMEDRIVER_RELEASE_URL, latest_release_fname))
  if version == latest_released_version:
    return

  # Check if chromedriver was released on all supported platforms.
  supported_platforms = ['linux64', 'mac32', 'win32']
  for platform in supported_platforms:
    if not _WasReleased(version, platform):
      return

  util.MarkBuildStepStart('updating LATEST_RELEASE to %s' % version)

  temp_latest_release_fname = tempfile.mkstemp()[1]
  with open(temp_latest_release_fname, 'w') as f:
    f.write(version)
  if slave_utils.GSUtilCopy(temp_latest_release_fname, latest_release_url,
                            mimetype='text/plain'):
    util.MarkBuildStepError()
Ejemplo n.º 6
0
def _Release(build, platform):
  """Releases the given candidate build."""
  release_name = 'chromedriver_%s.zip' % platform
  util.MarkBuildStepStart('releasing %s' % release_name)
  slave_utils.GSUtilCopy(
      build, '%s/%s/%s' % (GS_CHROMEDRIVER_BUCKET, _GetVersion(), release_name))

  _MaybeUploadReleaseNotes()
Ejemplo n.º 7
0
def _DownloadPrebuilts():
  """Downloads the most recent prebuilts from google storage."""
  util.MarkBuildStepStart('Download latest chromedriver')

  zip_path = os.path.join(util.MakeTempDir(), 'build.zip')
  if gsutil_download.DownloadLatestFile(GS_PREBUILTS_URL, 'r', zip_path):
    util.MarkBuildStepError()

  util.Unzip(zip_path, chrome_paths.GetBuildDir(['host_forwarder']))
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    parser.add_option('-r', '--revision', type='int', help='Chromium revision')
    parser.add_option(
        '',
        '--update-log',
        action='store_true',
        help='Update the test results log (only applicable to Android)')
    options, _ = parser.parse_args()

    bitness = '32'
    if util.IsLinux() and platform_module.architecture()[0] == '64bit':
        bitness = '64'
    platform = '%s%s' % (util.GetPlatformName(), bitness)
    if options.android_packages:
        platform = 'android'

    if platform != 'android':
        _KillChromes()
    _CleanTmpDir()

    if platform == 'android':
        if not options.revision and options.update_log:
            parser.error('Must supply a --revision with --update-log')
        _DownloadPrebuilts()
    else:
        if not options.revision:
            parser.error('Must supply a --revision')
        if platform == 'linux64':
            _ArchivePrebuilts(options.revision)
        _WaitForLatestSnapshot(options.revision)

    _AddToolsToPath(platform)

    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'),
    ]
    if platform == 'android':
        cmd.append('--android-packages=' + options.android_packages)

    passed = (util.RunCommand(cmd) == 0)

    _ArchiveServerLogs()

    if platform == 'android':
        if options.update_log:
            util.MarkBuildStepStart('update test result log')
            _UpdateTestResultsLog(platform, options.revision, passed)
    elif passed:
        _ArchiveGoodBuild(platform, options.revision)
        _MaybeRelease(platform)
Ejemplo n.º 9
0
def _ArchivePrebuilts(commit_position):
  """Uploads the prebuilts to google storage."""
  util.MarkBuildStepStart('archive prebuilts')
  zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir(['chromedriver']),
                                   'chromedriver'))
  if slave_utils.GSUtilCopy(
      zip_path,
      '%s/%s' % (GS_PREBUILTS_URL, 'r%s.zip' % commit_position)):
    util.MarkBuildStepError()
Ejemplo n.º 10
0
def _WaitForLatestSnapshot(revision):
    util.MarkBuildStepStart('wait_for_snapshot')
    while True:
        snapshot_revision = archive.GetLatestSnapshotVersion()
        if int(snapshot_revision) >= int(revision):
            break
        util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                           (revision, snapshot_revision))
        time.sleep(60)
    util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision)
Ejemplo n.º 11
0
def DownloadChrome(version_name, revision, download_site):
  util.MarkBuildStepStart('download %s' % version_name)
  try:
    temp_dir = util.MakeTempDir()
    return (temp_dir, archive.DownloadChrome(revision, temp_dir, download_site))
  except Exception:
    traceback.print_exc()
    util.AddBuildStepText('Skip Java and Python tests')
    util.MarkBuildStepError()
    return (None, None)
Ejemplo n.º 12
0
def _ArchiveServerLogs():
    """Uploads chromedriver server logs to google storage."""
    util.MarkBuildStepStart('archive chromedriver server logs')
    for server_log in glob.glob(
            os.path.join(tempfile.gettempdir(), 'chromedriver_*')):
        base_name = os.path.basename(server_log)
        util.AddLink(base_name, '%s/%s' % (SERVER_LOGS_LINK, base_name))
        slave_utils.GSUtilCopy(server_log,
                               '%s/%s' % (GS_SERVER_LOGS_URL, base_name),
                               mimetype='text/plain')
Ejemplo n.º 13
0
def WaitForLatestSnapshot(revision):
    util.MarkBuildStepStart('wait_for_snapshot')
    while True:
        snapshot_revision = archive.GetLatestRevision(archive.Site.SNAPSHOT)
        if snapshot_revision >= revision:
            break
        util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                           (revision, snapshot_revision))
        time.sleep(60)
    util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision)
Ejemplo n.º 14
0
def _WaitForLatestSnapshot(commit_position):
    util.MarkBuildStepStart('wait_for_snapshot')
    while True:
        snapshot_position = archive.GetLatestSnapshotVersion()
        if commit_position is not None and snapshot_position is not None:
            if int(snapshot_position) >= int(commit_position):
                break
            util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                               (commit_position, snapshot_position))
        time.sleep(60)
    util.PrintAndFlush('Got snapshot commit position %s' % snapshot_position)
Ejemplo n.º 15
0
def RunPythonTests(chromedriver,
                   chrome=None,
                   android_package=None):
  util.MarkBuildStepStart('python_tests')
  code = util.RunCommand(
      _GenerateTestCommand('run_py_tests.py',
                           chromedriver,
                           chrome=chrome,
                           android_package=android_package))
  if code:
    util.MarkBuildStepError()
  return code
Ejemplo n.º 16
0
def RunJavaTests(chromedriver, chrome=None,
                 android_package=None,
                 verbose=False):
  util.MarkBuildStepStart('java_tests')
  code = util.RunCommand(
      _GenerateTestCommand('run_java_tests.py',
                           chromedriver,
                           chrome=chrome,
                           android_package=android_package,
                           verbose=verbose))
  if code:
    util.MarkBuildStepError()
  return code
Ejemplo n.º 17
0
def _WaitForLatestSnapshot(commit_position):
  util.MarkBuildStepStart('wait_for_snapshot')
  for attempt in range(0, 200):
    snapshot_position = archive.GetLatestSnapshotPosition()
    if commit_position is not None and snapshot_position is not None:
      if int(snapshot_position) >= int(commit_position):
        break
      util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                         (commit_position, snapshot_position))
    time.sleep(60)
  if int(snapshot_position) < int(commit_position):
    raise Exception('Failed to find a snapshot version >= %s' % commit_position)
  util.PrintAndFlush('Got snapshot commit position %s' % snapshot_position)
Ejemplo n.º 18
0
def _ArchiveGoodBuild(platform, revision):
  assert platform != 'android'
  util.MarkBuildStepStart('archive build')

  server_name = 'chromedriver'
  if util.IsWindows():
    server_name += '.exe'
  zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir([server_name]),
                                   server_name))

  build_url = '%s/chromedriver_%s_%s.%s.zip' % (
      GS_CONTINUOUS_URL, platform, _GetVersion(), revision)
  if slave_utils.GSUtilCopy(zip_path, build_url):
    util.MarkBuildStepError()
def RunJavaTests(chromedriver, chrome=None, chrome_version=None,
                 chrome_version_name=None, android_package=None):
  version_info = ''
  if chrome_version_name:
    version_info = '(v%s)' % chrome_version_name
  util.MarkBuildStepStart('java_tests%s' % version_info)
  code = util.RunCommand(
      _GenerateTestCommand('run_java_tests.py',
                           chromedriver,
                           ref_chromedriver=None,
                           chrome=chrome,
                           chrome_version=chrome_version,
                           android_package=android_package))
  if code:
    util.MarkBuildStepError()
  return code
Ejemplo n.º 20
0
def RunReplayTests(chromedriver, chrome):
  util.MarkBuildStepStart('replay_tests')

  _, log_path = tempfile.mkstemp(prefix='chromedriver_log_')
  print 'chromedriver server log: %s' % log_path
  cmd = [
    sys.executable,
    os.path.join(_PARENT_DIR, 'log_replay', 'client_replay_test.py'),
    chromedriver,
    chrome,
    '--output-log-path=%s' % log_path
  ]
  code = util.RunCommand(cmd)

  if code:
    util.MarkBuildStepError()
  return code
Ejemplo n.º 21
0
def _Release(build, version, platform):
  """Releases the given candidate build."""
  release_name = 'chromedriver_%s.zip' % platform
  util.MarkBuildStepStart('releasing %s' % release_name)
  temp_dir = util.MakeTempDir()
  slave_utils.GSUtilCopy(build, temp_dir)
  zip_path = os.path.join(temp_dir, os.path.basename(build))

  if util.IsLinux():
    util.Unzip(zip_path, temp_dir)
    server_path = os.path.join(temp_dir, 'chromedriver')
    util.RunCommand(['strip', server_path])
    zip_path = util.Zip(server_path)

  slave_utils.GSUtilCopy(
      zip_path, '%s/%s/%s' % (GS_CHROMEDRIVER_BUCKET, version, release_name))

  _MaybeUpdateLatestRelease(version)
Ejemplo n.º 22
0
def _WaitForLatestSnapshot(revision):
  util.MarkBuildStepStart('wait_for_snapshot')
  def _IsRevisionNumber(revision):
    if isinstance(revision, int):
      return True
    else:
      return revision.isdigit()
  while True:
    snapshot_revision = archive.GetLatestSnapshotVersion()
    if not _IsRevisionNumber(revision):
      revision = _GetSVNRevisionFromGitHash(revision)
    if not _IsRevisionNumber(snapshot_revision):
      snapshot_revision = _GetSVNRevisionFromGitHash(snapshot_revision)
    if revision is not None and snapshot_revision is not None:
      if int(snapshot_revision) >= int(revision):
        break
      util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
                         (revision, snapshot_revision))
    time.sleep(60)
  util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision)
Ejemplo n.º 23
0
def Download():
    util.MarkBuildStepStart('Download chromedriver prebuilts')

    temp_dir = util.MakeTempDir()
    zip_path = os.path.join(temp_dir, 'chromedriver2_prebuilts.zip')
    cmd = [
        sys.executable, DOWNLOAD_SCRIPT,
        '--url=%s' % GS_BUCKET,
        '--partial-name=%s' % GS_ZIP_PREFIX,
        '--dst=%s' % zip_path
    ]
    if util.RunCommand(cmd):
        util.MarkBuildStepError()

    build_dir = chrome_paths.GetBuildDir(['host_forwarder'])
    print 'Unzipping prebuilts %s to %s' % (zip_path, build_dir)
    f = zipfile.ZipFile(zip_path, 'r')
    f.extractall(build_dir)
    f.close()
    # Workaround for Python bug: http://bugs.python.org/issue15795
    os.chmod(os.path.join(build_dir, 'chromedriver2_server'), 0700)
Ejemplo n.º 24
0
def Archive(revision):
  util.MarkBuildStepStart('archive')
  prebuilts = ['chromedriver2_server',
               'chromedriver2_unittests', 'chromedriver2_tests']
  build_dir = chrome_paths.GetBuildDir(prebuilts[0:1])
  zip_name = '%s_r%s.zip' % (GS_ZIP_PREFIX, revision)
  temp_dir = util.MakeTempDir()
  zip_path = os.path.join(temp_dir, zip_name)
  print 'Zipping prebuilts %s' % zip_path
  f = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
  for prebuilt in prebuilts:
    f.write(os.path.join(build_dir, prebuilt), prebuilt)
  f.close()

  cmd = [
      sys.executable,
      UPLOAD_SCRIPT,
      '--source_filepath=%s' % zip_path,
      '--dest_gsbase=%s' % GS_BUCKET
  ]
  if util.RunCommand(cmd):
    util.MarkBuildStepError()
Ejemplo n.º 25
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--android-packages',
      help=('Comma separated list of application package names, '
            'if running tests on Android.'))
  parser.add_option(
      '-r', '--revision', help='Chromium git revision hash')
  parser.add_option(
      '', '--update-log', action='store_true',
      help='Update the test results log (only applicable to Android)')
  options, _ = parser.parse_args()

  bitness = '32'
  if util.Is64Bit():
    bitness = '64'
  platform = '%s%s' % (util.GetPlatformName(), bitness)
  if options.android_packages:
    platform = 'android'

  if not options.revision:
    commit_position = None
  else:
    commit_position = archive.GetCommitPositionFromGitHash(options.revision)
    if commit_position is None:
      raise Exception('Failed to convert revision to commit position')

  if platform == 'android':
    if not options.revision and options.update_log:
      parser.error('Must supply a --revision with --update-log')
    _DownloadPrebuilts()
  else:
    if not options.revision:
      parser.error('Must supply a --revision')
    if platform == 'linux64':
      _ArchivePrebuilts(commit_position)
    _WaitForLatestSnapshot(commit_position)

  _AddToolsToPath(platform)

  cmd = [
      sys.executable,
      os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'),
  ]
  if platform == 'android':
    cmd.append('--android-packages=' + options.android_packages)

  passed = (util.RunCommand(cmd) == 0)

  _ArchiveServerLogs()

  if platform == 'android':
    if options.update_log:
      util.MarkBuildStepStart('update test result log')
      _UpdateTestResultsLog(platform, commit_position, passed)
  elif passed:
    _ArchiveGoodBuild(platform, commit_position)
    _MaybeRelease(platform)

  if not passed:
    # Make sure the build is red if there is some uncaught exception during
    # running run_all_tests.py.
    util.MarkBuildStepStart('run_all_tests.py')
    util.MarkBuildStepError()

  # Add a "cleanup" step so that errors from runtest.py or bb_device_steps.py
  # (which invoke this script) are kept in their own build step.
  util.MarkBuildStepStart('cleanup')

  return 0 if passed else 1
Ejemplo n.º 26
0
def RunCppTests(cpp_tests):
    util.MarkBuildStepStart('chromedriver_tests')
    code = util.RunCommand([cpp_tests])
    if code:
        util.MarkBuildStepError()
    return code
Ejemplo n.º 27
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['51'] = '5a161bb6fe3d6bfbe2dafc0a7dd5831478f34277'
            versions['50'] = '4acbec91b57f31a501264906aded632cc64c9300'
            versions['49'] = '7acdedefe3ddcb27b3fc826027f519bdb5d04d7e'
        else:
            versions['51'] = '386266'
            versions['50'] = '378110'
            versions['49'] = '369932'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
Ejemplo n.º 28
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '', '--android-packages',
      help='Comma separated list of application package names, '
           'if running tests on Android.')
  # Option 'chrome-version' is for desktop only.
  parser.add_option(
      '', '--chrome-version',
      help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
           'Default is to run tests against all of these versions.'
           'Notice: this option only applies to desktop.')
  options, _ = parser.parse_args()

  exe_postfix = ''
  if util.IsWindows():
    exe_postfix = '.exe'
  cpp_tests_name = 'chromedriver_tests' + exe_postfix
  server_name = 'chromedriver' + exe_postfix

  required_build_outputs = [server_name]
  if not options.android_packages:
    required_build_outputs += [cpp_tests_name]
  try:
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
  except RuntimeError:
    util.MarkBuildStepStart('check required binaries')
    traceback.print_exc()
    util.MarkBuildStepError()
  constants.SetBuildType(os.path.basename(build_dir))
  print 'Using build outputs from', build_dir

  chromedriver = os.path.join(build_dir, server_name)
  platform_name = util.GetPlatformName()
  if util.IsLinux() and util.Is64Bit():
    platform_name += '64'
  ref_chromedriver = os.path.join(
      chrome_paths.GetSrc(),
      'chrome', 'test', 'chromedriver', 'third_party', 'java_tests',
      'reference_builds',
      'chromedriver_%s%s' % (platform_name, exe_postfix))

  if options.android_packages:
    os.environ['PATH'] += os.pathsep + os.path.join(
        _THIS_DIR, os.pardir, 'chrome')
    code = 0
    for package in options.android_packages.split(','):
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome_version_name=package,
                             android_package=package)
      code2 = RunJavaTests(chromedriver,
                           chrome_version_name=package,
                           android_package=package,
                           verbose=True)
      code = code or code1 or code2
    return code
  else:
    versions = {'HEAD': archive.GetLatestRevision()}
    if util.IsLinux() and not util.Is64Bit():
      # Linux32 builds need to be special-cased, because 1) they are keyed by
      # git hash rather than commit position, and 2) come from a different
      # download site (so we can't just convert the commit position to a hash).
      versions['63'] = 'adb61db19020ed8ecee5e91b1a0ea4c924ae2988'
      versions['62'] = '17030e3a08cfbb6e591991f7dbf0eb703454b365'
      versions['61'] = '77132a2bc78e8dc9ce411e8166bfd009f6476f6f'

      # TODO(samuong): speculative fix for crbug.com/611886
      os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'

    # Linux64 build numbers
    elif util.IsLinux():
      versions['65'] = '530372'
      versions['64'] = '520842'
      versions['63'] = '508578'

    # Mac build numbers
    elif util.IsMac():
      versions['65'] = '530368'
      versions['64'] = '520840'
      versions['63'] = '508578'

    # Windows build numbers
    elif util.IsWindows():
      versions['65'] = '530366'
      versions['64'] = '520840'
      versions['63'] = '508578'

    code = 0
    for version, revision in versions.iteritems():
      if options.chrome_version and version != options.chrome_version:
        continue
      download_site = archive.GetDownloadSite()
      version_name = version
      if version_name == 'HEAD':
        version_name = revision
      temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                             download_site)
      if not chrome_path:
        code = 1
        continue
      code1 = RunPythonTests(chromedriver,
                             ref_chromedriver,
                             chrome=chrome_path,
                             chrome_version=version,
                             chrome_version_name='v%s' % version_name)
      code2 = RunJavaTests(chromedriver, chrome=chrome_path,
                           chrome_version=version,
                           chrome_version_name='v%s' % version_name)
      code = code or code1 or code2
      _KillChromes()
      shutil.rmtree(temp_dir)
    cpp_tests = os.path.join(build_dir, cpp_tests_name)
    return RunCppTests(cpp_tests) or code
Ejemplo n.º 29
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and util.Is64Bit():
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        versions = {'HEAD': archive.GetLatestRevision()}
        if util.IsLinux() and not util.Is64Bit():
            # Linux32 builds need to be special-cased, because 1) they are keyed by
            # git hash rather than commit position, and 2) come from a different
            # download site (so we can't just convert the commit position to a hash).
            versions['55'] = 'e9bc4e0245c9a1e570ed2cf8e12152b9122275f2'
            versions['54'] = '13d140acdaa710770f42790044825b49f99e466c'
            versions['53'] = 'ac799c2fd50b8fb62b7a8186ff78b025de5b8718'
            # TODO(samuong): speculative fix for crbug.com/611886
            os.environ['CHROME_DEVEL_SANDBOX'] = '/opt/chromium/chrome_sandbox'
        else:
            versions['55'] = '423791'
            versions['54'] = '414545'
            versions['53'] = '403392'
        code = 0
        for version, revision in versions.iteritems():
            if options.chrome_version and version != options.chrome_version:
                continue
            download_site = archive.GetDownloadSite()
            version_name = version
            if version_name == 'HEAD':
                version_name = revision
            temp_dir, chrome_path = DownloadChrome(version_name, revision,
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version,
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version,
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code
Ejemplo n.º 30
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-packages',
        help='Comma separated list of application package names, '
        'if running tests on Android.')
    # Option 'chrome-version' is for desktop only.
    parser.add_option(
        '',
        '--chrome-version',
        help='Version of chrome, e.g., \'HEAD\', \'27\', or \'26\'.'
        'Default is to run tests against all of these versions.'
        'Notice: this option only applies to desktop.')
    options, _ = parser.parse_args()

    exe_postfix = ''
    if util.IsWindows():
        exe_postfix = '.exe'
    cpp_tests_name = 'chromedriver_tests' + exe_postfix
    server_name = 'chromedriver' + exe_postfix

    required_build_outputs = [server_name]
    if not options.android_packages:
        required_build_outputs += [cpp_tests_name]
    try:
        build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    except RuntimeError:
        util.MarkBuildStepStart('check required binaries')
        traceback.print_exc()
        util.MarkBuildStepError()
    constants.SetBuildType(os.path.basename(build_dir))
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, server_name)
    platform_name = util.GetPlatformName()
    if util.IsLinux() and platform.architecture()[0] == '64bit':
        platform_name += '64'
    ref_chromedriver = os.path.join(
        chrome_paths.GetSrc(), 'chrome', 'test', 'chromedriver', 'third_party',
        'java_tests', 'reference_builds',
        'chromedriver_%s%s' % (platform_name, exe_postfix))

    if options.android_packages:
        os.environ['PATH'] += os.pathsep + os.path.join(
            _THIS_DIR, os.pardir, 'chrome')
        code = 0
        for package in options.android_packages.split(','):
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome_version_name=package,
                                   android_package=package)
            code2 = RunJavaTests(chromedriver,
                                 chrome_version_name=package,
                                 android_package=package,
                                 verbose=True)
            code = code or code1 or code2
        return code
    else:
        latest_snapshot_revision = archive.GetLatestSnapshotVersion()
        versions = [
            ['HEAD', latest_snapshot_revision],
            ['49', archive.CHROME_49_REVISION],
            ['48', archive.CHROME_48_REVISION],
            ['47', archive.CHROME_47_REVISION],
        ]
        code = 0
        for version in versions:
            if options.chrome_version and version[0] != options.chrome_version:
                continue
            download_site = archive.Site.CONTINUOUS
            version_name = version[0]
            if version_name == 'HEAD':
                version_name = version[1]
                download_site = archive.GetSnapshotDownloadSite()
            temp_dir, chrome_path = DownloadChrome(version_name, version[1],
                                                   download_site)
            if not chrome_path:
                code = 1
                continue
            code1 = RunPythonTests(chromedriver,
                                   ref_chromedriver,
                                   chrome=chrome_path,
                                   chrome_version=version[0],
                                   chrome_version_name='v%s' % version_name)
            code2 = RunJavaTests(chromedriver,
                                 chrome=chrome_path,
                                 chrome_version=version[0],
                                 chrome_version_name='v%s' % version_name)
            code = code or code1 or code2
            _KillChromes()
            shutil.rmtree(temp_dir)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)
        return RunCppTests(cpp_tests) or code