Пример #1
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-package',
        help='Application package name, if running tests on Android.')
    parser.add_option('-r',
                      '--revision',
                      type='string',
                      default=None,
                      help='Chromium revision')
    options, _ = parser.parse_args()

    if options.android_package:
        Download()
    else:
        if options.revision is None:
            parser.error('Must supply a --revision')

        platform = util.GetPlatformName()
        if 'linux' in platform:
            Archive(options.revision)

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

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

    if not options.android_package and passed:
        MaybeRelease(options.revision)
def KillChromes():
    chrome_map = {
        'win': 'chrome.exe',
        'mac': 'Chromium',
        'linux': 'chrome',
    }
    if util.IsWindows():
        cmd = ['taskkill', '/F', '/IM']
    else:
        cmd = ['killall', '-9']
    cmd.append(chrome_map[util.GetPlatformName()])
    util.RunCommand(cmd)
Пример #3
0
def MaybeRelease(revision):
  # Version is embedded as: const char kChromeDriverVersion[] = "0.1";
  with open(os.path.join(_THIS_DIR, 'chrome', 'version.cc'), 'r') as f:
    version_line = filter(lambda x: 'kChromeDriverVersion' in x, f.readlines())
  version = version_line[0].split('"')[1]

  bitness = '32'
  if util.IsLinux():
    bitness = '64'
  zip_name = 'chromedriver2_%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

  print '@@@BUILD_STEP 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)
  if util.IsLinux() or util.IsMac():
    adb_commands = os.path.join(_THIS_DIR, 'chrome', 'adb_commands.py')
    f.write(adb_commands, 'adb_commands.py')
  f.close()

  cmd = [
    sys.executable,
    os.path.join(_THIS_DIR, 'third_party', 'googlecode',
                 'googlecode_upload.py'),
    '--summary', 'version of ChromeDriver2 r%s' % revision,
    '--project', 'chromedriver',
    '--user', '*****@*****.**',
    '--label', 'Release',
    zip_path
  ]
  with open(os.devnull, 'wb') as no_output:
    if subprocess.Popen(cmd, stdout=no_output, stderr=no_output).wait():
      print '@@@STEP_FAILURE@@@'
Пример #4
0
def main():
  chromedriver_map = {
    'win': 'chromedriver2.dll',
    'mac': 'chromedriver2.so',
    'linux': 'libchromedriver2.so',
  }
  chromedriver_name = chromedriver_map[util.GetPlatformName()]

  chrome_map = {
    'win': 'chrome.exe',
    'mac': 'Chromium.app/Contents/MacOS/Chromium',
    'linux': 'chrome',
  }
  chrome_name = chrome_map[util.GetPlatformName()]

  if util.IsWindows():
    cpp_tests_name = 'chromedriver2_tests.exe'
  else:
    cpp_tests_name = 'chromedriver2_tests'

  required_build_outputs = [chromedriver_name, chrome_name, cpp_tests_name]
  build_dir = chrome_paths.GetBuildDir(required_build_outputs)
  print 'Using build outputs from', build_dir

  chromedriver = os.path.join(build_dir, chromedriver_name)
  chrome = os.path.join(build_dir, chrome_name)
  cpp_tests = os.path.join(build_dir, cpp_tests_name)

  if util.IsLinux():
    # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
    # when chromedriver2.so is not a static build.
    _AppendEnvironmentPath('LD_LIBRARY_PATH', os.path.join(build_dir, 'lib'))
  elif util.IsWindows():
    # For Windows bots: add ant, java(jre) and the like to system path.
    _AddToolsToSystemPathForWindows()

  code1 = RunPythonTests(chromedriver, chrome)
  code2 = RunJavaTests(chromedriver, chrome)
  code3 = RunCppTests(cpp_tests)
  return code1 or code2 or code3
