parallel_split_test 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d47db7668cac84b19a06abb0f28fd4f616305c73
4
+ data.tar.gz: 8540f31e03bc0c3ef75df0ca1f35ca8fecdb2fb9
5
+ SHA512:
6
+ metadata.gz: 5549fef2328692d9f6595dde32ef0c15be9f5593b323526d2f020fb06b269a0c99aaed669fab2e880d2280da00a03373799d17620fd97b902fb0cce632e89de9
7
+ data.tar.gz: 27e9cf6279d5ca9003f449ebce3ab3e5a8b61be2776161d47af9e61923ba21fe4efa9d510104f8c64456db4126cc3e920e90f992cd45f61f8c4a703b82c87931
data/Readme.md CHANGED
@@ -2,7 +2,10 @@ Split a big test file into multiple chunks and run them in parallel
2
2
 
3
3
  Install
4
4
  =======
5
- gem install parallel_split_test
5
+
6
+ ```Bash
7
+ gem install parallel_split_test
8
+ ```
6
9
 
7
10
  Usage
8
11
  =====
@@ -61,16 +64,18 @@ Took 10.06 seconds with 2 processes
61
64
 
62
65
  TIPS
63
66
  ====
67
+ - use `-o/--out` to get unified/clean output from all processes
64
68
  - set number of processes to use with `PARALLEL_SPLIT_TEST_PROCESSES` environment variable
