Skip to content

Commit

Permalink
Move all classes into a top level SeleniumRake namespace and correct …
Browse files Browse the repository at this point in the history
…folder/file structure
  • Loading branch information
luke-hill authored and p0deje committed Sep 27, 2019
1 parent 2f46354 commit 9ea32fa
Show file tree
Hide file tree
Showing 23 changed files with 596 additions and 602 deletions.
114 changes: 70 additions & 44 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ require 'rake-tasks/crazy_fun/mappings/ruby'
require 'rake-tasks/task-gen'
require 'rake-tasks/checks'
require 'rake-tasks/c'
require 'rake-tasks/selenium'
require 'rake-tasks/ie_code_generator'
require 'rake-tasks/ci'

# Our modifications to the Rake library
require 'rake-tasks/rake/task'

$DEBUG = orig_verbose != Rake::FileUtilsExt::DEFAULT ? true : false
if (ENV['debug'] == 'true')
$DEBUG = true
Expand All @@ -53,7 +55,7 @@ end
# "crazy fun" for no readily apparent reason.

# First off, create a new CrazyFun object.
crazy_fun = CrazyFun.new
crazy_fun = SeleniumRake::CrazyFun.new

# Secondly, we add the handlers, which are responsible for turning a build
# rule into a (series of) rake tasks. For example if we're looking at a file
Expand Down Expand Up @@ -109,7 +111,6 @@ JAVA_RELEASE_TARGETS = %w(
//java/client/src/org/openqa/selenium:client-combined-publish
)