Пример #5
0
def Main():
    chromedriver_map = {
        'win': 'chromedriver2.dll',
        'mac': 'chromedriver2.so',
        'linux': 'libchromedriver2.so',
    }
    chromedriver = chromedriver_map[util.GetPlatformName()]
    build_dir = chrome_paths.GetBuildDir([chromedriver])
    chrome_binary = _FindChromeBinary(build_dir)
    if util.IsLinux():
        # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
        # when chromedriver2.so is not a static build.
        _AppendEnvironmentPath('LD_LIBRARY_PATH',
                               os.path.join(build_dir, 'lib'))
    elif util.IsWindows():
        # For Windows bots: add ant, java(jre) and the like to system path.
        _AddToolsToSystemPathForWindows()

    # Run python test for chromedriver.
    print '@@@BUILD_STEP chromedriver2_python_tests@@@'
    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'test.py'),
        os.path.join(build_dir, chromedriver),
    ]
    # Set the built chrome binary.
    if chrome_binary is not None:
        cmd.append(chrome_binary)
    if util.IsMac():
        # In Mac, chromedriver2.so is a 32-bit build, so run with the 32-bit python.
        os.environ['VERSIONER_PYTHON_PREFER_32_BIT'] = 'yes'
    code1 = util.RunCommand(cmd)
    if code1 != 0:
        print '@@@STEP_FAILURE@@@'

    # Run java tests for chromedriver.
    print '@@@BUILD_STEP chromedriver2_java_tests@@@'
    cmd = [
        sys.executable,
        os.path.join(_THIS_DIR, 'run_java_tests.py'),
        '--chromedriver_path=' + os.path.join(build_dir, chromedriver),
    ]
    # Set the built chrome binary.
    if chrome_binary is not None:
        cmd.append('--chrome_path=' + chrome_binary)
    code2 = util.RunCommand(cmd)
    if code2 != 0:
        print '@@@STEP_FAILURE@@@'

    return code1 or code2
Пример #6
0
def MaybeRelease(revision):
  # Version is embedded as: const char kChromeDriverVersion[] = "0.1";
  with open(os.path.join(_THIS_DIR, 'version.cc'), 'r') as f:
    version_line = filter(lambda x: 'kChromeDriverVersion' in x, f.readlines())
  version = version_line[0].split('"')[1]

  # This assumes the bitness of python is the same as the built ChromeDriver.
  bitness = '32'
  if sys.maxint > 2**32:
    bitness = '64'
  zip_name = 'experimental_chromedriver2_%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

  print '@@@BUILD_STEP 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', 'alpha version of ChromeDriver2 r%s' % revision,
    '--project', 'chromedriver',
    '--user', '*****@*****.**',
    '--label', 'Release-Alpha',
    zip_path
  ]
  if util.RunCommand(cmd):
    print '@@@STEP_FAILURE@@@'
Пример #7
0
def Main():
  print '@@@BUILD_STEP chromedriver2_tests@@@'
  chromedriver_map = {
    'win': 'chromedriver2.dll',
    'mac': 'chromedriver2.so',
    'linux': 'libchromedriver2.so',
  }
  chromedriver = chromedriver_map[util.GetPlatformName()]
  build_dir = chrome_paths.GetBuildDir([chromedriver])
  cmd = [
    sys.executable,
    os.path.join(_THIS_DIR, 'test.py'),
    os.path.join(build_dir, chromedriver),
  ]
  code = util.RunCommand(cmd)
  if code != 0:
    print '@@@STEP_FAILURE@@@'
  return code
Пример #8
0
def main():
  parser = optparse.OptionParser()
  parser.add_option(
      '-r', '--revision', type='string', default=None,
      help='Chromium revision')
  options, _ = parser.parse_args()
  if options.revision is None:
    parser.error('Must supply a --revision')

  platform = util.GetPlatformName()
  if 'linux' in platform:
    Archive(options.revision)
  cmd = [
    sys.executable,
    os.path.join(_THIS_DIR, 'run_all_tests.py'),
  ]
  passed = (util.RunCommand(cmd) == 0)
  if passed:
    MaybeRelease(options.revision)
