multicuke 0.1.2 → 0.1.3

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/Gemfile CHANGED
@@ -2,4 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'cucumber'
4
4
  gem 'rspec'
5
- gem 'nokogiri'
5
+ gem 'nokogiri'
6
+ gem 'forkoff'
@@ -4,15 +4,15 @@ module Multicuke
4
4
 
5
5
  # Wrapper of {Kernel#system} method for test/mock
6
6
  class SystemCommand
7
-
7
+
8
8
  def run(full_command_as_array)
9
9
  system *full_command_as_array
10
- end
10
+ end
11
11
 
12
12
  def exit(status = 0)
13
13
  Kernel.exit(status == 0)
14
14
  end
15
-
15
+
16
16
  end
17
17
 
18
18
  # Set of features under one specific directory
@@ -45,11 +45,11 @@ module Multicuke
45
45
  (scenarios_results.include?"failed") || (steps_results.include?"failed")
46
46
  end
47
47
 
48
- # Human readable name used for index page (ex: user_logout --> User logout)
48
+ # Human readable name used for index page (ex: user_logout --> User logout)
49
49
  def human_name
50
50
  name.gsub(/[_-]/, " ").capitalize
51
51
  end
52
-
52
+
53
53
  end
54
54
 
55
55
  # Actual clas that will spawn one command process per directory of features collected
@@ -65,7 +65,7 @@ module Multicuke
65
65
  # Optional full path for generated reports. Default to ../{features_root_path}.
66
66
  attr_accessor :output_path
67
67
 
68
- # Optional regexp for name of features directories to exclude.
68
+ # Optional regexp for name of features directories to exclude.
69
69
  attr_accessor :excluded_dirs
70
70
 
71
71
  # Optional only the features directories to be included
@@ -74,6 +74,9 @@ module Multicuke
74
74
  # Array of extra options to pass to the command. Ex: ["-p", "my_profile", "--backtrace"]
75
75
  attr_accessor :extra_options
76
76
 
77
+ # Define the size for the pool of forks. Default is 5
78
+ attr_accessor :forks_pool_size
79
+
77
80
  # Full final path where html reports will be generated
78
81
  attr_reader :reports_path
79
82
 
@@ -92,14 +95,15 @@ module Multicuke
92
95
  yield self if block_given?
93
96
 
94
97
  @dry_run = false if dry_run.nil?
98
+ @forks_pool_size ||= 5
95
99
  @require_features_root_option = true if require_features_root_option.nil?
96
100
  @output_dir_name = "cucumber_reports" unless output_dir_name
97
101
  @output_path = File.expand_path("..", features_root_path) unless output_path
98
- @excluded_dirs = [] unless excluded_dirs
99
- @included_only_dirs = [] unless included_only_dirs
100
- @extra_options = [] unless extra_options
102
+ @excluded_dirs ||= []
103
+ @included_only_dirs ||= []
104
+ @extra_options ||= []
101
105
  @reports_path = File.join(output_path, output_dir_name)
102
- @system_command = SystemCommand.new unless system_command
106
+ @system_command ||= SystemCommand.new
103
107
  end
104
108
 
105
109
  def start
@@ -117,10 +121,9 @@ module Multicuke
117
121
  if dry_run
118
122
  0
119
123
  else
120
- features_dirs.each { |features_dir|
121
- report_file_path = File.join(reports_path, "#{features_dir.name}.html")
122
- feature_full_path = File.join(features_root_path, "#{features_dir.name}")
123
- fork {
124
+ features_dirs.forkoff!(:processes => forks_pool_size){ |features_dir|
125
+ report_file_path = File.join(reports_path, "#{features_dir.name}.html")
126
+ feature_full_path = File.join(features_root_path, "#{features_dir.name}")
124
127
  main_command = %W[bundle exec cucumber #{feature_full_path}]
125
128
  options = %W[--format html --out #{report_file_path}]
126
129
  options.concat %W[--require #{features_root_path}] if require_features_root_option
@@ -128,8 +131,8 @@ module Multicuke
128
131
  result = system_command.run full_command
129
132
  puts "Features '#{features_dir.name}' finished. #{result ? 'SUCCESS' : 'FAILURE'} (pid: #{Process.pid})"
130
133
  exit(result)
131
- }
132
134
  }
135
+
133
136
  global_exit_status = Process.waitall.inject(0) {|result, process|
134
137
  pid, status = *process
135
138
  result + status.exitstatus
@@ -148,7 +151,7 @@ module Multicuke
148
151
  scenarios = scenarios_match ? scenarios_match.captures.first : ""
149
152
  steps_match = content.match(/\d+ steps? \((.*?)\)/)
150
153
  steps = steps_match ? steps_match.captures.first : ""
151
-
154
+
152
155
  features_dir.scenarios_results = scenarios
153
156
  features_dir.steps_results = steps
154
157
  features_dir.duration = duration
@@ -1,3 +1,3 @@
1
1
  module Multicuke
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/multicuke.rb CHANGED
@@ -4,7 +4,4 @@ require "multicuke/runner"
4
4
  require 'fileutils'
5
5
  require 'builder'
6
6
  require 'nokogiri'
7
-
8
- module Multicuke
9
- # Your code goes here...
10
- end
7
+ require 'forkoff'
data/spec/runner_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  module Multicuke
4
4
 
@@ -9,6 +9,7 @@ module Multicuke
9
9
  r.output_path = "my_output_path"
10
10
  r.dry_run = true
11
11
  r.require_features_root_option = false
12
+ r.forks_pool_size = 10
12
13
  r.excluded_dirs = ["my_first_dir", "my_second_dir"]
13
14
  r.extra_options = ["-p", "profile"]
14
15
  end
@@ -17,6 +18,7 @@ module Multicuke
17
18
  runner.output_dir_name.should == "my_reports"
18
19
  runner.output_path.should == "my_output_path"
19
20
  runner.dry_run.should be_true
21
+ runner.forks_pool_size.should == 10
20
22
  runner.require_features_root_option.should be_false
21
23
  runner.excluded_dirs.should include("my_first_dir", "my_second_dir")
22
24
  runner.extra_options.should include("-p", "profile")
@@ -27,10 +29,11 @@ module Multicuke
27
29
  runner.output_dir_name.should == "cucumber_reports"
28
30
  runner.output_path.should match "multicuke/spec$"
29
31
  runner.dry_run.should be_false
32
+ runner.forks_pool_size.should == 5
30
33
  runner.require_features_root_option.should be_true
31
34
  runner.excluded_dirs.should be_empty
32
35
  runner.extra_options.should be_empty
33
36
  end
34
- end
37
+ end
35
38
 
36
39
  end
@@ -10,7 +10,6 @@ describe "System command" do
10
10
  r.system_command = mock('SystemCommand mock')
11
11
  end
12
12
 
13
- runner.should_receive(:fork)
14
13
  runner.system_command.should_receive(:exit).with(0)
15
14
  runner.start
16
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multicuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-08 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 1.8.24
114
+ rubygems_version: 1.8.25
115
115
  signing_key:
116
116
  specification_version: 3
117
117
  summary: Run one cucumber process per features directory