sauce 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.markdown +3 -2
- data/VERSION +1 -1
- data/generators/sauce/templates/sauce.rake +1 -51
- data/lib/sauce.rb +1 -0
- data/lib/sauce/config.rb +7 -1
- data/lib/sauce/connect.rb +1 -1
- data/lib/sauce/gateway_ext.rb +2 -0
- data/lib/sauce/integrations.rb +31 -26
- data/lib/sauce/raketasks.rb +67 -0
- data/lib/sauce/tunnel.rb +2 -0
- data/lib/sauce/utilities.rb +52 -0
- data/support/selenium-server.jar +0 -0
- metadata +6 -3
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -13,9 +13,10 @@ Current:
|
|
13
13
|
|
14
14
|
Planned:
|
15
15
|
|
16
|
+
* Include selenium-client RSpec/Test::Unit integration
|
17
|
+
* Webrat integration
|
16
18
|
* Extend to automatic retrieval of jobs logs, videos, reverse tunnels
|
17
19
|
* Start/stop local instances of Sauce RC
|
18
|
-
* Webrat integration
|
19
20
|
|
20
21
|
Install
|
21
22
|
-------
|
@@ -145,4 +146,4 @@ Note on Patches/Pull Requests
|
|
145
146
|
|
146
147
|
Copyright
|
147
148
|
---------
|
148
|
-
Copyright (c) 2010 Sauce Labs Inc. See LICENSE for details.
|
149
|
+
Copyright (c) 2009-2010 Sauce Labs Inc. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.11.0
|
@@ -1,51 +1 @@
|
|
1
|
-
|
2
|
-
task :noop do
|
3
|
-
end
|
4
|
-
|
5
|
-
namespace :spec do
|
6
|
-
namespace :selenium do
|
7
|
-
desc "Run the Selenium acceptance tests in spec/selenium using Sauce OnDemand"
|
8
|
-
task :sauce => spec_prereq do
|
9
|
-
server = IO.popen("script/server RAILS_ENV=test --port 3001")
|
10
|
-
begin
|
11
|
-
Rake::Task["spec:selenium:runtests"].invoke
|
12
|
-
ensure
|
13
|
-
Process.kill("INT", server.pid)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "" # Hide it from rake -T
|
18
|
-
Spec::Rake::SpecTask.new :runtests do |t|
|
19
|
-
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
20
|
-
t.spec_files = FileList["spec/selenium/**/*_spec.rb"]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
task :selenium => "selenium:sauce"
|
25
|
-
end
|
26
|
-
|
27
|
-
namespace :test do
|
28
|
-
namespace :selenium do
|
29
|
-
desc "Run the Selenium acceptance tests in test/selenium using Sauce OnDemand"
|
30
|
-
task :sauce do
|
31
|
-
server = IO.popen("script/server --port 3001")
|
32
|
-
begin
|
33
|
-
Rake::Task["test:selenium:runtests"].invoke
|
34
|
-
ensure
|
35
|
-
Process.kill("INT", server.pid)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
Rake::TestTask.new(:runtests) do |t|
|
40
|
-
t.libs << "test"
|
41
|
-
t.pattern = 'test/selenium/**/*_test.rb'
|
42
|
-
t.verbose = true
|
43
|
-
end
|
44
|
-
desc "" # Hide it from rake -T
|
45
|
-
Rake::Task['test:selenium:runtests'].instance_variable_set(:@full_comment, nil)
|
46
|
-
Rake::Task['test:selenium:runtests'].instance_variable_set(:@comment, nil)
|
47
|
-
Rake::Task['test:selenium:runtests'].enhance(["db:test:prepare"])
|
48
|
-
end
|
49
|
-
|
50
|
-
task :selenium => "selenium:sauce"
|
51
|
-
end
|
1
|
+
require 'sauce/raketasks'
|
data/lib/sauce.rb
CHANGED
data/lib/sauce/config.rb
CHANGED
@@ -14,6 +14,7 @@ module Sauce
|
|
14
14
|
|
15
15
|
class Config
|
16
16
|
attr_reader :opts
|
17
|
+
|
17
18
|
DEFAULT_OPTIONS = {
|
18
19
|
:host => "saucelabs.com",
|
19
20
|
:port => 4444,
|
@@ -21,7 +22,8 @@ module Sauce
|
|
21
22
|
:os => "Linux",
|
22
23
|
:browser => "firefox",
|
23
24
|
:browser_version => "3.",
|
24
|
-
:job_name => "Unnamed Ruby job"
|
25
|
+
:job_name => "Unnamed Ruby job",
|
26
|
+
:local_application_port => "3001"
|
25
27
|
}
|
26
28
|
|
27
29
|
def initialize(opts={})
|
@@ -65,6 +67,10 @@ module Sauce
|
|
65
67
|
return URI.parse(@opts[:browser_url]).host
|
66
68
|
end
|
67
69
|
|
70
|
+
def local?
|
71
|
+
return ENV['LOCAL_SELENIUM']
|
72
|
+
end
|
73
|
+
|
68
74
|
private
|
69
75
|
|
70
76
|
def load_options_from_environment
|
data/lib/sauce/connect.rb
CHANGED
data/lib/sauce/gateway_ext.rb
CHANGED
data/lib/sauce/integrations.rb
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
|
8
8
|
before :suite do
|
9
9
|
config = Sauce::Config.new
|
10
|
-
if config.application_host
|
10
|
+
if config.application_host && !config.local?
|
11
11
|
@@tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
|
12
12
|
@@tunnel.wait_until_ready
|
13
13
|
end
|
@@ -19,21 +19,22 @@ begin
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
before(:each) do
|
23
|
-
@selenium.start
|
24
|
-
end
|
25
|
-
|
26
|
-
after(:each) do
|
27
|
-
@selenium.stop
|
28
|
-
end
|
29
|
-
|
30
22
|
def execute(*args)
|
31
23
|
config = Sauce::Config.new
|
32
24
|
description = [self.class.description, self.description].join(" ")
|
33
25
|
config.browsers.each do |os, browser, version|
|
34
|
-
|
35
|
-
:
|
26
|
+
if config.local?
|
27
|
+
@selenium = ::Selenium::Client::Driver.new(:host => "127.0.0.1",
|
28
|
+
:port => 4444,
|
29
|
+
:browser => "*" + browser,
|
30
|
+
:url => "http://127.0.0.1:#{config.local_application_port}/")
|
31
|
+
else
|
32
|
+
@selenium = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version,
|
33
|
+
:job_name => "#{description}"})
|
34
|
+
end
|
35
|
+
@selenium.start
|
36
36
|
super(*args)
|
37
|
+
@selenium.stop
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -61,8 +62,15 @@ begin
|
|
61
62
|
unless name =~ /^default_test/
|
62
63
|
config = Sauce::Config.new
|
63
64
|
config.browsers.each do |os, browser, version|
|
64
|
-
|
65
|
-
:
|
65
|
+
if config.local?
|
66
|
+
@selenium = ::Selenium::Client::Driver.new(:host => "127.0.0.1",
|
67
|
+
:port => 4444,
|
68
|
+
:browser => "*" + browser,
|
69
|
+
:url => "http://127.0.0.1:#{config.local_application_port}/")
|
70
|
+
else
|
71
|
+
@selenium = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version,
|
72
|
+
:job_name => "#{name}"})
|
73
|
+
end
|
66
74
|
@selenium.start
|
67
75
|
super(*args, &blk)
|
68
76
|
@selenium.stop
|
@@ -73,11 +81,6 @@ begin
|
|
73
81
|
# Placeholder so test/unit ignores test cases without any tests.
|
74
82
|
def default_test
|
75
83
|
end
|
76
|
-
|
77
|
-
def self.ensure_tunnel_running
|
78
|
-
unless defined?(@tunnel)
|
79
|
-
end
|
80
|
-
end
|
81
84
|
end
|
82
85
|
end
|
83
86
|
require 'test/unit/ui/console/testrunner'
|
@@ -95,7 +98,7 @@ begin
|
|
95
98
|
|
96
99
|
def start_tunnel(msg)
|
97
100
|
config = Sauce::Config.new
|
98
|
-
if config.application_host
|
101
|
+
if config.application_host && !config.local?
|
99
102
|
@sauce_tunnel = Sauce::Connect.new(:host => config.application_host, :port => config.application_port || 80)
|
100
103
|
@sauce_tunnel.wait_until_ready
|
101
104
|
end
|
@@ -123,8 +126,15 @@ if defined?(ActiveSupport::TestCase)
|
|
123
126
|
unless name =~ /^default_test/
|
124
127
|
config = Sauce::Config.new
|
125
128
|
config.browsers.each do |os, browser, version|
|
126
|
-
|
127
|
-
:
|
129
|
+
if config.local?
|
130
|
+
@selenium = ::Selenium::Client::Driver.new(:host => "127.0.0.1",
|
131
|
+
:port => 4444,
|
132
|
+
:browser => "*" + browser,
|
133
|
+
:url => "http://127.0.0.1:#{config.local_application_port}/")
|
134
|
+
else
|
135
|
+
@selenium = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version,
|
136
|
+
:job_name => "#{name}"})
|
137
|
+
end
|
128
138
|
@selenium.start
|
129
139
|
super(*args, &blk)
|
130
140
|
@selenium.stop
|
@@ -135,11 +145,6 @@ if defined?(ActiveSupport::TestCase)
|
|
135
145
|
# Placeholder so test/unit ignores test cases without any tests.
|
136
146
|
def default_test
|
137
147
|
end
|
138
|
-
|
139
|
-
def self.ensure_tunnel_running
|
140
|
-
unless defined?(@tunnel)
|
141
|
-
end
|
142
|
-
end
|
143
148
|
end
|
144
149
|
end
|
145
150
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'sauce'
|
2
|
+
|
3
|
+
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
4
|
+
task :noop do
|
5
|
+
end
|
6
|
+
|
7
|
+
include Sauce::Utilities
|
8
|
+
|
9
|
+
namespace :spec do
|
10
|
+
namespace :selenium do
|
11
|
+
desc "Run the Selenium acceptance tests in spec/selenium using Sauce OnDemand"
|
12
|
+
task :sauce => spec_prereq do
|
13
|
+
with_rails_server do
|
14
|
+
Rake::Task["spec:selenium:runtests"].invoke
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run the Selenium acceptance tests in spec/selenium using a local Selenium server"
|
19
|
+
task :local => spec_prereq do
|
20
|
+
with_rails_server do
|
21
|
+
with_selenium_rc do
|
22
|
+
Rake::Task["spec:selenium:runtests"].invoke
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "" # Hide it from rake -T
|
28
|
+
Spec::Rake::SpecTask.new :runtests do |t|
|
29
|
+
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
|
30
|
+
t.spec_files = FileList["spec/selenium/**/*_spec.rb"]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
task :selenium => "selenium:sauce"
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace :test do
|
38
|
+
namespace :selenium do
|
39
|
+
desc "Run the Selenium acceptance tests in test/selenium using Sauce OnDemand"
|
40
|
+
task :sauce do
|
41
|
+
with_rails_server do
|
42
|
+
Rake::Task["test:selenium:runtests"].invoke
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Run the Selenium acceptance tests in spec/selenium using a local Selenium server"
|
47
|
+
task :local do
|
48
|
+
with_rails_server do
|
49
|
+
with_selenium_rc do
|
50
|
+
Rake::Task["test:selenium:runtests"].invoke
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Rake::TestTask.new(:runtests) do |t|
|
56
|
+
t.libs << "test"
|
57
|
+
t.pattern = 'test/selenium/**/*_test.rb'
|
58
|
+
t.verbose = true
|
59
|
+
end
|
60
|
+
# Hide it from rake -T
|
61
|
+
Rake::Task['test:selenium:runtests'].instance_variable_set(:@full_comment, nil)
|
62
|
+
Rake::Task['test:selenium:runtests'].instance_variable_set(:@comment, nil)
|
63
|
+
Rake::Task['test:selenium:runtests'].enhance(["db:test:prepare"])
|
64
|
+
end
|
65
|
+
|
66
|
+
task :selenium => "selenium:sauce"
|
67
|
+
end
|
data/lib/sauce/tunnel.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Sauce
|
2
|
+
module Utilities
|
3
|
+
def silence_stream(stream)
|
4
|
+
old_stream = stream.dup
|
5
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
6
|
+
stream.sync = true
|
7
|
+
yield
|
8
|
+
ensure
|
9
|
+
stream.reopen(old_stream)
|
10
|
+
end
|
11
|
+
|
12
|
+
def with_selenium_rc
|
13
|
+
ENV['LOCAL_SELENIUM'] = "true"
|
14
|
+
STDERR.puts "Starting Selenium RC server on port 4444..."
|
15
|
+
server = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0", 4444)
|
16
|
+
server.jar_file = File.expand_path(File.dirname(__FILE__) + "/../../support/selenium-server.jar")
|
17
|
+
silence_stream(STDOUT) do
|
18
|
+
server.start :background => true
|
19
|
+
TCPSocket.wait_for_service(:host => "127.0.0.1", :port => 4444)
|
20
|
+
end
|
21
|
+
STDERR.puts "Selenium RC running!"
|
22
|
+
begin
|
23
|
+
yield
|
24
|
+
ensure
|
25
|
+
server.stop
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def with_rails_server
|
30
|
+
STDERR.puts "Starting Rails server on port 3001..."
|
31
|
+
server = IO.popen("script/server RAILS_ENV=test --port 3001 2>&1")
|
32
|
+
pid = nil
|
33
|
+
Thread.new do
|
34
|
+
while (line = server.gets)
|
35
|
+
if line =~ /pid=(.*) /
|
36
|
+
pid = $1.to_i
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
silence_stream(STDOUT) do
|
42
|
+
TCPSocket.wait_for_service(:host => "127.0.0.1", :port => 3001)
|
43
|
+
end
|
44
|
+
STDERR.puts "Rails server running!"
|
45
|
+
begin
|
46
|
+
yield
|
47
|
+
ensure
|
48
|
+
Process.kill("INT", pid)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sauce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 11
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.11.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Grove
|
@@ -155,9 +155,12 @@ files:
|
|
155
155
|
- lib/sauce/heroku.rb
|
156
156
|
- lib/sauce/integrations.rb
|
157
157
|
- lib/sauce/job.rb
|
158
|
+
- lib/sauce/raketasks.rb
|
158
159
|
- lib/sauce/selenium.rb
|
159
160
|
- lib/sauce/tunnel.rb
|
161
|
+
- lib/sauce/utilities.rb
|
160
162
|
- support/sauce_connect
|
163
|
+
- support/selenium-server.jar
|
161
164
|
- support/simplejson/LICENSE.txt
|
162
165
|
- support/simplejson/__init__.py
|
163
166
|
- support/simplejson/decoder.py
|