Пример #9
0
    def InitTestFixture(install_build, update_builds, base_url, options):
        """Static method for passing command options to InstallTest.

    We do not instantiate InstallTest. Therefore, command arguments cannot be
    passed to its constructor. Since InstallTest needs to use these options,
    and using globals is not an option, this method can be used by the Main
    class to pass the arguments it parses onto InstallTest.

    Args:
      install_build: A string representing the Chrome build to be used for
                     install testing. Pass this argument only if testing
                     fresh install scenarios.
      update_builds: A list that contains the Chrome builds to be used for
                     testing update scenarios. Pass this argument only if
                     testing upgrade scenarios.
      base_url: Base url of the 'official chrome builds' page.
      options: A list that contains options to be passed to Chrome installer.
    """
        system = util.GetPlatformName()
        InstallTest._install_build = install_build
        InstallTest._update_builds = update_builds
        InstallTest._installer_options = options
        tempdir = util.MakeTempDir()
        builds = []
        if InstallTest._install_build:
            builds.append(InstallTest._install_build)
        if InstallTest._update_builds:
            builds.extend(InstallTest._update_builds)
        # Remove any duplicate build numbers.
        builds = list(frozenset(builds))
        for build in builds:
            url = '%s%s/%s/mini_installer.exe' % (base_url, build, system)
            installer_path = os.path.join(tempdir,
                                          'mini_installer_%s.exe' % build)
            InstallTest._installer_paths[build] = installer_path
            InstallTest._Download(url, installer_path)
        InstallTest._chrome_driver = os.path.join(tempdir, 'chromedriver.exe')
        url = '%s%s/%s/%s/chromedriver.exe' % (base_url, build, system,
                                               'chrome-win32.test')
        InstallTest._Download(url, InstallTest._chrome_driver)
Пример #10
0
def _Run(src_dir, java_tests_src_dir, test_filter, chromedriver_path,
         chrome_path):
    """Run the WebDriver Java tests and return the test results.

  Args:
    src_dir: the chromium source checkout directory.
    java_tests_src_dir: the java test source code directory.
    test_filter: the filter to use when choosing tests to run. Format is
        ClassName#testMethod.
    chromedriver_path: path to ChromeDriver exe.
    chrome_path: path to Chrome exe.

  Returns:
    A list of |TestResult|s.
  """
    test_dir = util.MakeTempDir()
    keystore_path = ('java', 'client', 'test', 'keystore')
    required_dirs = [
        keystore_path[:-1], ('javascript', ),
        ('third_party', 'closure', 'goog')
    ]
    for required_dir in required_dirs:
        os.makedirs(os.path.join(test_dir, *required_dir))

    test_jar = 'test-standalone.jar'
    shutil.copyfile(os.path.join(java_tests_src_dir, 'keystore'),
                    os.path.join(test_dir, *keystore_path))
    shutil.copytree(os.path.join(java_tests_src_dir, 'common'),
                    os.path.join(test_dir, 'common'))
    shutil.copyfile(os.path.join(java_tests_src_dir, test_jar),
                    os.path.join(test_dir, test_jar))

    sys_props = [
        'selenium.browser=chrome',
        'webdriver.chrome.driver=' + chromedriver_path
    ]
    if chrome_path is not None:
        sys_props += ['webdriver.chrome.binary=' + chrome_path]
    if test_filter != '' and test_filter != '*':
        classes = []
        methods = []
        cases = test_filter.split(',')
        for case in cases:
            parts = case.split('#')
            if len(parts) > 2:
                raise RuntimeError(
                    'Filter should be of form: SomeClass#testMethod')
            elif len(parts) == 2:
                methods += [parts[1]]
            if len(parts[0]) > 0:
                classes += [parts[0]]
        sys_props += ['only_run=' + ','.join(classes)]
        sys_props += ['method=' + ','.join(methods)]

    # Make a copy of chormedriver library, because java expects a different name.
    expected_chromedriver_map = {
        'win': 'chromedriver.dll',
        'mac': 'libchromedriver.jnilib',
        'linux': 'libchromedriver.so',
    }
    expected_chromedriver = expected_chromedriver_map[util.GetPlatformName()]
    expected_chromedriver_path = os.path.join(test_dir, expected_chromedriver)
    shutil.copyfile(chromedriver_path, expected_chromedriver_path)
    sys_props += ['java.library.path=' + test_dir]

    return _RunAntTest(test_dir,
                       'org.openqa.selenium.chrome.ChromeDriverTests',
                       test_jar, sys_props)
