parallel_rspec 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 789b0fec42e9fe3b485305a5da250915fab02f89678dba1171ec7fd2d7b0bcc5
4
- data.tar.gz: 259d48bbffa5177861d88cf92daa4a9b942e4d40d21dff4d04ee3eb190a49dde
3
+ metadata.gz: 6d2e2199456f48d4b9726672b0c5e223b536350826d46b1bc14ff28e5d83ef45
4
+ data.tar.gz: ae4b625e1041147f8e6c4087196fe34bb97977fb0034549e9436b4056363f184
5
5
  SHA512:
6
- metadata.gz: b5da7ba542f13faacb9d89906b23255c02262e228b3cfa4c72377f0f0a1addfabfcb1c6970e6c15316e4a569f4ed15b28592ce11b0cbad522b7342c67f97ed13
7
- data.tar.gz: 4a1eac0dfaa95d8ef167380ec9922072dee901e2e9087c0c9f00b121b34dde73cd148dada9c435bf51d98cb5f6547eaf31f5aa61e9b9effa8de148843f7ee122
6
+ metadata.gz: a27c85ac8cc1ef08b04ac61054848eeed0dfbe08465fd4814d0a6909dd18891df71d7bbe9011f2fe0281a028bdd62550988d2716f707d3ea1a11d12139d67772
7
+ data.tar.gz: 584531e1f3027132097cebb1a36e600ae7e470ce62b91bc23522352dc39f14a7c1c80b34b92a1c5298bbdb079fb51c1204962945577c6cdf549e14dd944f8a22
data/CHANGES.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 2.2.0
4
+
5
+ * Fix incompatibility with `rspec --profile`.
6
+
7
+ ## 2.1.2
8
+
9
+ * Fix error when used in projects without ActiveSupport. Thanks @erikpaasonen.
10
+
11
+ ## 2.1.1
12
+
13
+ * Fix deprecation warnings from ActiveRecord::Base.configurations[].
14
+
15
+ ## 2.1.0
16
+
17
+ * Add a default parallel_rspec rake task.
18
+ * Add task descriptions for rake --tasks.
19
+
20
+ ## 2.0.0
21
+
22
+ * Remove an unnecessary dev dependency to pacify dependabot.
23
+ * Add after_fork hook and running? method. Thanks @mogest.
24
+ * Upgrade for compatibility with Rails 6.1 and RSpec 3.10. Thanks @mogest.
25
+
26
+ ## 1.2.0
27
+
28
+ * 9924295 Make the Railtie load optional.
29
+ * 6366f07 Add require to the recommended Rakefile for people not using Rails.
30
+ * 1a5ec3d Fix rake and rspec dependencies.
data/README.md CHANGED
@@ -24,7 +24,7 @@ And then execute:
24
24
 
25
25
  $ bundle
26
26
 
27
- This version of ParallelRSpec has been tested with RSpec 3.10.
27
+ This version of ParallelRSpec has been tested with RSpec 3.12.
28
28
 
29
29
  ## Usage
30
30
 
@@ -82,6 +82,10 @@ You might also want to detect whether your spec suite is running under ParallelR
82
82
  do_something unless ParallelRSpec.running?
