gondola 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/gondola +39 -98
  2. data/examples/config.yml +6 -6
  3. data/lib/gondola.rb +3 -0
  4. metadata +3 -19
data/bin/gondola CHANGED
@@ -10,121 +10,62 @@
10
10
  require 'rubygems'
11
11
  require 'yaml'
12
12
  require 'cmdparse'
13
- require 'parallel'
14
- require 'sauce'
15
13
 
16
14
  lib_dir = File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'lib/' ) )
17
15
  $LOAD_PATH.unshift( lib_dir ) unless $LOAD_PATH.include?( lib_dir )
18
16
 
19
17
  require 'gondola'
20
18
 
21
- # Function to configure sauce labs' gem with proper api information
22
- # as well as populate the configuration for the specific test being run
23
- def configure( file )
24
- puts "Configuring"
25
- # Load possible paths for the api information (Sauce already does this to some extent
26
- # but more paths were required for this gem
27
- api = {}
28
- apiPaths = [
29
- File.expand_path( File.join( file, "ondemand.yml" ) ),
30
- File.expand_path( File.join( File.dirname( file ), "ondemand.yml" ) ),
31
- File.expand_path( File.join( File.dirname( file ), "../ondemand.yml" ) ),
32
- ]
33
- apiPaths.each do |path|
34
- if File.exists?( path )
35
- api = YAML.load_file( path )
36
- break
37
- end
38
- end
39
-
40
- # Load possible paths for the configuration information
41
- conf = {}
42
- configPaths = [
43
- File.expand_path( File.join( File.dirname( file ), "../config.yml" ) ),
44
- File.expand_path( File.join( File.dirname( file ), "config.yml" ) ),
45
- File.expand_path( File.join( file, "config.yml" ) ),
46
- ]
47
- configPaths.each do |path|
48
- if File.exists?( path )
49
- conf.merge! YAML.load_file( path )
50
- end
51
- end
52
-
53
- # Configure Sauce accordingly
54
- Sauce.config do |config|
55
- if api["username"]
56
- config.username = api["username"]
57
- end
58
- if api["access_key"]
59
- config.access_key = api["access_key"]
60
- end
61
- config.browser_url = conf["base_url"]
62
- config.browsers = conf["browsers"]
63
- config.job_name = conf["project_name"]
64
- end
65
- end
66
-
67
- # Function to run and parallelize the given test on the given browsers
68
- def run( file, browsers )
69
- # Initialize a converter object
70
- converter = Gondola::Converter.new( file )
71
- # Spawn n threads
72
- Parallel.map( browsers, :in_threads => browsers.size ) do |browser|
73
- os,browser,version = browser
74
- name = converter.name
75
- if Sauce.get_config.job_name
76
- name = "#{Sauce.get_config.job_name} - #{name}"
77
- end
78
- # Request a new selenium object from Sauce
79
- selenium = Sauce::Selenium.new({:os => os, :browser => browser, :browser_version => version,
80
- :job_name => name })
81
- # Begin test using a tester object
82
- tester = Gondola::Tester.new( selenium, converter )
83
- puts "Starting test case \"#{file}\" with: #{os} #{browser} #{version}"
84
- tester.begin
85
- puts "#{file} finished - Sauce Job ID: #{tester.job_id}"
86
- end
87
- puts
88
- end
89
-
90
19
  # Command parsing stuff
91
20
  cmd = CmdParse::CommandParser.new( true, true )
92
- cmd.program_name = "gondola "
21
+ cmd.program_name = "gondola"
22
+ cmd.program_version = "Gondola v1.1.0"
93
23
  cmd.add_command( CmdParse::HelpCommand.new )
24
+ cmd.add_command( CmdParse::VersionCommand.new )
94
25
 
95
26
  # Run command
96
27
  class RunCommand < CmdParse::Command