Пример #11
0
 def GetOS(self):
     return util.GetPlatformName()
Пример #12
0
def main():
    parser = optparse.OptionParser()
    parser.add_option(
        '',
        '--android-package',
        help='Application package name, 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()

    chromedriver_map = {
        'win': 'chromedriver2.dll',
        'mac': 'chromedriver2.so',
        'linux': 'libchromedriver2.so',
    }
    chromedriver_name = chromedriver_map[util.GetPlatformName()]

    chrome_map = {
        'win': 'chrome.exe',
        'mac': 'Chromium.app/Contents/MacOS/Chromium',
        'linux': 'chrome',
    }
    chrome_name = chrome_map[util.GetPlatformName()]

    if util.IsWindows():
        cpp_tests_name = 'chromedriver2_tests.exe'
        server_name = 'chromedriver2_server.exe'
    else:
        cpp_tests_name = 'chromedriver2_tests'
        server_name = 'chromedriver2_server'

    required_build_outputs = [chromedriver_name]
    if not options.android_package:
        required_build_outputs += [cpp_tests_name, server_name]
    build_dir = chrome_paths.GetBuildDir(required_build_outputs)
    print 'Using build outputs from', build_dir

    chromedriver = os.path.join(build_dir, chromedriver_name)
    chromedriver_server = os.path.join(build_dir, server_name)

    if util.IsLinux():
        # Set LD_LIBRARY_PATH to enable successful loading of shared object files,
        # when chromedriver2.so is not a static build.
        _AppendEnvironmentPath('LD_LIBRARY_PATH',
                               os.path.join(build_dir, 'lib'))
    elif util.IsWindows():
        # For Windows bots: add ant, java(jre) and the like to system path.
        _AddToolsToSystemPathForWindows()

    if options.android_package:
        os.environ['PATH'] += os.pathsep + os.path.join(_THIS_DIR, 'chrome')
        code1 = RunPythonTests(chromedriver,
                               android_package=options.android_package)
        code2 = RunJavaTests(chromedriver_server,
                             android_package=options.android_package)
        return code1 or code2
    else:
        chrome_tip_of_tree = os.path.join(build_dir, chrome_name)
        cpp_tests = os.path.join(build_dir, cpp_tests_name)

        chrome_26 = continuous_archive.DownloadChrome(
            continuous_archive.CHROME_26_REVISION, util.MakeTempDir())
        chrome_27 = continuous_archive.DownloadChrome(
            continuous_archive.CHROME_27_REVISION, util.MakeTempDir())
        chrome_path_versions = [
            {
                'path': chrome_tip_of_tree,
                'version': 'HEAD'
            },
            {
                'path': chrome_27,
                'version': '27'
            },
            {
                'path': chrome_26,
                'version': '26'
            },
        ]
        code = 0
        for chrome in chrome_path_versions:
            if options.chrome_version and chrome[
                    'version'] != options.chrome_version:
                continue

            code1 = RunPythonTests(chromedriver,
                                   chrome=chrome['path'],
                                   chrome_version=chrome['version'])
            code2 = RunJavaTests(chromedriver_server,
                                 chrome=chrome['path'],
                                 chrome_version=chrome['version'])
            code = code or code1 or code2
        return RunCppTests(cpp_tests) or code
Пример #13
0
 def GetPassedJavaTestFilter(self):
     return _EXPECTATIONS['GetPassedJavaTestFilter'](util.GetPlatformName(),
                                                     self._chrome_version)