mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:21:18 +00:00
Revert "Adding webdriver setup script."
It seems to have caused Safari bot to not run any tests. See: http://build.chromium.org/p/client.dart/builders/web-safari-mac/builds/325 vs http://build.chromium.org/p/client.dart/builders/web-safari-mac/builds/326 Review URL: https://chromiumcodereview.appspot.com//9572007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4863 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
0930238061
commit
4533fbe58d
|
@ -1,89 +0,0 @@
|
|||
Overview:
|
||||
These are the instructions to run a wide variety of browser tests using
|
||||
test.dart --component=webdriver or
|
||||
dart/tools/testing/perf_testing/create_graph.py. Currently the results of
|
||||
create_graph are uploaded to https://dartperf.googleplex.com/.
|
||||
|
||||
============== Windows Setup ==============
|
||||
|
||||
Open Internet Explorer. Open the Internet Options dialog, and move to the
|
||||
"Security" tab. Click through Internet, Local Intranet, Trusted sites, and
|
||||
Restricted site and ensure the "Enable Protected Mode" is checked for all zones
|
||||
or unchecked for all zones. Then click to the "Advanced" tab, scroll down to the
|
||||
"Security" section, and check the checkbox "Allow active content to run in files
|
||||
on My Computer."
|
||||
|
||||
================ Mac Setup ================
|
||||
|
||||
1) Ensure Java is installed and in your path (if you want to run Safari). If
|
||||
not, install the Java jdk (so that we can run the webdriver server from its
|
||||
jar)
|
||||
|
||||
2) a) Disable pop-up blocking in Safari:
|
||||
Preferences -> Security -> (unselect) Block pop-up windows.
|
||||
b) copy the file in /Library/Preferences/com.apple.Safari.plist to
|
||||
$DARTDIR/tools/testing/com.apple.Safari.plist
|
||||
(We do this because Safari deletes our preferences (on no pop-up
|
||||
blocking) if it crashes (aka times out) two times in a row.)
|
||||
|
||||
============= All Platforms ================
|
||||
|
||||
THE EASISET WAY:
|
||||
1) Ensure Python 2.7 is installed and in your path.
|
||||
2) Download and install Chrome in the default location if you haven't done so
|
||||
already.
|
||||
3) Run the following script as root/administrator while standing in this
|
||||
directory:
|
||||
$> [sudo] python dart/tools/testing/perf_testing/webdriver_test_setup.py
|
||||
4) Profit!
|
||||
|
||||
Example Run:
|
||||
$> tools/test.py --component=webdriver --report --timeout=20 --mode=release
|
||||
--browser=[ff | safari | chrome | ie]
|
||||
[--frog=path/to/frog/executable/like/Release_ia32/dart-sdk/frogc
|
||||
--froglib=path/to/frog/lib/like/dart/frog/lib] test_to_run(like "language" or
|
||||
"corelib")
|
||||
|
||||
(If you don't specify frog and froglib arguments, we default to using frog with
|
||||
the VM.)
|
||||
|
||||
|
||||
============================================
|
||||
Okay, so you're still here? Here's the long version of what that script does if
|
||||
it didn't work for you:
|
||||
a) Install selenium library python bindings
|
||||
(http://pypi.python.org/pypi/selenium)
|
||||
|
||||
b) Ensure that Firefox is installed in the default location.
|
||||
|
||||
c) Download the Chrome Driver: http://code.google.com/p/chromium/downloads/list
|
||||
and make sure it is in your path.
|
||||
|
||||
d) Download the selenium server (version 2.15 or newer) and place it in this
|
||||
directory:
|
||||
http://selenium.googlecode.com/files/selenium-server-standalone-2.15.0.jar
|
||||
|
||||
|
||||
========= Proceed further only if you also want to run performance tests.======
|
||||
|
||||
10)Download appengine for Python and place it in third_party (http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Python):
|
||||
"dart/third_party/appengine-python/"
|
||||
|
||||
11)Install matplotlib http://matplotlib.sourceforge.net/
|
||||
|
||||
12)Pull down benchmarks from internal repo (Google only):
|
||||
http://chromegw.corp.google.com/viewvc/dash/trunk/internal/browserBenchmarks/README.txt?view=markup
|
||||
|
||||
13)TODO(efortuna): Deal with appengine check in! Run
|
||||
'../../../third_party/appengine-python/1.5.4/appcfg.py update appengine/'
|
||||
while standing in dart/tools/testing/perf_tests.
|
||||
|
||||
14) Run the tests! While standing in dart/tools/testing/perf_testing, run
|
||||
$> python create_graph.py --forever --verbose
|
||||
to run all the tests (browser performance, language correctness in the
|
||||
browser, command line performance, and self-hosted compile time and compiled
|
||||
code size).
|
||||
|
||||
You can run individual tests by adding the particular option (such as
|
||||
--language) when running create_graph.py. Type "create_graph.py -h" for a
|
||||
full list of the options.
|
|
@ -184,14 +184,7 @@ is 'dart file.dart' and you specify special command
|
|||
'Path to frog library',
|
||||
['--froglib'],
|
||||
[],
|
||||
''),
|
||||
new _TestOptionSpecification(
|
||||
'noBatch',
|
||||
'Do not run browser tests in batch mode',
|
||||
['-n', '--nobatch'],
|
||||
[],
|
||||
false,
|
||||
'bool')];
|
||||
'')];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -128,8 +128,6 @@ class TestCase {
|
|||
List<String> get batchTestArguments() => commands.last().arguments;
|
||||
|
||||
void completed() { completedHandler(this); }
|
||||
|
||||
bool get usesWebDriver() => configuration['component'] == 'webdriver';
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,8 +286,8 @@ class RunningProcess {
|
|||
for (var line in testCase.output.stdout) print(line);
|
||||
}
|
||||
if (allowRetries != null && allowRetries
|
||||
&& testCase.usesWebDriver && testCase.output.unexpectedOutput
|
||||
&& testCase.numRetries > 0) {
|
||||
&& testCase.configuration['component'] == 'webdriver' &&
|
||||
testCase.output.unexpectedOutput && testCase.numRetries > 0) {
|
||||
// Selenium tests can be flaky. Try rerunning.
|
||||
testCase.output.requestRetry = true;
|
||||
}
|
||||
|
@ -323,8 +321,8 @@ class RunningProcess {
|
|||
} else {
|
||||
stderr.add('test.dart: Compilion finished $suffix\n');
|
||||
stdout.add('test.dart: Compilion finished $suffix\n');
|
||||
if (currentStep == totalSteps - 1 && testCase.usesWebDriver &&
|
||||
!testCase.configuration['noBatch']) {
|
||||
if (currentStep == totalSteps - 1
|
||||
&& testCase.configuration['component'] == 'webdriver') {
|
||||
// Note: processQueue will always be non-null for component == webdriver
|
||||
// (It is only null for component == vm)
|
||||
processQueue._getBatchRunner(testCase).startTest(testCase);
|
||||
|
@ -402,7 +400,7 @@ class BatchRunnerProcess {
|
|||
BatchRunnerProcess(TestCase testCase) {
|
||||
_executable = testCase.commands.last().executable;
|
||||
_batchArguments = testCase.batchRunnerArguments;
|
||||
_isWebDriver = testCase.usesWebDriver;
|
||||
_isWebDriver = testCase.configuration['component'] == 'webdriver';
|
||||
}
|
||||
|
||||
bool get active() => _currentTest != null;
|
||||
|
@ -607,14 +605,7 @@ class ProcessQueue {
|
|||
* String indicating the browser used to run the tests. Empty if no browser
|
||||
* used.
|
||||
*/
|
||||
String browserUsed = '';
|
||||
/**
|
||||
* Process running the selenium server .jar (only used for Safari and Opera
|
||||
* tests.)
|
||||
*/
|
||||
Process _seleniumServer = null;
|
||||
/** True if we are in the process of starting the server. */
|
||||
bool _startingServer = false;
|
||||
String browserUsed;
|
||||
|
||||
ProcessQueue(int this._maxProcesses,
|
||||
String progress,
|
||||
|
@ -631,6 +622,7 @@ class ProcessQueue {
|
|||
_batchProcesses = new Map<String, List<BatchRunnerProcess>>(),
|
||||
_testCache = new Map<String, List<TestInformation>>() {
|
||||
if (!_enqueueMoreWork(this)) _progress.allDone();
|
||||
browserUsed = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -706,9 +698,6 @@ class ProcessQueue {
|
|||
void _cleanupAndMarkDone() {
|
||||
if (browserUsed != '') {
|
||||
killZombieBrowsers();
|
||||
if (_isSeleniumAvailable) {
|
||||
_seleniumServer.kill();
|
||||
}
|
||||
} else {
|
||||
_progress.allDone();
|
||||
}
|
||||
|
@ -747,92 +736,16 @@ class ProcessQueue {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* True if we are using a browser + platform combination that needs the
|
||||
* Selenium server jar.
|
||||
*/
|
||||
bool get _needsSelenium() => new Platform().operatingSystem() == 'macos' &&
|
||||
browserUsed == 'safari';
|
||||
|
||||
/** True if the Selenium Server is ready to be used. */
|
||||
bool get _isSeleniumAvailable() => _seleniumServer != null;
|
||||
|
||||
/** Start the Selenium Server jar, if appropriate for this platform. */
|
||||
void _ensureSeleniumServerRunning() {
|
||||
if (!_isSeleniumAvailable && _startingServer == false) {
|
||||
_startingServer = true;
|
||||
_startSeleniumServer();
|
||||
}
|
||||
}
|
||||
|
||||
void _runTest(TestCase test) {
|
||||
if (test.usesWebDriver) {
|
||||
if (test.configuration['component'] == 'webdriver') {
|
||||
browserUsed = test.configuration['browser'];
|
||||
if (_needsSelenium) _ensureSeleniumServerRunning();
|
||||
}
|
||||
_progress.testAdded();
|
||||
_tests.add(test);
|
||||
_tryRunTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor the output of the Selenium server, to know when we are ready to
|
||||
* begin running tests.
|
||||
* source: Output(Stream) from the Java server.
|
||||
*/
|
||||
Function makeSeleniumServerHandler(StringInputStream source) {
|
||||
return () {
|
||||
if (source.closed) return; // TODO(whesse): Remove when bug is fixed.
|
||||
var line = source.readLine();
|
||||
while (null != line) {
|
||||
if (const RegExp(@".*Started.*Server.*").hasMatch(line) ||
|
||||
const RegExp(@"Exception.*Selenium is already running.*").hasMatch(
|
||||
line)) {
|
||||
for (int i = 0; i < _maxProcesses; i++) {
|
||||
// Restart all the processes that have been waiting/stopped for
|
||||
// the server to start up. If we just call this once we end up
|
||||
// with a single-"threaded" run.
|
||||
_tryRunTest();
|
||||
}
|
||||
}
|
||||
line = source.readLine();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* For browser tests using Safari or Opera, we need to use the Selenium 1.0
|
||||
* Java server.
|
||||
*/
|
||||
void _startSeleniumServer() {
|
||||
// Get the absolute path to the Selenium jar.
|
||||
String filePath = new Options().script;
|
||||
String pathSep = new Platform().pathSeparator();
|
||||
int index = filePath.lastIndexOf(pathSep);
|
||||
filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}';
|
||||
var dir = new Directory(filePath);
|
||||
dir.onFile = (String file) {
|
||||
if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file)
|
||||
&& _seleniumServer == null) {
|
||||
_seleniumServer = new Process.start('java', ['-jar', file]);
|
||||
// Heads up: there seems to an obscure data race of some form in
|
||||
// the VM between launching the server process and launching the test
|
||||
// tasks that disappears when you read IO (which is convenient, since
|
||||
// that is our condition for knowing that the server is ready).
|
||||
StringInputStream stdoutStringStream =
|
||||
new StringInputStream(_seleniumServer.stdout);
|
||||
StringInputStream stderrStringStream =
|
||||
new StringInputStream(_seleniumServer.stderr);
|
||||
stdoutStringStream.onLine =
|
||||
makeSeleniumServerHandler(stdoutStringStream);
|
||||
stderrStringStream.onLine =
|
||||
makeSeleniumServerHandler(stderrStringStream);
|
||||
}
|
||||
};
|
||||
dir.list();
|
||||
}
|
||||
|
||||
void _terminateBatchRunners() {
|
||||
for (var runners in _batchProcesses.getValues()) {
|
||||
for (var runner in runners) {
|
||||
|
@ -872,12 +785,6 @@ class ProcessQueue {
|
|||
tab + Strings.join(test.commands.last().arguments, tab));
|
||||
return;
|
||||
}
|
||||
if (test.usesWebDriver && _needsSelenium && !_isSeleniumAvailable) {
|
||||
// The server is not ready to run Selenium tests. Put them back in the
|
||||
// queue.
|
||||
_tests.addFirst(test);
|
||||
return;
|
||||
}
|
||||
_progress.start(test);
|
||||
Function oldCallback = test.completedHandler;
|
||||
Function wrapper = (TestCase test_arg) {
|
||||
|
|
14
tools/testing/perf_testing/buildbot_browser_test_setup.sh
Normal file
14
tools/testing/perf_testing/buildbot_browser_test_setup.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
# Run to install the necessary components to run webdriver on the buildbots.
|
||||
# NOTE: YOU WILL NEED TO RUN THIS SCRIPT AS ROOT IN ORDER FOR IT TO SUCCESSFULLY
|
||||
# INSTALL COMPONENTS.
|
||||
|
||||
curl http://python-distribute.org/distribute_setup.py | sudo python
|
||||
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
|
||||
pip install -U selenium
|
||||
wget -O - http://releases.mozilla.org/pub/mozilla.org/firefox/releases/8.0.1/linux-x86_64/en-US/firefox-8.0.1.tar.bz2 | tar -C ~ -jxv
|
123
tools/testing/perf_testing/perf_README.txt
Normal file
123
tools/testing/perf_testing/perf_README.txt
Normal file
|
@ -0,0 +1,123 @@
|
|||
Setup to run all performance tests:
|
||||
|
||||
TODO(efortuna): run through these steps again on a clean machine to make sure I
|
||||
didn't leave anything out!
|
||||
|
||||
Overview:
|
||||
These are the instructions to run a wide variety of performance tests using
|
||||
dart/tools/testing/perf_testing/create_graph.py. Currently the results are
|
||||
uploaded to https://dartperf.googleplex.com/.
|
||||
|
||||
A variant of these tests are running on our buildbots to test Chrome and
|
||||
Firefox (since the buildbots are Linux) that simply ensure that no changes to
|
||||
frog have broken updating the dom, but not for testing performance.
|
||||
|
||||
This file details how to set up configurations for each setup. It is long,
|
||||
because there are many variants depending on what platform you're on, and what
|
||||
you want to set up.
|
||||
|
||||
============ Windows Installation =============
|
||||
|
||||
Setting up Windows on Mac hardware:
|
||||
If you need to install Windows 7 via dual-boot mac, use BootCamp to install
|
||||
Windows 7 Professional. You can obtain a copy of Windows 7 (Google internal)
|
||||
by getting an MSDN subscription via GUTS. When installing via BootCamp, don't
|
||||
forget to also install the "WindowsSupport" drivers that are optional --
|
||||
you'll need them to be able to connect to any wireless network in Windows.
|
||||
|
||||
Great! You have a shiny dual-booting machine!
|
||||
|
||||
Use the following instructions to set up for Windows builds:
|
||||
http://www.chromium.org/developers/how-tos/build-instructions-windows
|
||||
|
||||
NOTE: DO NOT USE Visual Studio 2010 to try to build the project!! Right now Dart
|
||||
only builds with VS2008 versions!
|
||||
|
||||
Then:
|
||||
1) Download installer for OpenSSL for Windows via
|
||||
http://openssl.org/related/binaries.html
|
||||
2) Install OpenSSL
|
||||
3) Copy the directory OpenSSL-Win32/include/openssl to
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include
|
||||
4) Copy the ***contents*** of the directory OpenSSL-Win32/lib/VC/static/ to
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib
|
||||
|
||||
============= All Platforms ================
|
||||
|
||||
1) Ensure Python 2.7 is installed and in your path.
|
||||
|
||||
2) Run the following command while standing in this directory:
|
||||
$> sudo buildbot_browser_test_setup.sh
|
||||
|
||||
If that doesn't work, or you're running Windows, here are the manual steps:
|
||||
a) Install selenium library python bindings
|
||||
(http://pypi.python.org/pypi/selenium)
|
||||
b) Ensure Firefox is installed.
|
||||
|
||||
3) Mac only:
|
||||
Download and install xcode 3.2:
|
||||
https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_3.2.6_and_ios_sdk_4.3__final/xcode_3.2.6_and_ios_sdk_4.3.dmg
|
||||
a) Mount dmg
|
||||
b) LION only: At a terminal type:
|
||||
TODO(efortuna): verify
|
||||
$> export COMMAND_LINE_INSTALL=1
|
||||
$> open "/Volumes/Xcode and iOS SDK/Xcode and iOS SDK.mpkg"
|
||||
c) Install.
|
||||
|
||||
4) (Mac OS Lion only) Install xcode 4.0 and then run:
|
||||
$> xcode-select -switch /path/to/xcode3.2.6/
|
||||
|
||||
5) Ensure Java is installed and in your path. If not, install the Java jdk
|
||||
(so that we can run the webdriver server from its jar)
|
||||
|
||||
6) Download selenium-server-standalone-2.15.0.jar (only to run Safari)
|
||||
http://selenium.googlecode.com/files/selenium-server-standalone-2.15.0.jar
|
||||
and run it:
|
||||
$> java -jar selenium-server-standalone-2.15.0.jar
|
||||
|
||||
7) Ensure that Chrome, Safari and IE (Windows only) are installed.
|
||||
|
||||
8)Download the Chrome Driver: http://code.google.com/p/chromium/downloads/list
|
||||
and make sure it is in your path.
|
||||
|
||||
9) a) Disable pop-up blocking in Safari:
|
||||
Preferences -> Security -> (unselect) Block pop-up windows.
|
||||
b) copy the file in /Library/Preferences/com.apple.Safari.plist to
|
||||
$DARTDIR/tools/testing/com.apple.Safari.plist
|
||||
(We do this because Safari deletes our preferences (on no pop-up
|
||||
blocking) if it crashes (aka times out) two times in a row.)
|
||||
|
||||
If you just want smoketests, you're done! Run them by typing:
|
||||
|
||||
$> tools/testing/bin/$YOUR_OS_DIR/dart tools/test.dart --component=webdriver
|
||||
--report --timeout=20 --mode=release --browser=[ff | safari | chrome | ie]
|
||||
[--frog=path/to/frog/executable/like/Release_ia32/dart-sdk/frogc
|
||||
--froglib=path/to/frog/lib/like/dart/frog/lib] test_to_run(like "language" or
|
||||
"corelib")
|
||||
|
||||
(If you don't specify frog and froglib arguments, we default to using the frogsh
|
||||
living in your frog directory.)
|
||||
|
||||
========= Proceed further only if you also want to run performance tests.======
|
||||
|
||||
10)Download appengine for Python and place it in third_party (http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Python):
|
||||
"dart/third_party/appengine-python/"
|
||||
|
||||
11)Install matplotlib http://matplotlib.sourceforge.net/
|
||||
|
||||
12)Pull down benchmarks from internal repo (Google only):
|
||||
http://chromegw.corp.google.com/viewvc/dash/trunk/internal/browserBenchmarks/README.txt?view=markup
|
||||
|
||||
13)TODO(efortuna): Deal with appengine check in! Run
|
||||
'../../../third_party/appengine-python/1.5.4/appcfg.py update appengine/'
|
||||
while standing in dart/tools/testing/perf_tests.
|
||||
|
||||
14) Run the tests! While standing in dart/tools/testing/perf_testing, run
|
||||
$> python create_graph.py --forever --verbose
|
||||
to run all the tests (browser performance, language correctness in the
|
||||
browser, command line performance, and self-hosted compile time and compiled
|
||||
code size).
|
||||
|
||||
You can run individual tests by adding the particular option (such as
|
||||
--language) when running create_graph.py. Type "create_graph.py -h" for a
|
||||
full list of the options.
|
|
@ -1,240 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
# Run to install the necessary components to run webdriver on the buildbots or
|
||||
# on your local machine.
|
||||
# Note: The setup steps can be done fairly easily by hand. This script is
|
||||
# intended to simply and reduce the time for setup since there are a fair number
|
||||
# of steps.
|
||||
|
||||
# TODO(efortuna): Rewrite this script in Dart when the Process module has a
|
||||
# better high level API.
|
||||
import optparse
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
def run_cmd(cmd, stdin=None):
|
||||
"""Run the command on the command line in the shell. We print the output of
|
||||
the command.
|
||||
"""
|
||||
print cmd
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE, shell=True)
|
||||
output, not_used = p.communicate(input=stdin)
|
||||
if output:
|
||||
print output
|
||||
|
||||
def parse_args():
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('--firefox', '-f', dest='firefox', help='Install Firefox',
|
||||
action='store_true', default=False)
|
||||
parser.add_option('--path', '-p', dest='path', help='Specify location ' + \
|
||||
'on your PATH for where we should install chromedriver (default is in' + \
|
||||
'depot_tools).', metavar='CHROMEDRIVER_LOC', type='str', action='store',
|
||||
default=None)
|
||||
parser.add_option('--buildbot', '-b', dest='buildbot', action='store_true',
|
||||
help='Perform a buildbot selenium setup (buildbots have a different' + \
|
||||
'location for their python executable).', default=False)
|
||||
args, ignored = parser.parse_args()
|
||||
return args
|
||||
|
||||
def find_depot_tools_location(is_buildbot):
|
||||
"""Depot_tools is our default install location for chromedriver, so we find
|
||||
its location on the filesystem.
|
||||
Arguments:
|
||||
is_buildbot - True if we are running buildbot machine setup (we can't detect
|
||||
this automatically because this script is not run at build time).
|
||||
"""
|
||||
if is_buildbot:
|
||||
depot_tools = os.path.join('b', 'depot_tools')
|
||||
if 'win32' in sys.platform or 'cygwin' in sys.platform:
|
||||
depot_tools = os.path.join('e:', depot_tools)
|
||||
depot_tools = '/Users/efortuna'
|
||||
return depot_tools
|
||||
else:
|
||||
path = os.environ['PATH'].split(os.pathsep)
|
||||
for loc in path:
|
||||
if 'depot_tools' in loc:
|
||||
return loc
|
||||
raise Exception("Could not find depot_tools in your path.")
|
||||
|
||||
|
||||
class GoogleCodeInstaller(object):
|
||||
"""Install code that is being hosted on Google Code."""
|
||||
|
||||
def __init__(self, project_name, download_location, download_name_func):
|
||||
""" Create a object that will install code from a Google Code site.
|
||||
Arguments:
|
||||
project_name - The GoogleCode project name such as "selenium" or "chromium."
|
||||
download_location - Where to download the desired file on our filesystem.
|
||||
download_name_func - A function that takes a dictionary (currently with keys
|
||||
"os" and "version", but more can be added) that calculates the string
|
||||
representing the name of the download we want.
|
||||
"""
|
||||
self.project_name = project_name
|
||||
self.download_location = download_location
|
||||
self.download_name_func = download_name_func
|
||||
self.download_regex_str = self.download_name_func({'os': self.get_os_str,
|
||||
'version': '.+'})
|
||||
|
||||
def google_code_downloads_page(self):
|
||||
return 'http://code.google.com/p/%s/downloads/list' % self.project_name
|
||||
|
||||
def google_code_download(self):
|
||||
return 'http://%s.googlecode.com/files/' % self.project_name
|
||||
|
||||
def find_latest_version(self):
|
||||
"""Find the latest version number of some code available for download on a
|
||||
Google code page. This was unfortunately done in an ad hoc manner because
|
||||
Google Code does not seem to have an API for their list of current
|
||||
downloads(!).
|
||||
"""
|
||||
google_code_site = self.google_code_downloads_page()
|
||||
f = urllib2.urlopen(google_code_site)
|
||||
latest = ''
|
||||
for line in f.readlines():
|
||||
if re.search(self.download_regex_str, line):
|
||||
suffix_index = line.find(
|
||||
self.download_regex_str[self.download_regex_str.rfind('.'):])
|
||||
name_end = self.download_regex_str.rfind('.+')
|
||||
name = self.download_name_func({'os': self.get_os_str, 'version': ''})
|
||||
name = name[:name.rfind('.')]
|
||||
version_str = line[line.find(name) + len(name) : suffix_index]
|
||||
if latest == '':
|
||||
latest = '0.' * version_str.count('.')
|
||||
latest += '0'
|
||||
nums = version_str.split('.')
|
||||
latest_nums = latest.split('.')
|
||||
for (num, latest_num) in zip(nums, latest_nums):
|
||||
if int(num) > int(latest_num):
|
||||
latest = version_str
|
||||
break
|
||||
if latest == '':
|
||||
raise Exception("Couldn't find the desired download on " + \
|
||||
' %s.' % google_code_site)
|
||||
return latest
|
||||
|
||||
def run(self):
|
||||
"""Download and install the Google Code."""
|
||||
print 'Installing from %s' % self.project_name
|
||||
os_str = self.get_os_str
|
||||
version = self.find_latest_version()
|
||||
download_name = self.download_name_func({'os': os_str, 'version': version})
|
||||
urllib.urlretrieve(self.google_code_download() + '/' + download_name,
|
||||
os.path.join(self.download_location, download_name))
|
||||
if download_name.endswith('.zip'):
|
||||
run_cmd('unzip -u %s -d %s' % (os.path.join(self.download_location,
|
||||
download_name), self.download_location))
|
||||
os.remove(os.path.join(self.download_location, download_name))
|
||||
|
||||
@property
|
||||
def get_os_str(self):
|
||||
"""The strings to indicate what OS a download is for as used on Google Code.
|
||||
"""
|
||||
os_str = 'win'
|
||||
if 'darwin' in sys.platform:
|
||||
os_str = 'mac'
|
||||
elif 'linux' in sys.platform:
|
||||
os_str = 'linux32'
|
||||
if '64bit' in platform.architecture()[0]:
|
||||
os_str = 'linux64'
|
||||
return os_str
|
||||
|
||||
|
||||
class FirefoxInstaller(object):
|
||||
"""Installs the latest version of Firefox on the machine."""
|
||||
|
||||
def ff_download_site(self, os_name):
|
||||
return 'http://releases.mozilla.org/pub/mozilla.org/firefox/releases/' + \
|
||||
'latest/%s/en-US/' % os_name
|
||||
|
||||
def get_os_str(self):
|
||||
"""Returns the string that Mozilla uses to denote which operating system a
|
||||
Firefox binary is for."""
|
||||
os_str = ('win32', '.exe')
|
||||
if 'darwin' in sys.platform:
|
||||
os_str = ('mac', '.dmg')
|
||||
elif 'linux' in sys.platform:
|
||||
os_str = ('linux-i686', '.tar.bz2')
|
||||
if '64bit' in platform.architecture()[0]:
|
||||
os_str = ('linux-x86_64', '.tar.bz2')
|
||||
return os_str
|
||||
|
||||
def get_download_url(self):
|
||||
"""Parse the html on the page to determine what is the latest download
|
||||
appropriate for our system."""
|
||||
f = urllib2.urlopen(self.ff_download_site(self.get_os_str[0]))
|
||||
download_name = ''
|
||||
for line in f.readlines():
|
||||
suffix = self.get_os_str[1]
|
||||
if (suffix + '"') in line:
|
||||
link_str = '<a href="'
|
||||
download_name = line[line.find(link_str) + len(link_str) : \
|
||||
line.find(suffix) + len(suffix)]
|
||||
break
|
||||
return '%s%s' % (self.ff_download_site(self.get_os_str[0]), download_name)
|
||||
|
||||
def run(self):
|
||||
print 'Installing Firefox'
|
||||
if 'darwin' in sys.platform:
|
||||
urllib.urlretrieve(self.get_download_url(), 'firefox.dmg')
|
||||
run_cmd('hdiutil mount firefox.dmg')
|
||||
run_cmd('sudo cp -R /Volumes/firefox/Firefox.app /Applications')
|
||||
run_cmd('hdiutil unmount /Volumes/firefox/')
|
||||
elif 'win' in sys.platform:
|
||||
urllib.urlretrieve(self.get_download_url(), 'firefox_install.exe')
|
||||
run_cmd('firefox_install.exe -ms')
|
||||
else:
|
||||
run_cmd('wget -O - %s | tar -C ~ -jxv' % self.get_download_url())
|
||||
|
||||
|
||||
class SeleniumBindingsInstaller(object):
|
||||
"""Install the Selenium Webdriver bindings for Python."""
|
||||
|
||||
SETUPTOOLS_SITE = 'http://python-distribute.org/distribute_setup.py'
|
||||
PIP_SITE = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py'
|
||||
def __init__(self, is_buildbot):
|
||||
self.is_buildbot = is_buildbot
|
||||
|
||||
def run(self):
|
||||
print 'Installing Selenium Python Bindings'
|
||||
admin_keyword = ''
|
||||
python_cmd = 'python'
|
||||
if 'win32' not in sys.platform and 'cygwin' not in sys.platform:
|
||||
admin_keyword = 'sudo'
|
||||
else:
|
||||
# The python installation is "special" on Windows buildbots.
|
||||
if is_buildbot:
|
||||
python_cmd = os.path.join(find_depot_tools_location(is_buildbot),
|
||||
'python-bin', 'python')
|
||||
page = urllib2.urlopen(self.SETUPTOOLS_SITE)
|
||||
run_cmd('%s %s' % (admin_keyword, python_cmd), page.read())
|
||||
page = urllib2.urlopen(self.PIP_SITE)
|
||||
run_cmd('%s %s' % (admin_keyword, python_cmd), page.read())
|
||||
run_cmd('%s pip install -U selenium' % admin_keyword)
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
SeleniumBindingsInstaller(args.buildbot).run()
|
||||
chromedriver_loc = find_depot_tools_location(args.buildbot)
|
||||
if args.path:
|
||||
chromedriver_loc = args.path
|
||||
GoogleCodeInstaller('chromium', chromedriver_loc,
|
||||
lambda x: 'chromedriver_%(os)s_%(version)s.zip' % x).run()
|
||||
if 'darwin' in sys.platform:
|
||||
GoogleCodeInstaller('selenium', os.path.dirname(os.path.abspath(__file__)),
|
||||
lambda x: 'selenium-server-standalone-%(version)s.jar' % x).run()
|
||||
|
||||
if args.firefox:
|
||||
FirefoxInstaller().run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in a new issue