97
- def usage
98
- "Usage: #{commandparser.program_name}run PATH [CONFIG]"
28
+ def initialize
29
+ super( 'run', false )
30
+ @opts = {}
31
+ self.short_desc = "Run an entire test suite or one test case"
32
+ # User supplied options for running a suite
33
+ self.options = CmdParse::OptionParserWrapper.new do |opt|
34
+ opt.on( '-s', '--super_parallel', 'Execute all test cases at once' ) do |sp|
35
+ @opts[:super_parallel] = true
36
+ end
37
+ opt.on( '-r', '--recursive', 'Execute all sub suites' ) do |r|
38
+ @opts[:recursive] = true
39
+ end
40
+ opt.on( '-l', '--legacy', 'Allow legacy Gondola suites' ) do |l|
41
+ @opts[:legacy] = true
42
+ end
43
+ end
99
44
  end
100
- end
101
- run = RunCommand.new( 'run', false )
102
- run.short_desc = "Run an entire test suite or one test case"
103
- run.set_execution_block do |args|
104
- if args.length < 1
105
- puts run.usage
106
- exit 1
45
+
46
+ # Proper usage format
47
+ def usage
48
+ "Usage: #{commandparser.program_name} run [options] [tests]"
107
49
  end
108
- test = args[0]
109
- # Can either provide directory or file
110
- if File.directory?( test )
111
- puts "Running test suite \"#{test}\""
112
- configure( test )
113
- Dir.chdir( test )
114
- dirlist = Dir.glob( "*.html" )
115
- dirlist.each do |file|
116
- run( file, Sauce.get_config.browsers )
50
+
51
+ # Function that is executed when a user issues a run command
52
+ def execute( args )
53
+ if args.length < 1
54
+ puts run.usage
55
+ exit 1
56
+ end
57
+ test = args[0]
58
+ # Can either provide directory or file
59
+ if File.exists?( test )
60
+ runner = Gondola::TestRunner.new
61
+ runner.addTest( test )
62
+ runner.run( @opts )
63
+ else
64
+ puts "Could not find file \"#{test}\""
117
65
  end
118
- elsif File.exists?( test )
119
- puts "Running test case \"#{test}\""
120
- configure( test )
121
- run( test, Sauce.get_config.browsers )
122
- else
123
- puts "Could not find file \"#{test}\""
124
66
  end
125
67
  end
126
- cmd.add_command( run )
68
+ cmd.add_command( RunCommand.new )
127
69
 
128
70
  cmd.parse
129
-
130
71
  exit( 0 )
data/examples/config.yml CHANGED
@@ -2,10 +2,10 @@ project_name: "Test Project"
2
2
  base_url: "http://www.google.com"
3
3
  browsers:
4
4
  -
5
- - "Windows 2003"
6
- - "firefox"
7
- - "3.6"
5
+ os: "Windows 2003"
6
+ browser: "firefox"
7
+ browser_version: "3.6"
8
8
  -
9
- - "Windows 2003"
10
- - "iexplore"
11
- - "8"
9
+ os: "Windows 2003"
10
+ browser: "iexplore"
11
+ browser_version: "8"
data/lib/gondola.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'gondola/converter'
3
3
  require 'gondola/tester'
4
+ require 'gondola/testrunner'
5
+ require 'sauce'
6
+ require 'parallel'
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gondola
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 4
9
- version: 1.0.4
4
+ prerelease:
5
+ version: 1.1.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Matthew Perry
@@ -25,10 +21,6 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 17
31
- - 5
32
24
  version: 0.17.5
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -40,10 +32,6 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- - 5
46
- - 2
47
35
  version: 0.5.2
48
36
  type: :runtime
49
37
  version_requirements: *id002
@@ -80,21 +68,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
68
  requirements:
81
69
  - - ">="
82
70
  - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
71
  version: "0"
86
72
  required_rubygems_version: !ruby/object:Gem::Requirement
87
73
  none: false
88
74
  requirements:
89
75
  - - ">="
90
76
  - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
77
  version: "0"
94
78
  requirements: []
95
79
 
96
80
  rubyforge_project:
97
- rubygems_version: 1.3.7
81
+ rubygems_version: 1.6.1
98
82
  signing_key:
99
83
  specification_version: 3
100
84
  summary: Ruby command line utility and library for integrating the Selenium IDE more tightly with Sauce Labs' Ondemand services