parallel_rspec 0.3.1 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/parallel_rspec/client.rb +9 -0
- data/lib/parallel_rspec/runner.rb +7 -8
- data/lib/parallel_rspec/server.rb +22 -8
- data/lib/parallel_rspec/version.rb +1 -1
- data/lib/parallel_rspec/workers.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 773680cd7ac7cc86421fc4511597b488293aa9b0
|
4
|
+
data.tar.gz: 420dff9c171a05bf34e3013c8cb8c0aed377bf0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b347907242eed08bc9edef8f2d59f221519d74d9f30ff6fa8fdb81edac1c7cdfc1df2b1c38566a20aa6a137618909a5a6c539d6f7c5d9ff6dcb92760c8815be
|
7
|
+
data.tar.gz: cbe1cf67c4deab173e1668dae741f555d8b930872a558f08d6d3d71925d06d0c4c38f2f1d5266f2d8cc8a0af8e02c05ba10f0768e39fa493cbf81e1a604f57df
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ This version of ParallelRSpec has been tested with RSpec 3.3.
|
|
30
30
|
|
31
31
|
By default, ParallelRSpec will use two workers. If you would like to use more, set an environment variable:
|
32
32
|
|
33
|
-
$ export WORKERS=
|
33
|
+
$ export WORKERS=4
|
34
34
|
|
35
35
|
ParallelRSpec runs each worker with its own copy of the test database to avoid locking and deadlocking problems. To create these and populate them with your schema, run:
|
36
36
|
|
@@ -57,5 +57,14 @@ module ParallelRSpec
|
|
57
57
|
:shared_group_inclusion_backtrace,
|
58
58
|
:type))
|
59
59
|
end
|
60
|
+
|
61
|
+
def next_example_to_run
|
62
|
+
channel_to_server.write([:next_example_to_run])
|
63
|
+
channel_to_server.read
|
64
|
+
end
|
65
|
+
|
66
|
+
def result(success)
|
67
|
+
channel_to_server.write([:result, success])
|
68
|
+
end
|
60
69
|
end
|
61
70
|
end
|
@@ -66,15 +66,14 @@ module ParallelRSpec
|
|
66
66
|
workers = Workers.new
|
67
67
|
workers.run_test_workers_with_server(server) do |worker, channel_to_server|
|
68
68
|
client = Client.new(channel_to_server)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
success = true
|
70
|
+
while next_example = client.next_example_to_run
|
71
|
+
example_group, example_index = *next_example
|
72
|
+
example = RSpec.world.filtered_examples[example_group][example_index]
|
73
|
+
example_group_instance = example_group.new(example.inspect_output)
|
74
|
+
success = example.run(example_group_instance, client) && success
|
75
75
|
end
|
76
|
-
|
77
|
-
channel_to_server.write([:result, success])
|
76
|
+
client.result(success)
|
78
77
|
end
|
79
78
|
server.success?
|
80
79
|
end
|
@@ -1,34 +1,48 @@
|
|
1
1
|
module ParallelRSpec
|
2
2
|
class Server
|
3
|
-
attr_reader :reporter
|
3
|
+
attr_reader :remaining_example_group_indexes, :reporter
|
4
4
|
|
5
5
|
def initialize(reporter)
|
6
|
+
@remaining_example_group_indexes = RSpec.world.filtered_examples.each_with_object({}) do |(example_group, examples), results|
|
7
|
+
results[example_group] = examples.size unless example_group.any_context_hooks? || examples.size.zero?
|
8
|
+
end
|
6
9
|
@reporter = reporter
|
7
10
|
@success = true
|
8
11
|
end
|
9
12
|
|
10
|
-
def example_started(example)
|
13
|
+
def example_started(example, channel_to_client)
|
11
14
|
reporter.example_started(example)
|
12
15
|
end
|
13
16
|
|
14
|
-
def example_passed(example)
|
17
|
+
def example_passed(example, channel_to_client)
|
15
18
|
reporter.example_passed(example)
|
16
19
|
end
|
17
20
|
|
18
|
-
def example_failed(example)
|
21
|
+
def example_failed(example, channel_to_client)
|
19
22
|
reporter.example_failed(example)
|
20
23
|
end
|
21
24
|
|
22
|
-
def example_pending(example)
|
25
|
+
def example_pending(example, channel_to_client)
|
23
26
|
reporter.example_pending(example)
|
24
27
|
end
|
25
28
|
|
26
|
-
def deprecation(hash)
|
29
|
+
def deprecation(hash, channel_to_client)
|
27
30
|
reporter.deprecation(hash)
|
28
31
|
end
|
29
32
|
|
30
|
-
def
|
31
|
-
|
33
|
+
def next_example_to_run(channel_to_client)
|
34
|
+
if remaining_example_group_indexes.empty?
|
35
|
+
channel_to_client.write(nil)
|
36
|
+
else
|
37
|
+
klass = remaining_example_group_indexes.keys.first
|
38
|
+
remaining_example_group_indexes[klass] -= 1
|
39
|
+
channel_to_client.write([klass, remaining_example_group_indexes[klass]])
|
40
|
+
remaining_example_group_indexes.delete(klass) if remaining_example_group_indexes[klass].zero?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def result(success, channel_to_client)
|
45
|
+
@success &&= success
|
32
46
|
end
|
33
47
|
|
34
48
|
def success?
|
@@ -2,7 +2,7 @@ module ParallelRSpec
|
|
2
2
|
class Workers
|
3
3
|
def self.number_of_workers
|
4
4
|
workers = ENV['WORKERS'].to_i
|
5
|
-
workers =
|
5
|
+
workers = 2 if workers.zero?
|
6
6
|
workers
|
7
7
|
end
|
8
8
|
|
@@ -46,7 +46,7 @@ module ParallelRSpec
|
|
46
46
|
while !channels.empty?
|
47
47
|
Channel.read_select(channels).each do |channel|
|
48
48
|
if command = channel.read
|
49
|
-
server.send(*command)
|
49
|
+
server.send(*(command + [channel]))
|
50
50
|
else
|
51
51
|
channels.delete(channel)
|
52
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel_rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant, Powershop New Zealand Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|