83
83
  ```
84
84
 
85
+ ## Limitations
86
+
87
+ ParallelRSpec can't parallelize the specs in groups that use `before(:context)` or `after(:context)` (AKA `before(:all)` or `after(:all)`) hooks, since these may mean that there is state shared between examples.
88
+
85
89
  ## Contributing
86
90
 
87
91
  Bug reports and pull requests are welcome on GitHub at https://github.com/willbryant/parallel_rspec.
@@ -91,6 +95,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/willbr
91
95
 
92
96
  * Charles Horn (@hornc)
93
97
  * Roger Nesbitt (@mogest)
98
+ * Erik Paasonen (@erikpaasonen)
94
99
 
95
100
 
96
101
  ## License
@@ -98,3 +103,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/willbr
98
103
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
99
104
 
100
105
  Copyright (c) Powershop New Zealand Ltd, 2015.
106
+ Copyright (c) Will Bryant, 2023.
@@ -15,52 +15,38 @@ module ParallelRSpec
15
15
  end
16
16
 
17
17
  def example_started(example)
18
- channel_to_server.write([:example_started, serialize_example(example)])
18
+ channel_to_server.write([:example_started, example.id, updates_from(example)])
19
19
  end
20
20
 
21
21
  def example_passed(example)
22
- channel_to_server.write([:example_passed, serialize_example(example)])
22
+ channel_to_server.write([:example_passed, example.id, updates_from(example)])
23
23
  end
24
24
 
25
25
  def example_failed(example)
26
- channel_to_server.write([:example_failed, serialize_example(example)])
26
+ channel_to_server.write([:example_failed, example.id, updates_from(example)])
27
27
  end
28
28
 
29
29
  def example_finished(example)
30
- channel_to_server.write([:example_finished, serialize_example(example)])
30
+ channel_to_server.write([:example_finished, example.id, updates_from(example)])
31
31
  end
32
32
 
33
33
  def example_pending(example)
34
- channel_to_server.write([:example_pending, serialize_example(example)])
34
+ channel_to_server.write([:example_pending, example.id, updates_from(example)])
35
35
  end
36
36
 
37
37
  def deprecation(hash)
38
38
  channel_to_server.write([:deprecation, hash])
39
39
  end
40
40
 
41
- def serialize_example(example)
42
- Example.new(
43
- example.id,
44
- example.description,
45
- example.exception,
46
- example.location_rerun_argument,
47
- ExampleGroup.new([]),
48
- example.metadata.slice(
49
- :absolute_file_path,
50
- :described_class,
51
- :description,
52
- :description_args,
41
+ def updates_from(example)
42
+ {
43
+ exception: example.exception,
44
+ metadata: example.metadata.slice(
53
45
  :execution_result,
54
- :full_description,
55
- :file_path,
56
- :last_run_status,
57
- :line_number,
58
- :location,
59
46
  :pending,
60
- :rerun_file_path,
61
- :scoped_id,
62
- :shared_group_inclusion_backtrace,
63
- :type))
47
+ :skip,
48
+ )
49
+ }
64
50
  end
65
51
 
66
52
  def next_example_to_run
@@ -6,8 +6,8 @@ module RSpec
6
6
  def self.any_context_hooks?
7
7
  # unfortunately the public HookCollection API doesn't make this information available, so we have to grab it from internals
8
8
  descendants.any? do |group| # despite the name, descendents includes self
9
- group.hooks.send(:matching_hooks_for, :before, :context, group).present? ||
10
- group.hooks.send(:matching_hooks_for, :after, :context, group).present?
9
+ group.hooks.send(:matching_hooks_for, :before, :context, group).any? ||
10
+ group.hooks.send(:matching_hooks_for, :after, :context, group).any?
11
11
  end
12
12
  end
13
13
  end
@@ -1,33 +1,34 @@
1
1
  module ParallelRSpec
2
2
  class Server
3
- attr_reader :remaining_example_group_indexes, :reporter
3
+ attr_reader :reporter, :remaining_examples_by_group, :running_examples
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?
6
+ @remaining_examples_by_group = RSpec.world.filtered_examples.each_with_object({}) do |(example_group, examples), results|
7
+ results[example_group] = examples unless example_group.any_context_hooks? || examples.size.zero?
8
8
  end
9
9
  @reporter = reporter
10
10
  @success = true
11
+ @running_examples = {}
11
12
  end
12
13
 
13
- def example_started(example, channel_to_client)
14
- reporter.example_started(example)
14
+ def example_started(example_id, example_updates, channel_to_client)
15
+ reporter.example_started(update_example(running_examples[example_id], example_updates))
15
16
  end
16
17
 
17
- def example_passed(example, channel_to_client)
18
- reporter.example_passed(example)
18
+ def example_finished(example_id, example_updates, channel_to_client)
19
+ reporter.example_finished(update_example(running_examples[example_id], example_updates))
19
20
  end
20
21
 
21
- def example_failed(example, channel_to_client)
22
- reporter.example_failed(example)
22
+ def example_passed(example_id, example_updates, channel_to_client)
23
+ reporter.example_passed(update_example(running_examples.delete(example_id), example_updates))
23
24
  end
24
25
 
25
- def example_finished(example, channel_to_client)
26
- reporter.example_finished(example)
26
+ def example_failed(example_id, example_updates, channel_to_client)
27
+ reporter.example_failed(update_example(running_examples.delete(example_id), example_updates))
27
28
  end
28
29
 
29
- def example_pending(example, channel_to_client)
30
- reporter.example_pending(example)
30
+ def example_pending(example_id, example_updates, channel_to_client)
31
+ reporter.example_pending(update_example(running_examples.delete(example_id), example_updates))
31
32
  end
32
33
 
33
34
  def deprecation(hash, channel_to_client)
@@ -35,13 +36,14 @@ module ParallelRSpec
35
36
  end
36
37
 
37
38
  def next_example_to_run(channel_to_client)
38
- if remaining_example_group_indexes.empty?
39
+ if remaining_examples_by_group.empty?
39
40
  channel_to_client.write(nil)
40
41
  else
41
- klass = remaining_example_group_indexes.keys.first
42
- remaining_example_group_indexes[klass] -= 1
43
- channel_to_client.write([klass, remaining_example_group_indexes[klass]])
44
- remaining_example_group_indexes.delete(klass) if remaining_example_group_indexes[klass].zero?
42
+ example_group = remaining_examples_by_group.keys.first
43
+ example = remaining_examples_by_group[example_group].pop
44
+ running_examples[example.id] = example # cache so we don't need to look through all the examples for each message
45
+ channel_to_client.write([example_group, remaining_examples_by_group[example_group].size])
46
+ remaining_examples_by_group.delete(example_group) if remaining_examples_by_group[example_group].empty?
45
47
  end
46
48
  end
47
49
 
@@ -52,5 +54,11 @@ module ParallelRSpec
52
54
  def success?
53
55
  @success
54
56
  end
57
+
58
+ def update_example(example, data)
59
+ example.set_exception(data[:exception])
60
+ example.metadata.merge!(data[:metadata])
61
+ example
62
+ end
55
63
  end
56
64
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelRSpec
2
- VERSION = "2.1.1"
2
+ VERSION = "2.2.0"
3
3
  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: 2.1.1
4
+ version: 2.2.0
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: 2022-02-04 00:00:00.000000000 Z
11
+ date: 2023-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -50,6 +50,7 @@ extra_rdoc_files: []
50
50
  files:
51
51
  - ".gitignore"
52
52
  - ".travis.yml"
53
+ - CHANGES.md
53
54
  - Gemfile
54
55
  - LICENSE.txt
55
56
  - README.md
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  - !ruby/object:Gem::Version
88
89
  version: '0'
89
90
  requirements: []
90
- rubygems_version: 3.0.3
91
+ rubygems_version: 3.3.26
91
92
  signing_key:
92
93
  specification_version: 4
93
94
  summary: This gem lets you run your RSpec examples in parallel across across your