Skip to content

Commit

Permalink
DanielWagnerHall: Crazy-fun-ifying python build
Browse files Browse the repository at this point in the history
r15111
  • Loading branch information
illicitonion committed Dec 8, 2011
1 parent 7610cd5 commit 49206d8
Show file tree
Hide file tree
Showing 99 changed files with 346 additions and 3,340 deletions.
146 changes: 4 additions & 142 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require 'rake-tasks/crazy_fun/mappings/gcc'
require 'rake-tasks/crazy_fun/mappings/java'
require 'rake-tasks/crazy_fun/mappings/javascript'
require 'rake-tasks/crazy_fun/mappings/mozilla'
require 'rake-tasks/crazy_fun/mappings/python'
require 'rake-tasks/crazy_fun/mappings/rake'
require 'rake-tasks/crazy_fun/mappings/ruby'
require 'rake-tasks/crazy_fun/mappings/visualstudio'
Expand Down Expand Up @@ -63,6 +64,7 @@ GccMappings.new.add_all(crazy_fun)
JavaMappings.new.add_all(crazy_fun)
JavascriptMappings.new.add_all(crazy_fun)
MozillaMappings.new.add_all(crazy_fun)
PythonMappings.new.add_all(crazy_fun)
RakeMappings.new.add_all(crazy_fun)
RubyMappings.new.add_all(crazy_fun)
VisualStudioMappings.new.add_all(crazy_fun)
Expand Down Expand Up @@ -215,9 +217,7 @@ task :test_rb => [
"//rb:chrome-test"
].compact

task :test_py => [
"test_firefox_py"
]
task :test_py => [ "//py:test_firefox:run" ]

