gondola 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gondola/testrunner.rb +117 -0
- metadata +2 -1
@@ -0,0 +1,117 @@
|
|
1
|
+
# Gondola v2
|
2
|
+
# FILE: testrunner.rb
|
3
|
+
# AUTHOR: Matthew Perry
|
4
|
+
# DESCRIPTION:
|
5
|
+
# A wrapper for all the tasks required for launching a run
|
6
|
+
# of a test suite or test case on several browsers
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'gondola'
|
10
|
+
|
11
|
+
module Gondola
|
12
|
+
class TestRunner
|
13
|
+
attr_accessor :tests
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@tests = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def addTest( file )
|
20
|
+
@tests.push( file )
|
21
|
+
end
|
22
|
+
|
23
|
+
def run( opts = {} )
|
24
|
+
if @tests.empty?
|
25
|
+
puts "No tests to run"
|
26
|
+
end
|
27
|
+
if opts[:super_parallel] == true
|
28
|
+
puts "Work in progress, please run again without the super parallel flag"
|
29
|
+
else
|
30
|
+
@tests.each do |test|
|
31
|
+
if File.directory? test
|
32
|
+
Dir.chdir( test )
|
33
|
+
prepend = ""
|
34
|
+
if opts[:recursive] == true
|
35
|
+
prepend = "**/"
|
36
|
+
end
|
37
|
+
files = Dir.glob( prepend + "*.html" )
|
38
|
+
if opts[:legacy] == true
|
39
|
+
files.concat( Dir.glob( prepend + "*.rb" ) )
|
40
|
+
end
|
41
|
+
files.each do |file|
|
42
|
+
conf = configure( File.expand_path( File.dirname( file ) ) )
|
43
|
+
runTest( file, conf )
|
44
|
+
end
|
45
|
+
else
|
46
|
+
conf = configure( File.expand_path( File.dirname( test ) ) )
|
47
|
+
runTest( file, conf )
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
# Function to configure sauce labs' gem with proper api information
|
55
|
+
# as well as populate the configuration for the specific test being run
|
56
|
+
def configure( file )
|
57
|
+
# Load possible paths for the api information (Sauce already does this to some extent
|
58
|
+
# but more paths were required for this gem)
|
59
|
+
conf = {}
|
60
|
+
apiPaths = [
|
61
|
+
File.expand_path( File.join( file, "ondemand.yml" ) ),
|
62
|
+
File.expand_path( File.join( file, "../ondemand.yml" ) ),
|
63
|
+
]
|
64
|
+
apiPaths.each do |path|
|
65
|
+
if File.exists?( path )
|
66
|
+
conf = YAML.load_file( path )
|
67
|
+
break
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Load possible paths for the configuration information
|
72
|
+
configPaths = [
|
73
|
+
File.expand_path( File.join( file, "../config.yml" ) ),
|
74
|
+
File.expand_path( File.join( file, "config.yml" ) ),
|
75
|
+
]
|
76
|
+
configPaths.each do |path|
|
77
|
+
if File.exists?( path )
|
78
|
+
conf.merge! YAML.load_file( path )
|
79
|
+
end
|
80
|
+
end
|
81
|
+
conf = conf.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
82
|
+
conf[:browsers].map! do |browser|
|
83
|
+
browser.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
84
|
+
end
|
85
|
+
return conf
|
86
|
+
end
|
87
|
+
|
88
|
+
# Function to run and parallelize the given test on the given browsers
|
89
|
+
def runTest( file, conf )
|
90
|
+
# Initialize a converter object
|
91
|
+
converter = Gondola::Converter.new( file )
|
92
|
+
# Set global information
|
93
|
+
global = {}
|
94
|
+
global[:job_name] = converter.name
|
95
|
+
if conf[:project_name]
|
96
|
+
global[:job_name] = "#{conf[:project_name]} - #{global[:job_name]}"
|
97
|
+
end
|
98
|
+
global[:browser_url] = conf[:base_url]
|
99
|
+
# Spawn n threads
|
100
|
+
Parallel.map( conf[:browsers], :in_threads => conf[:browsers].size ) do |browser|
|
101
|
+
# Convert to symbols
|
102
|
+
browser = browser.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
103
|
+
# Add global information to this configuration
|
104
|
+
browser.merge! global
|
105
|
+
# Request a new selenium object from Sauce
|
106
|
+
selenium = Sauce::Selenium.new( browser )
|
107
|
+
# Begin test using a tester object
|
108
|
+
tester = Gondola::Tester.new( selenium, converter )
|
109
|
+
browser_string = "#{browser[:os]} #{browser[:browser]} #{browser[:browser_version]}"
|
110
|
+
puts "Starting test case \"#{file}\" with: #{browser_string}"
|
111
|
+
tester.begin
|
112
|
+
puts "#{file} finished - Sauce Job ID: #{tester.job_id}"
|
113
|
+
end
|
114
|
+
puts
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gondola
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.1.
|
5
|
+
version: 1.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matthew Perry
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- examples/gondola_agora_pass.html
|
54
54
|
- lib/gondola/converter.rb
|
55
55
|
- lib/gondola/tester.rb
|
56
|
+
- lib/gondola/testrunner.rb
|
56
57
|
- lib/gondola.rb
|
57
58
|
has_rdoc: true
|
58
59
|
homepage: https://github.com/perrym5/Gondola_Gem
|