69
+ - [unify JUnit output](http://blog.tech.renttherunway.com/?p=631) for rspec
65
70
 
66
71
  TODO
67
72
  ====
68
73
  - Cucumber support
69
- - Test::Unit support
74
+ - Test::Unit / Minitest support
70
75
 
71
76
  Author
72
77
  ======
73
78
  [Michael Grosser](http://grosser.it)<br/>
74
79
  michael@grosser.it<br/>
75
80
  License: MIT<br/>
76
- [![Build Status](https://secure.travis-ci.org/grosser/parallel_split_test.png)](http://travis-ci.org/grosser/parallel_split_test)
81
+ [![Build Status](https://travis-ci.org/grosser/parallel_split_test.png)](https://travis-ci.org/grosser/parallel_split_test)
@@ -5,13 +5,15 @@ require 'rspec'
5
5
  require 'parallel_split_test/core_ext/rspec_example'
6
6
 
7
7
  module ParallelSplitTest
8
- class CommandLine < RSpec::Core::CommandLine
8
+ class CommandLine < RSpec::Core::Runner
9
9
  def initialize(args)
10
10
  @args = args
11
11
  super
12
12
  end
13
13
 
14
14
  def run(err, out)
15
+ @options = RSpec::Core::ConfigurationOptions.new(@args)
16
+
15
17
  processes = ParallelSplitTest.choose_number_of_processes
16
18
  out.puts "Running examples in #{processes} processes"
17
19
 
@@ -38,7 +40,6 @@ module ParallelSplitTest
38
40
  def modify_out_file_in_args(process_number)
39
41
  @args[out_file_position] = "#{out_file}.#{process_number}"
40
42
  @options = RSpec::Core::ConfigurationOptions.new(@args)
41
- @options.parse_options
42
43
  end
43
44
 
44
45
  def set_test_env_number(process_number)
@@ -75,25 +76,17 @@ module ParallelSplitTest
75
76
  def run_group_of_tests
76
77
  example_count = @world.example_count / ParallelSplitTest.processes
77
78
 
78
- @configuration.reporter.report(example_count, seed) do |reporter|
79
- begin
80
- @configuration.run_hook(:before, :suite)
81
- groups = @world.example_groups.ordered
82
- results = groups.map {|g| g.run(reporter)}
83
- results.all? ? 0 : @configuration.failure_exit_code
84
- ensure
85
- @configuration.run_hook(:after, :suite)
86
- end
79
+ @configuration.reporter.report(example_count) do |reporter|
80
+ groups = @world.example_groups
81
+ results = groups.map {|g| g.run(reporter)}
82
+ results.all? ? 0 : @configuration.failure_exit_code
87
83
  end
88
84
  end
89
85
 
90
- def seed
91
- @configuration.randomize? ? @configuration.seed : nil
92
- end
93
-
86
+ # https://github.com/rspec/rspec-core/blob/6ee92a0d47bcb1f3abcd063dca2cee005356d709/lib/rspec/core/runner.rb#L93
94
87
  def setup_copied_from_rspec(err, out)
95
88
  @configuration.error_stream = err
96
- @configuration.output_stream ||= out
89
+ @configuration.output_stream = out if @configuration.output_stream == $stdout
97
90
  @options.configure(@configuration)
98
91
  @configuration.load_spec_files
99
92
  @world.announce_filters
@@ -1,3 +1,3 @@
1
1
  module ParallelSplitTest
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_split_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Grosser
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-16 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '2'
19
+ version: 3.1.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '2'
26
+ version: 3.1.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: parallel
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.5.13
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.5.13
46
41
  description:
@@ -50,12 +45,6 @@ executables:
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
- - .gitignore
54
- - .rspec
55
- - .travis.yml
56
- - Gemfile
57
- - Gemfile.lock
58
- - Rakefile
59
48
  - Readme.md
60
49
  - bin/parallel_split_test
61
50
  - lib/parallel_split_test.rb
@@ -64,39 +53,28 @@ files:
64
53
  - lib/parallel_split_test/output_recorder.rb
65
54
  - lib/parallel_split_test/runner.rb
66
55
  - lib/parallel_split_test/version.rb
67
- - parallel_split_test.gemspec
68
- - spec/parallel_split_test/output_recorder_spec.rb
69
- - spec/parallel_split_test_spec.rb
70
- - spec/spec_helper.rb
71
- homepage: http://github.com/grosser/parallel_split_test
56
+ homepage: https://github.com/grosser/parallel_split_test
72
57
  licenses:
73
58
  - MIT
59
+ metadata: {}
74
60
  post_install_message:
75
61
  rdoc_options: []
76
62
  require_paths:
77
63
  - lib
78
64
  required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
65
  requirements:
81
- - - ! '>='
66
+ - - ">="
82
67
  - !ruby/object:Gem::Version
83
68
  version: '0'
84
- segments:
85
- - 0
86
- hash: 4514306617232661236
87
69
  required_rubygems_version: !ruby/object:Gem::Requirement
88
- none: false
89
70
  requirements:
90
- - - ! '>='
71
+ - - ">="
91
72
  - !ruby/object:Gem::Version
92
73
  version: '0'
93
- segments:
94
- - 0
95
- hash: 4514306617232661236
96
74
  requirements: []
97
75
  rubyforge_project:
98
- rubygems_version: 1.8.25
76
+ rubygems_version: 2.2.2
99
77
  signing_key:
100
- specification_version: 3
78
+ specification_version: 4
101
79
  summary: Split a big test file into multiple chunks and run them in parallel
102
80
  test_files: []
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- spec/tmp*
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --backtrace
@@ -1,4 +0,0 @@
1
- rvm:
2
- - ree
3
- - 1.9.3
4
- - 2.0.0
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- gem "rake"
5
- gem "bump"
@@ -1,30 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- parallel_split_test (0.3.0)
5
- parallel (>= 0.5.13)
6
- rspec (>= 2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- bump (0.4.1)
12
- diff-lcs (1.2.3)
13
- parallel (0.6.4)
14
- rake (10.0.4)
15
- rspec (2.13.0)
16
- rspec-core (~> 2.13.0)
17
- rspec-expectations (~> 2.13.0)
18
- rspec-mocks (~> 2.13.0)
19
- rspec-core (2.13.1)
20
- rspec-expectations (2.13.0)
21
- diff-lcs (>= 1.1.3, < 2.0)
22
- rspec-mocks (2.13.1)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- bump
29
- parallel_split_test!
30
- rake
data/Rakefile DELETED
@@ -1,11 +0,0 @@
1
- require 'bundler/setup'
2
- require 'bundler/gem_tasks'
3
- require 'bump/tasks'
4
-
5
- task :default do
6
- sh "rspec spec/"
7
- end
8
-
9
- task :selftest do
10
- sh "./bin/parallel_split_test spec/"
11
- end
@@ -1,15 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
- name = "parallel_split_test"
3
- require "#{name}/version"
4
-
5
- Gem::Specification.new name, ParallelSplitTest::VERSION do |s|
6
- s.summary = "Split a big test file into multiple chunks and run them in parallel"
7
- s.authors = ["Michael Grosser"]
8
- s.email = "michael@grosser.it"
9
- s.homepage = "http://github.com/grosser/#{name}"
10
- s.files = `git ls-files`.split("\n")
11
- s.executables = ["parallel_split_test"]
12
- s.add_dependency "rspec", ">=2"
13
- s.add_dependency "parallel", ">=0.5.13"
14
- s.license = "MIT"
15
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ParallelSplitTest::OutputRecorder do
4
- ['write', 'puts', 'print'].each do |method|
5
- it "records #{method}" do
6
- out = StringIO.new("")
7
- recorder = ParallelSplitTest::OutputRecorder.new(out)
8
- recorder.send(method, "XXX")
9
-
10
- # output got recorded
11
- recorder.recorded.strip.should == "XXX"
12
- out.read.should == ""
13
-
14
- # output was written to original
15
- out.rewind
16
- out.read.strip.should == "XXX"
17
- end
18
- end
19
-
20
- it "can puts without arguments" do
21
- out = StringIO.new("")
22
- recorder = ParallelSplitTest::OutputRecorder.new(out)
23
- recorder.puts
24
- recorder.recorded.should == "\n"
25
- end
26
- end
@@ -1,268 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ParallelSplitTest do
4
- it "has a VERSION" do
5
- ParallelSplitTest::VERSION.should =~ /^[\.\da-z]+$/
6
- end
7
-
8
- describe ".best_number_of_processes" do
9
- before do
10
- ENV['PARALLEL_SPLIT_TEST_PROCESSES'] = nil
11
- end
12
-
13
- let(:count) { ParallelSplitTest.send(:best_number_of_processes) }
14
-
15
- it "uses ENV" do
16
- ENV['PARALLEL_SPLIT_TEST_PROCESSES'] = "5"
17
- count.should == 5
18
- end
19
-
20
- it "uses physical_processor_count" do
21
- Parallel.stub(:physical_processor_count).and_return 6
22
- count.should == 6
23
- end
24
-
25
- it "uses processor_count if everything else fails" do
26
- Parallel.stub(:physical_processor_count).and_return 0
27
- Parallel.stub(:processor_count).and_return 7
28
- count.should == 7
29
- end
30
- end
31
-
32
- describe "cli" do
33
- def run(command, options={})
34
- result = `#{command} 2>&1`
35
- message = (options[:fail] ? "SUCCESS BUT SHOULD FAIL" : "FAIL")
36
- raise "[#{message}] #{result} [#{command}]" if $?.success? == !!options[:fail]
37
- result
38
- end
39
-
40
- def write(path, content)
41
- run "mkdir -p #{File.dirname(path)}" unless File.exist?(File.dirname(path))
42
- File.open(path, 'w'){|f| f.write content }
43
- path
44
- end
45
-
46
- def parallel_split_test(x, options={})
47
- run "PARALLEL_SPLIT_TEST_PROCESSES=#{options[:process_count] || 2} ../../bin/parallel_split_test #{x}", options
48
- end
49
-
50
- def time
51
- start = Time.now.to_f
52
- yield
53
- Time.now.to_f - start
54
- end
55
-
56
- let(:root) { File.expand_path('../../', __FILE__) }
57
-
58
- around do |example|
59
- dir = "spec/tmp#{ENV['TEST_ENV_NUMBER']}"
60
- run "rm -rf #{dir} ; mkdir #{dir}"
61
- Dir.chdir(dir, &example)
62
- run "rm -rf #{dir}"
63
- end
64
-
65
- describe "printing version" do
66
- it "prints version on -v" do
67
- parallel_split_test("-v").strip.should =~ /^[\.\da-z]+$/
68
- end
69
-
70
- it "prints version on --version" do
71
- parallel_split_test("--version").strip.should =~ /^[\.\da-z]+$/
72
- end
73
- end
74
-
75
- describe "printing help" do
76
- it "prints help on -h" do
77
- parallel_split_test("-h").should include("Usage")
78
- end
79
-
80
- it "prints help on --help" do
81
- parallel_split_test("-h").should include("Usage")
82
- end
83
-
84
- it "prints help on no arguments" do
85
- parallel_split_test("").should include("Usage")
86
- end
87
- end
88
-
89
- describe "running tests" do
90
- it "runs in different processes" do
91
- write "xxx_spec.rb", <<-RUBY
92
- describe "X" do
93
- it "a" do
94
- puts "it-ran-a-in-\#{ENV['TEST_ENV_NUMBER']}-"
95
- end
96
- end
97
-
98
- describe "Y" do
99
- it "b" do
100
- puts "it-ran-b-in-\#{ENV['TEST_ENV_NUMBER']}-"
101
- end
102
- end
103
- RUBY
104
- result = parallel_split_test "xxx_spec.rb"
105
- result.scan('1 example, 0 failures').size.should == 4
106
- result.scan(/it-ran-.-in-.?-/).sort.should == ["it-ran-a-in--", "it-ran-b-in-2-"]
107
- end
108
-
109
- it "runs in different processes for many examples/processes" do
110
- write "xxx_spec.rb", <<-RUBY
111
- describe "X" do
112
- #{(0...3).to_a.map{|i| "it{ puts 'it-ran-"+ i.to_s+"-in-'+ENV['TEST_ENV_NUMBER'].to_s + '-' }" }.join("\n")}
113
- describe "Y" do
114
- #{(3...6).to_a.map{|i| "it{ puts 'it-ran-"+ i.to_s+"-in-'+ENV['TEST_ENV_NUMBER'].to_s + '-' }" }.join("\n")}
115
- describe "Y" do
116
- #{(6...9).to_a.map{|i| "it{ puts 'it-ran-"+ i.to_s+"-in-'+ENV['TEST_ENV_NUMBER'].to_s + '-' }" }.join("\n")}
117
- end
118
- end
119
- end
120
- RUBY
121
- result = parallel_split_test "xxx_spec.rb", :process_count => 3
122
- result.scan('3 examples, 0 failures').size.should == 6
123
- result.scan(/it-ran-.-in-.?-/).size.should == 9
124
- end
125
-
126
- it "runs faster" do
127
- write "xxx_spec.rb", <<-RUBY
128
- describe "X" do
129
- it { sleep 1.5 }
130
- end
131
-
132
- describe "Y" do
133
- it { sleep 1.5 }
134
- end
135
- RUBY
136
-
137
- time{ parallel_split_test "xxx_spec.rb" }.should < 3
138
- end
139
-
140
- it "splits based on examples" do
141
- write "xxx_spec.rb", <<-RUBY
142
- describe "X" do
143
- describe "Y" do
144
- it { sleep 1.5 }
145
- it { sleep 1.5 }
146
- end
147
- end
148
- RUBY
149
-
150
- result = nil
151
- time{ result = parallel_split_test "xxx_spec.rb" }.should < 3
152
- result.scan('1 example, 0 failures').size.should == 4
153
- end
154
-
155
- it "sets up TEST_ENV_NUMBER before loading the test files, so db connections are set up correctly" do
156
- write "xxx_spec.rb", 'puts "ENV_IS_#{ENV[\'TEST_ENV_NUMBER\']}_"'
157
- result = parallel_split_test "xxx_spec.rb"
158
- result.scan(/ENV_IS_.?_/).sort.should == ["ENV_IS_2_", "ENV_IS__"]
159
- end
160
-
161
- it "fails when one of the processes fail" do
162
- write "xxx_spec.rb", <<-RUBY
163
- describe "X" do
164
- it { sleep 0.1; raise }
165
- it { sleep 0.1 }
166
- end
167
- RUBY
168
-
169
- # test works because if :fail => true does not fail it raises
170
- result = parallel_split_test "xxx_spec.rb", :fail => true
171
- result.should include('1 example, 1 failure')
172
- result.should include('1 example, 0 failures')
173
- end
174
-
175
- it "fails when all processes fail" do
176
- write "xxx_spec.rb", <<-RUBY
177
- describe "X" do
178
- it { sleep 0.1; raise }
179
- it { sleep 0.1; raise }
180
- end
181
- RUBY
182
-
183
- # test works because if :fail => true does not fail it raises
184
- result = parallel_split_test "xxx_spec.rb", :fail => true
185
- result.scan('1 example, 1 failure').size.should == 4
186
- end
187
-
188
- it "passes when no tests where run" do
189
- write "xxx_spec.rb", <<-RUBY
190
- describe "X" do
191
- end
192
- RUBY
193
- result = parallel_split_test "xxx_spec.rb"
194
- result.should include('No examples found')
195
- end
196
-
197
- it "prints a summary before running" do
198
- write "xxx_spec.rb", <<-RUBY
199
- describe "X" do
200
- end
201
- RUBY
202
- result = parallel_split_test "xxx_spec.rb"
203
- result.should include('Running examples in 2 processes')
204
- end
205
-
206
- it "prints a runtime summary at the end" do
207
- write "xxx_spec.rb", <<-RUBY
208
- describe "X" do
209
- end
210
- RUBY
211
- result = parallel_split_test "xxx_spec.rb"
212
- result.should =~ /Took [\d\.]+ seconds with 2 processes/
213
- end
214
-
215
- it "reprints all summary lines at the end" do
216
- write "xxx_spec.rb", <<-RUBY
217
- describe "X" do
218
- it { }
219
- it { sleep 0.1 }
220
- end
221
- RUBY
222
- result = parallel_split_test "xxx_spec.rb"
223
- result.should include("1 example, 0 failures\n1 example, 0 failures")
224
- end
225
-
226
- it "can use rspec options" do
227
- write "xxx_spec.rb", <<-RUBY
228
- describe "xxx" do
229
- it "yyy" do
230
- end
231
- end
232
- RUBY
233
-
234
- result = parallel_split_test "xxx_spec.rb --format html"
235
- result.should include "</body>"
236
- end
237
-
238
- it "writes a unified --out" do
239
- write "xxx_spec.rb", <<-RUBY
240
- describe "xxx" do
241
- it "yyy" do
242
- end
243
-
244
- it "zzz" do
245
- end
246
- end
247
- RUBY
248
-
249
- result = parallel_split_test "xxx_spec.rb --format d --out xxx"
250
-
251
- # output does not show up in stdout
252
- result.should_not include "xxx"
253
- result.should_not include "yyy"
254
-
255
- # basic output is still there
256
- result.should include "Running examples in"
257
-
258
- # recorded output is combination of both
259
- out = File.read("xxx")
260
- out.should include "yyy"
261
- out.should include "zzz"
262
-
263
- # parts are cleaned up
264
- Dir["xxx.*"].should == []
265
- end
266
- end
267
- end
268
- end
@@ -1,4 +0,0 @@
1
- $LOAD_PATH.unshift 'lib'
2
- require 'parallel_split_test'
3
- require 'parallel_split_test/version'
4
- require 'parallel_split_test/output_recorder'