task :test_dotnet => [
"//dotnet/test:firefox:run"
Expand Down Expand Up @@ -379,145 +379,6 @@ task :javadocs => [:common, :firefox, :htmlunit, :ie, :remote, :support, :chrome
sh cmd
end

# Installs the webdriver python bindings using virtualenv for testing.
task :webdriver_py do
if python? then
pip_pkg = "pip install third_party/py/simplejson-2.2.1.tar.gz third_party/py/py-1.4.5.zip third_party/py/pytest-2.0.3.zip third_party/py/rdflib-3.1.0.tar.gz"
virtualenv = "virtualenv --no-site-packages build/python"
pip_install = 'build/python/bin/' + pip_pkg
if (windows?) then
virtualenv = "virtualenv build\\python"
pip_install = "build\\python\\Scripts\\" + pip_pkg
end

sh virtualenv, :verbose => true do |ok, res|
if ! ok
puts ""
puts "PYTHON DEPENDENCY ERROR: Virtualenv not found."
puts "Please run '[sudo] pip install virtualenv'"
puts ""
end
end

sh pip_install, :verbose => true
end
end

task :test_ie_py => :webdriver_py do
win = windows?
if win != nil then
if python? then
win32 = "py\\selenium\\webdriver\\ie\\win32\\"
x64 = "py\\selenium\\webdriver\\ie\\x64\\"
mkdir_p win32 unless File.exists?(win32)
mkdir_p x64 unless File.exists?(x64)
cp 'cpp\\prebuilt\\Win32\\Release\\IEDriver.dll', win32, :verbose => true
cp 'cpp\\prebuilt\\x64\\Release\\IEDriver.dll', x64, :verbose => true

sh "build\\python\\Scripts\\python setup.py build", :verbose => true

if File.exists?('build\\python\\Scripts\\py.test.exe')
py_test = 'build\\python\\Scripts\\py.test.exe'
else
py_test = 'py.test.exe'
end

test_dir = Dir.glob('build/lib**/selenium/test/selenium/webdriver/ie').first
sh py_test, test_dir, :verbose => true
rm_rf win32
rm_rf x64
end
end
end

task :test_chrome_py => [:webdriver_py, :chrome] do
if python? then
py_test_path = 'build/python/bin/py.test'
py_setup = "build/python/bin/python " + 'setup.py build'
if (windows?) then
py_test_path = 'build\\python\\Scripts\\py.test.exe'
py_setup = 'build\\python\\Scripts\\python ' + 'setup.py build'
end

sh py_setup , :verbose => true

if File.exists?(py_test_path)
py_test = py_test_path
else
py_test = 'py.test'
end
test_dir = Dir.glob('build/lib**/selenium/test/selenium/webdriver/chrome').first
sh py_test, test_dir, "-k -ignore_chrome", :verbose => true
end
end

task :test_firefox_py => [:webdriver_py, :firefox, "//javascript/firefox-driver:webdriver"] do
if python? then
xpi_zip_build = 'build/javascript/firefox-driver/webdriver.xpi'
firefox_py_home = "py/selenium/webdriver/firefox/"
x86 = firefox_py_home + "x86/"
amd64 = firefox_py_home + "amd64/"
py_test_path = 'build/python/bin/py.test'
py_setup = "build/python/bin/python " + 'setup.py build'
if (windows?) then
xpi_zip_build = xpi_zip_build.gsub(/\//, "\\")
firefox_py_home = firefox_py_home .gsub(/\//, "\\")
py_test_path = 'build\\python\\Scripts\\py.test.exe'
py_setup = 'build\\python\\Scripts\\python ' + 'setup.py build'
x86 = x86.gsub(/\//,"\\")
amd64 = amd64.gsub(/\//,"\\")
end

mkdir_p x86 unless File.exists?(x86)
mkdir_p amd64 unless File.exists?(amd64)

cp "cpp/prebuilt/i386/libnoblur.so", x86+"x_ignore_nofocus.so", :verbose => true
cp "cpp/prebuilt/amd64/libnoblur64.so", amd64+"x_ignore_nofocus.so", :verbose => true

cp xpi_zip_build , firefox_py_home, :verbose => true

sh py_setup , :verbose => true


if File.exists?(py_test_path)
py_test = py_test_path
else
py_test = 'py.test'
end


test_dir = Dir.glob('build/lib**/selenium/test/selenium/webdriver/firefox').first
sh py_test, test_dir, :verbose => true
webdriver_zip = firefox_py_home + 'webdriver.xpi'
rm webdriver_zip , :verbose => true
rm_rf x86 , :verbose => true
rm_rf amd64 , :verbose => true
end
end

task :test_remote_py => [:webdriver_py, :remote_client, :'selenium-server-standalone',
'//java/server/test/org/openqa/selenium/remote/server/auth:server:uber'] do
if python? then
py_setup = "build/python/bin/python " + 'setup.py build'
py_test_path = 'build/python/bin/py.test'

if (windows?) then
py_test_path = 'build\\python\\Scripts\\py.test.exe'
py_setup = 'build\\python\\Scripts\\python ' + 'setup.py build'
end

sh py_setup , :verbose => true

if File.exists?(py_test_path)
py_test = py_test_path
else
py_test = 'py.test'
end
test_dir = Dir.glob('build/lib**/selenium/test/selenium/webdriver/remote').first
sh py_test, test_dir, :verbose => true
end
end

task :py_prep_for_install_release => ["//javascript/firefox-driver:webdriver", :chrome] do
if python? then

Expand Down Expand Up @@ -748,3 +609,4 @@ at_exit do
sh "sh .git-fixfiles"
end
end

56 changes: 56 additions & 0 deletions py/build.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# py_test targets implicitly get the following extra targets added:
# for each browser in browsers:
# :name_B to gather the sources of the tests for browser B
# :name_B:run to run the tests for browser B
# Also, if only one browser, B, is listed in browsers:
# :name:run is created as a synonym for :name_B:run
#
# Currently, pulling in other tests through deps is limited to deps declared in the same build.desc file

py_test(
name = "firefox_test",
ff_specific_tests = [ "test/selenium/webdriver/firefox/*_tests.py" ],
deps = [ ":test_ff" ],
resources = [
{ "//javascript/firefox-driver:webdriver" : "lib/selenium/webdriver/firefox" }
],
browsers = [ "ff" ])

py_test(
name = "ie_test",
deps = [ ":test_ie" ],
resources = [
{"//cpp:ie_win32_dll" : "lib\\selenium\\webdriver\\ie\\win32\\IEDriver.dll"},
{"//cpp:ie_x64_dll" : "lib\\selenium\\webdriver\\ie\\x64\\IEDriver.dll"}
],

browsers = [ "ie" ])

py_test(
name = "remote_firefox_test",
remote_firefox_specific_tests = [ "test/selenium/webdriver/remote/*_tests.py" ],
deps = [ ":test_remote" ],
browsers = [ "remote_firefox" ])

py_env(
name = "test_env",
packages = [
"third_party/py/simplejson-2.2.1.tar.gz",
"third_party/py/py-1.4.5.zip",
"third_party/py/pytest-2.0.3.zip",
" third_party/py/rdflib-3.1.0.tar.gz"
],
dest = "build/python")

py_test(
name = "test",
common_tests = [
"test/selenium/webdriver/common/*_tests.py",
"test/selenium/webdriver/support/*_tests.py"
],
browsers = [
"chrome",
"ff",
"ie",
"remote_firefox"
])
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
#!/usr/bin/env python
# Copyright 2008-2009 WebDriver committers
# Copyright 2008-2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from selenium.test.selenium.webdriver.common.webserver import SimpleWebServer
from selenium.test.selenium.webdriver.common import api_examples
from selenium.test.selenium.common import utils
from selenium import webdriver


def setup_module(module):
utils.start_server(module)
webserver = SimpleWebServer()
webserver.start()
RemoteApiExampleTest.webserver = webserver
RemoteApiExampleTest.driver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.FIREFOX)


class RemoteApiExampleTest(api_examples.ApiExampleTest):
pass


def teardown_module(module):
try:
RemoteApiExampleTest.driver.quit()
except AttributeError:
pass
try:
RemoteApiExampleTest.webserver.stop()
except AttributeError:
pass
utils.stop_server(module)
#!/usr/bin/python
#
# Copyright 2011 Software Freedom Conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


##CUSTOM_TEST_IMPORT##
from selenium import webdriver
from selenium.##PACKAGE_NAME## import ##GENERAL_FILENAME##
from selenium.test.selenium.webdriver.common.webserver import SimpleWebServer

def setup_module(module):
##CUSTOM_TEST_SETUP##
webserver = SimpleWebServer()
webserver.start()
##BROWSER_SPECIFIC_TEST_CLASS##.webserver = webserver
##BROWSER_SPECIFIC_TEST_CLASS##.driver = webdriver.##BROWSER_CONSTRUCTOR##


class ##BROWSER_SPECIFIC_TEST_CLASS##(##GENERAL_FILENAME##.##GENERAL_TEST_CLASS##):
pass


def teardown_module(module):
try:
##BROWSER_SPECIFIC_TEST_CLASS##.driver.quit()
except AttributeError:
pass
try:
##BROWSER_SPECIFIC_TEST_CLASS##.webserver.stop()
except AttributeError:
pass
##CUSTOM_TEST_TEARDOWN##
16 changes: 0 additions & 16 deletions py/test/selenium/webdriver/chrome/__init__.py

This file was deleted.

37 changes: 0 additions & 37 deletions py/test/selenium/webdriver/chrome/test_chrome_api.py

This file was deleted.

Loading

0 comments on commit 49206d8

Please sign in to comment.