# Notice that because we're using rake, anything you can do in a normal rake
# build can also be done here. For example, here we set the default task
task :default => [:test]
Expand Down Expand Up @@ -199,30 +200,19 @@ task :test_support => [

# TODO(simon): test-core should go first, but it's changing the least for now.
task :test_selenium => [ :'test-rc']

task :'test-rc' => ['//java/client/test/com/thoughtworks/selenium:firefox-rc-test:run']

if (windows?)
task :'test-rc' => ['//java/client/test/com/thoughtworks/selenium:ie-rc-test:run']
end
task :'test-rc' => ['//java/client/test/com/thoughtworks/selenium:ie-rc-test:run'] if SeleniumRake::Checks.windows?

task :test_java_webdriver => [
:test_htmlunit,
:test_firefox,
:test_remote_server,
]
if (windows?)
task :test_java_webdriver => [:test_ie]
end
if (present?("chromedriver"))
task :test_java_webdriver => [:test_chrome]
end
if (present?("msedgedriver"))
task :test_java_webdriver => [:test_edge]
end
if (opera?)
task :test_java_webdriver => [:test_opera]
end

task :test_java_webdriver => [:test_ie] if SeleniumRake::Checks.windows?
task :test_java_webdriver => [:test_chrome] if SeleniumRake::Checks.present?("chromedriver")
task :test_java_webdriver => [:test_edge] if SeleniumRake::Checks.present?("msedgedriver")
task :test_java_webdriver => [:test_opera] if SeleniumRake::Checks.opera?

task :test_java => [
"//java/client/test/org/openqa/selenium/atoms:test:run",
Expand Down Expand Up @@ -250,27 +240,23 @@ task :test_rb => ["//rb:unit-test", :test_rb_local, :test_rb_remote]
task :test_rb_local => [
"//rb:chrome-test",
"//rb:firefox-test",
("//rb:safari-preview-test" if mac?),
("//rb:safari-test" if mac?),
("//rb:ie-test" if windows?),
("//rb:edge-test" if windows?)
("//rb:safari-preview-test" if SeleniumRake::Checks.mac?),
("//rb:safari-test" if SeleniumRake::Checks.mac?),
("//rb:ie-test" if SeleniumRake::Checks.windows?),
("//rb:edge-test" if SeleniumRake::Checks.windows?)
].compact

task :test_rb_remote => [
"//rb:remote-chrome-test",
"//rb:remote-firefox-test",
("//rb:remote-safari-test" if mac?),
("//rb:remote-ie-test" if windows?),
("//rb:remote-edge-test" if windows?)
("//rb:remote-safari-test" if SeleniumRake::Checks.mac?),
("//rb:remote-ie-test" if SeleniumRake::Checks.windows?),
("//rb:remote-edge-test" if SeleniumRake::Checks.windows?)
].compact

task :test_py => [ :py_prep_for_install_release, "py:marionette_test" ]

task :test => [ :test_javascript, :test_java, :test_rb ]
if (python?)
task :test => [ :test_py ]
end

task :test => [ :test_py ] if SeleniumRake::Checks.python?
task :build => [:all, :firefox, :remote, :selenium, :tests]

desc 'Clean build artifacts.'
Expand All @@ -280,13 +266,17 @@ task :clean do
rm_rf 'dist/'
end

# Create a new IEGenerator instance
ie_generator = SeleniumRake::IEGenerator.new

# Generate a C++ Header file for mapping between magic numbers and #defines
# in the C++ code.
ie_generate_type_mapping(:name => "ie_result_type_cpp",
:src => "cpp/iedriver/result_types.txt",
:type => "cpp",
:out => "cpp/iedriver/IEReturnTypes.h")

ie_generator.ie_generate_type_mapping(
:name => "ie_result_type_cpp",
:src => "cpp/iedriver/result_types.txt",
:type => "cpp",
:out => "cpp/iedriver/IEReturnTypes.h"
)

task :javadocs => [:common, :firefox, :ie, :remote, :support, :chrome, :selenium] do
rm_rf "build/javadoc"
Expand All @@ -307,7 +297,7 @@ task :javadocs => [:common, :firefox, :ie, :remote, :support, :chrome, :selenium
cmd = "javadoc -notimestamp -d build/javadoc -sourcepath #{sourcepath} -classpath #{classpath} -subpackages org.openqa.selenium -subpackages com.thoughtworks "
cmd << " -exclude org.openqa.selenium.internal.selenesedriver:org.openqa.selenium.internal.seleniumemulation:org.openqa.selenium.remote.internal"

if (windows?)
if SeleniumRake::Checks.windows?
cmd = cmd.gsub(/\//, "\\").gsub(/:/, ";")
end
sh cmd
Expand Down Expand Up @@ -336,11 +326,10 @@ task :py_prep_for_install_release => [
]

task :py_docs => "py:docs"

task :py_install => "py:install"

task :py_release => :py_prep_for_install_release do
sh "python setup.py sdist bdist_wheel upload"
sh "python setup.py sdist bdist_wheel upload"
end

file "cpp/iedriver/sizzle.h" => [ "//third_party/js/sizzle:sizzle:header" ] do
Expand Down Expand Up @@ -398,7 +387,6 @@ task :'prep-release-zip' => [
chmod 0666, "build/dist/selenium-html-runner-#{version}.jar"
end


task :'release-java' => [:'publish-maven', :'push-release']

def read_user_pass_from_m2_settings
Expand Down Expand Up @@ -439,9 +427,7 @@ end

task :'push-release' => [:'prep-release-zip'] do
py = "java -jar third_party/py/jython.jar"
if python?
py = "python"
end
py = "python" if SeleniumRake::Checks.python?

sh "#{py} third_party/py/googlestorage/publish_release.py --project_id google.com:webdriver --bucket selenium-release --acl public-read --publish_version #{google_storage_version} --publish build/dist/selenium-server-#{version}.jar --publish build/dist/selenium-java-#{version}.zip --publish build/dist/selenium-server-#{version}.jar --publish build/dist/selenium-html-runner-#{version}.jar"
end
Expand All @@ -461,6 +447,46 @@ task :authors do
sh "(git log --use-mailmap --format='%aN <%aE>' ; cat .OLD_AUTHORS) | sort -uf > AUTHORS"
end

namespace :ci do
task :upload_to_sauce do
upload_path = ENV['UPLOAD_PATH']
username = ENV['SAUCE_USERNAME']
apikey = ENV['SAUCE_APIKEY']
upload_filename = Pathname.new(upload_path).basename
upload_url = "http://saucelabs.com/rest/v1/storage/#{username}/#{upload_filename}"
body = nil

File.open(find_file(upload_path), 'r') do |infile|
body = infile.read
end

6.times do
uri = URI.parse(upload_url)
request = Net::HTTP::Post.new(uri.request_uri)
request.basic_auth(username, apikey)
request['Content-Type'] = 'application/octet-stream'
request.body = body
http = net_http.new(uri.host, uri.port)
http.read_timeout = 60 * 5 # 5 min
begin
response = http.request(request)
rescue StandardError => e
puts "issue uploading file: #{e}"
next
end
metadata = JSON.parse(response.body)
local_digest = Digest::MD5.hexdigest(body)
if metadata['md5'] == local_digest
puts "file successfully uploaded: #{metadata['filename']}"
else
puts "issues uploading file: #{response.code} - #{response.body}"
end
break
end
raise 'failed to upload to saucelabs after numerous retries'
end
end

at_exit do
if File.exist?(".git") && !Platform.windows?
system "sh", ".git-fixfiles"
Expand Down
90 changes: 0 additions & 90 deletions rake-tasks/browsers.rb
Original file line number Diff line number Diff line change
@@ -1,91 +1 @@
require 'rake-tasks/checks'

BROWSERS = {
'ff' => {
python: {
driver: 'Marionette'
},
java: {
class: 'org.openqa.selenium.firefox.SynthesizedFirefoxDriver',
deps: ['//java/client/test/org/openqa/selenium/testing/drivers']
},
browser_name: 'firefox'
},
'marionette' => {
python: {
driver: 'Marionette'
},
java: {
class: 'org.openqa.selenium.firefox.SynthesizedFirefoxDriver',
deps: ['//java/client/test/org/openqa/selenium/testing/drivers']
},
browser_name: 'firefox'
},
'ie' => {
python: {
driver: 'Ie'
},
java: {
class: 'org.openqa.selenium.ie.InternetExplorerDriver',
deps: ['//java/client/src/org/openqa/selenium/ie:ie', '//cpp/iedriverserver:win32']
},
browser_name: 'internet explorer',
available: windows?
},
'edge' => {
python: {
driver: 'Edge'
},
browser_name: 'MicrosoftEdge',
available: windows?
},
'chrome' => {
python: {
driver: 'Chrome'
},
java: {
class: 'org.openqa.selenium.chrome.ChromeDriver',
deps: ['//java/client/src/org/openqa/selenium/chrome:chrome']
},
browser_name: 'chrome',
available: chrome?
},
'chromiumedge' => {
python: {
driver: 'ChromiumEdge'
},
java: {
class: 'org.openqa.selenium.edge.EdgeDriver',
deps: ['//java/client/src/org/openqa/selenium/edge:edge']
},
browser_name: 'MicrosoftEdge',
available: edge?
},
'blackberry' => {
python: {
driver: 'BlackBerry'
},
browser_name: 'blackberry'
},
'remote_firefox' => {
python: {
driver: 'Remote',
deps: [
:remote_client,
:'selenium-server-standalone',
'//java/server/test/org/openqa/selenium/remote/server/auth:server'
]
}
},
'safari' => {
python: {
driver: 'Safari'
},
java: {
class: 'org.openqa.selenium.safari.SafariDriver',
deps: ['//java/client/src/org/openqa/selenium/safari:safari']
},
browser_name: 'safari',
available: mac?
}
}
Loading

0 comments on commit 9ea32fa

Please sign in to comment.