parallel_split_test 0.1.5 → 0.2.0
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.lock +1 -1
- data/Readme.md +7 -5
- data/bin/parallel_split_test +1 -1
- data/lib/parallel_split_test/command_line.rb +13 -4
- data/lib/parallel_split_test/output_recorder.rb +24 -0
- data/lib/parallel_split_test/runner.rb +15 -1
- data/lib/parallel_split_test/version.rb +1 -1
- data/spec/parallel_split_test/output_recorder_spec.rb +26 -0
- data/spec/parallel_split_test_spec.rb +32 -3
- data/spec/spec_helper.rb +2 -1
- metadata +10 -8
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -38,7 +38,9 @@ To use 1 database per test-process, add this to your `config/database.yml`<br/>
|
|
38
38
|
Output
|
39
39
|
======
|
40
40
|
|
41
|
-
|
41
|
+
parallel_split_test spec/xx_spec.rb
|
42
|
+
|
43
|
+
Running examples in 2 processes
|
42
44
|
.
|
43
45
|
|
44
46
|
Finished in 5 seconds
|
@@ -48,9 +50,10 @@ Output
|
|
48
50
|
Finished in 1 seconds
|
49
51
|
2 examples, 0 failures
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
Summary:
|
54
|
+
1 example, 0 failures
|
55
|
+
2 examples, 0 failures
|
56
|
+
Took 10.06 seconds with 2 processes
|
54
57
|
|
55
58
|
|
56
59
|
TIPS
|
@@ -59,7 +62,6 @@ TIPS
|
|
59
62
|
|
60
63
|
TODO
|
61
64
|
====
|
62
|
-
- re-print summary of all test results
|
63
65
|
- Cucumber support
|
64
66
|
- Test::Unit support
|
65
67
|
|
data/bin/parallel_split_test
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'parallel_split_test'
|
2
|
+
require 'parallel_split_test/output_recorder'
|
2
3
|
require 'parallel'
|
3
4
|
require 'rspec'
|
4
5
|
require 'parallel_split_test/core_ext/rspec_example'
|
@@ -6,21 +7,29 @@ require 'parallel_split_test/core_ext/rspec_example'
|
|
6
7
|
module ParallelSplitTest
|
7
8
|
class CommandLine < RSpec::Core::CommandLine
|
8
9
|
def run(err, out)
|
9
|
-
ParallelSplitTest.
|
10
|
-
|
11
|
-
Parallel.in_processes(ParallelSplitTest.processes) do |process_number|
|
10
|
+
results = Parallel.in_processes(ParallelSplitTest.processes) do |process_number|
|
12
11
|
ENV['TEST_ENV_NUMBER'] = (process_number == 0 ? '' : (process_number + 1).to_s)
|
12
|
+
out = OutputRecorder.new(out)
|
13
13
|
setup_copied_from_rspec(err, out)
|
14
14
|
|
15
15
|
ParallelSplitTest.example_counter = 0
|
16
16
|
ParallelSplitTest.process_number = process_number
|
17
17
|
|
18
|
-
run_group_of_tests
|
18
|
+
[run_group_of_tests, out.recorded]
|
19
19
|
end
|
20
|
+
|
21
|
+
reprint_result_lines(out, results.map(&:last))
|
22
|
+
results.map(&:first).max # combine exit status
|
20
23
|
end
|
21
24
|
|
22
25
|
private
|
23
26
|
|
27
|
+
def reprint_result_lines(out, printed_outputs)
|
28
|
+
out.puts
|
29
|
+
out.puts "Summary:"
|
30
|
+
out.puts printed_outputs.map{|o| o[/.*\d+ failure.*/] }.join("\n")
|
31
|
+
end
|
32
|
+
|
24
33
|
def run_group_of_tests
|
25
34
|
example_count = @world.example_count / ParallelSplitTest.processes
|
26
35
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
|
3
|
+
module ParallelSplitTest
|
4
|
+
class OutputRecorder
|
5
|
+
def initialize(out)
|
6
|
+
@recorded = StringIO.new
|
7
|
+
@out = out
|
8
|
+
end
|
9
|
+
|
10
|
+
%w[puts write print putc].each do |method|
|
11
|
+
class_eval <<-RUBY, __FILE__, __LINE__
|
12
|
+
def #{method}(*args)
|
13
|
+
@recorded.puts(*args)
|
14
|
+
@out.puts(*args)
|
15
|
+
end
|
16
|
+
RUBY
|
17
|
+
end
|
18
|
+
|
19
|
+
def recorded
|
20
|
+
@recorded.rewind
|
21
|
+
@recorded.read
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -7,9 +7,23 @@ module ParallelSplitTest
|
|
7
7
|
trap_interrupt
|
8
8
|
options = RSpec::Core::ConfigurationOptions.new(args)
|
9
9
|
options.parse_options
|
10
|
-
|
10
|
+
|
11
|
+
ParallelSplitTest.choose_number_of_processes
|
12
|
+
out.puts "Running examples in #{ParallelSplitTest.processes} processes"
|
13
|
+
|
14
|
+
report_execution_time(out) do
|
15
|
+
ParallelSplitTest::CommandLine.new(options).run(err, out)
|
16
|
+
end
|
11
17
|
ensure
|
12
18
|
RSpec.reset
|
13
19
|
end
|
20
|
+
|
21
|
+
def self.report_execution_time(out)
|
22
|
+
start = Time.now.to_f
|
23
|
+
result = yield
|
24
|
+
runtime = Time.now.to_f - start
|
25
|
+
out.puts "Took %.2f seconds with #{ParallelSplitTest.processes} processes" % runtime
|
26
|
+
result
|
27
|
+
end
|
14
28
|
end
|
15
29
|
end
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -104,7 +104,7 @@ describe ParallelSplitTest do
|
|
104
104
|
end
|
105
105
|
RUBY
|
106
106
|
result = parallel_split_test "xxx_spec.rb"
|
107
|
-
result.scan('1 example, 0 failures').size.should ==
|
107
|
+
result.scan('1 example, 0 failures').size.should == 4
|
108
108
|
result.scan(/it-ran-.-in-.?-/).sort.should == ["it-ran-a-in--", "it-ran-b-in-2-"]
|
109
109
|
end
|
110
110
|
|
@@ -134,7 +134,7 @@ describe ParallelSplitTest do
|
|
134
134
|
|
135
135
|
result = nil
|
136
136
|
time{ result = parallel_split_test "xxx_spec.rb" }.should < 2
|
137
|
-
result.scan('1 example, 0 failures').size.should ==
|
137
|
+
result.scan('1 example, 0 failures').size.should == 4
|
138
138
|
end
|
139
139
|
|
140
140
|
it "sets up TEST_ENV_NUMBER before loading the test files, so db connections are set up correctly" do
|
@@ -167,7 +167,7 @@ describe ParallelSplitTest do
|
|
167
167
|
|
168
168
|
# test works because if :fail => true does not fail it raises
|
169
169
|
result = parallel_split_test "xxx_spec.rb", :fail => true
|
170
|
-
result.scan('1 example, 1 failure').size.should ==
|
170
|
+
result.scan('1 example, 1 failure').size.should == 4
|
171
171
|
end
|
172
172
|
|
173
173
|
it "passes when no tests where run" do
|
@@ -178,6 +178,35 @@ describe ParallelSplitTest do
|
|
178
178
|
result = parallel_split_test "xxx_spec.rb"
|
179
179
|
result.should include('No examples found')
|
180
180
|
end
|
181
|
+
|
182
|
+
it "prints a summary before running" do
|
183
|
+
write "xxx_spec.rb", <<-RUBY
|
184
|
+
describe "X" do
|
185
|
+
end
|
186
|
+
RUBY
|
187
|
+
result = parallel_split_test "xxx_spec.rb"
|
188
|
+
result.should include('Running examples in 2 processes')
|
189
|
+
end
|
190
|
+
|
191
|
+
it "prints a runtime summary at the end" do
|
192
|
+
write "xxx_spec.rb", <<-RUBY
|
193
|
+
describe "X" do
|
194
|
+
end
|
195
|
+
RUBY
|
196
|
+
result = parallel_split_test "xxx_spec.rb"
|
197
|
+
result.should =~ /Took [\d\.]+ seconds with 2 processes/
|
198
|
+
end
|
199
|
+
|
200
|
+
it "reprints all summary lines at the end" do
|
201
|
+
write "xxx_spec.rb", <<-RUBY
|
202
|
+
describe "X" do
|
203
|
+
it { }
|
204
|
+
it { sleep 0.1 }
|
205
|
+
end
|
206
|
+
RUBY
|
207
|
+
result = parallel_split_test "xxx_spec.rb"
|
208
|
+
result.should include("1 example, 0 failures\n1 example, 0 failures")
|
209
|
+
end
|
181
210
|
end
|
182
211
|
end
|
183
212
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_split_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &81205430 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *81205430
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: parallel
|
27
|
-
requirement: &
|
27
|
+
requirement: &81205180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.5.13
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *81205180
|
36
36
|
description:
|
37
37
|
email: michael@grosser.it
|
38
38
|
executables:
|
@@ -49,9 +49,11 @@ files:
|
|
49
49
|
- lib/parallel_split_test.rb
|
50
50
|
- lib/parallel_split_test/command_line.rb
|
51
51
|
- lib/parallel_split_test/core_ext/rspec_example.rb
|
52
|
+
- lib/parallel_split_test/output_recorder.rb
|
52
53
|
- lib/parallel_split_test/runner.rb
|
53
54
|
- lib/parallel_split_test/version.rb
|
54
55
|
- parallel_split_test.gemspec
|
56
|
+
- spec/parallel_split_test/output_recorder_spec.rb
|
55
57
|
- spec/parallel_split_test_spec.rb
|
56
58
|
- spec/spec_helper.rb
|
57
59
|
homepage: http://github.com/grosser/parallel_split_test
|
@@ -69,7 +71,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
71
|
version: '0'
|
70
72
|
segments:
|
71
73
|
- 0
|
72
|
-
hash:
|
74
|
+
hash: 131892335
|
73
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
76
|
none: false
|
75
77
|
requirements:
|
@@ -78,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
80
|
version: '0'
|
79
81
|
segments:
|
80
82
|
- 0
|
81
|
-
hash:
|
83
|
+
hash: 131892335
|
82
84
|
requirements: []
|
83
85
|
rubyforge_project:
|
84
86
|
rubygems_version: 1.8.10
|