flatware 2.3.1 → 2.3.3

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: f3dfa03a78403cf9d0b10b97ac354baba9353a6847bcbbc9b150b7deaa8a4f68
4
- data.tar.gz: e2181f1f91b2b313ab42d39c93ce209efc432b29192737f7b9d5e06d13f637ce
3
+ metadata.gz: 26a331171fb4022830f008910834d7d0e2b7e7d7d6c449454c30dad6cff41900
4
+ data.tar.gz: 1652107a2aac23b8113d564629b064fb57ec58a3c7810151e7863794d8904cfc
5
5
  SHA512:
6
- metadata.gz: 63b9c6f997e89382276b56797cf0e0b53155c30e11a5e22157c03a93da7cd616bffde249283a6ed7a29affc1b9da5baa211c2963e98402998068c7a9f856ed33
7
- data.tar.gz: dba4525f41243955e2f0f3db5a8685031a38eb66192de319c110eae41450fcd55ad995d56c3025e01cb8ad61a50dce04dec4dcc1e45ed54f36dfe011554f5339
6
+ metadata.gz: 6bc54319c7c78a32dc5dd2f4ce05c4f41af153dcbbc49c795420deb4f156859602caf153028d1bd432bedfda2888207264c9501c370830058ec57790cfd3bede
7
+ data.tar.gz: 658c8ea788aea4756573727fff5dde2513c9cdde8bd60e960b31bd4e70b3f49e718d177ed7120fb25a17af2fa15660723f2b523c04761b20a7328e61caa10ac7
data/README.md CHANGED
@@ -40,13 +40,16 @@ $ flatware rspec
40
40
 
41
41
  The rspec runner can balance worker loads, making your suite even faster.
42
42
 
43
- It forms balaced groups of spec files according to their last run times, if you've set `example_status_persistence_file_path` [in your RSpec config](https://relishapp.com/rspec/rspec-core/v/3-8/docs/command-line/only-failures).
43
+ It forms balanced groups of spec files according to their last run times, if
44
+ you've set `example_status_persistence_file_path` in your [RSpec config].
44
45
 
45
- For this to work the configuration option must be loaded before any specs are run. The `.rspec` file is one way to achive this:
46
+ [RSpec config]: https://rspec.info/features/3-13/rspec-core/command-line/only-failures/
47
+
48
+ For this to work the configuration option must be loaded before any specs are run. The `.rspec` file is one way to achieve this:
46
49
 
47
50
  --require spec_helper
48
51
 
49
- But beware, if you're using ActiveRecord in your suite you'll need to avoid doing things that cause it to establish a database connection in `spec_helper.rb`. If ActiveRecord connects before flatware forks off workers, each will die messily. All of this will just work if you're following [the recomended pattern of splitting your helpers into `spec_helper` and `rails_helper`](https://github.com/rspec/rspec-rails/blob/v3.8.2/lib/generators/rspec/install/templates/spec/rails_helper.rb). Another option is to use [the configurable hooks](
52
+ But beware, if you're using ActiveRecord in your suite you'll need to avoid doing things that cause it to establish a database connection in `spec_helper.rb`. If ActiveRecord connects before flatware forks off workers, each will die messily. All of this will just work if you're following [the recommended pattern of splitting your helpers into `spec_helper` and `rails_helper`](https://github.com/rspec/rspec-rails/blob/v3.8.2/lib/generators/rspec/install/templates/spec/rails_helper.rb). Another option is to use [the configurable hooks](
50
53
  #faster-startup-with-activerecord
51
54
  ).
52
55
 
data/lib/flatware/cli.rb CHANGED
@@ -17,7 +17,7 @@ module Flatware
17
17
  aliases: '-w',
18
18
  type: :numeric,
19
19
  default: processors,
20
- desc: 'Number of concurent processes to run'
20
+ desc: 'Number of concurrent processes to run'
21
21
  )
22
22
  end
23
23
 
@@ -41,7 +41,8 @@ module Flatware
41
41
  exec({ 'TEST_ENV_NUMBER' => i.to_s }, command)
42
42
  end
43
43
  end
44
- Process.waitall
44
+ success = Process.waitall.all? { |_pid, status| status.success? }
45
+ exit success ? 0 : 1
45
46
  end
46
47
 
47
48
  desc 'clear', 'kills all flatware processes'
@@ -90,6 +91,6 @@ if loaded_flatware_gem_count.zero?
90
91
  warn(
91
92
  format(<<~MESSAGE, gem_list: flatware_gems.join(' or ')))
92
93
  The flatware gem is a dependency of flatware runners for rspec and cucumber.
93
- Install %<gem_list>s for more usefull commands.
94
+ Install %<gem_list>s for more useful commands.
94
95
  MESSAGE
95
96
  end
@@ -1,46 +1,77 @@
1
1
  module Flatware
2
2
  module Sink
3
3
  class Signal
4
- def initialize(&on_interrupt)
4
+ Message = Struct.new(:message)
5
+
6
+ attr_reader :formatter
7
+
8
+ def initialize(formatter, &on_interrupt)
9
+ @formatter = formatter
5
10
  Thread.main[:signals] = Queue.new
6
11
 
7
12
  @on_interrupt = on_interrupt
8
13
  end
9
14
 
10
- def interruped?
11
- !signals.empty?
12
- end
13
-
14
15
  def listen
15
16
  Thread.new(&method(:handle_signals))
16
17
 
17
18
  ::Signal.trap('INT') { signals << :int }
18
- ::Signal.trap('CLD') { signals << :cld }
19
+ ::Signal.trap('CLD') do
20
+ signals << :cld if child_failed?
21
+ end
19
22
 
20
23
  self
21
24
  end
22
25
 
23
- def self.listen(&block)
24
- new(&block).listen
26
+ def self.listen(formatter, &block)
27
+ new(formatter, &block).listen
25
28
  end
26
29
 
27
30
  private
28
31
 
32
+ def child_status
33
+ _worker_pid, status = begin
34
+ Process.wait2(-1, Process::WNOHANG)
35
+ rescue Errno::ECHILD
36
+ []
37
+ end
38
+ status
39
+ end
40
+
41
+ def child_statuses
42
+ statuses = []
43
+ loop do
44
+ status = child_status
45
+ return statuses unless status
46
+
47
+ statuses << status
48
+ end
49
+ end
50
+
51
+ def child_failed?
52
+ child_statuses.any? { |status| !status.success? }
53
+ end
54
+
29
55
  def handle_signals
30
- puts signal_message(signals.pop)
31
- Process.waitall
32
- @on_interrupt.call
33
- puts 'done.'
56
+ signal_message(signals.pop) do
57
+ Process.waitall
58
+ @on_interrupt.call
59
+ end
60
+
34
61
  abort
35
62
  end
36
63
 
37
64
  def signal_message(signal)
38
- format(<<~MESSAGE, { cld: 'A worker died', int: 'Interrupted' }.fetch(signal))
65
+ formatter.message(Message.new(format(<<~MESSAGE, { cld: 'A worker died', int: 'Interrupted' }.fetch(signal))))
39
66
 
40
67
  %s!
41
68
 
42
- Cleaning up. Please wait...
69
+ Waiting for workers to finish their current jobs...
43
70
  MESSAGE
71
+
72
+ yield
73
+
74
+ formatter.message(Message.new('done.'))
44
75
  end
45
76
 
46
77
  def signals
data/lib/flatware/sink.rb CHANGED
@@ -25,6 +25,7 @@ module Flatware
25
25
  @checkpoints = []
26
26
  @completed_jobs = []
27
27
  @formatter = formatter
28
+ @interrupted = false
28
29
  @jobs = group_jobs(jobs, worker_count).freeze
29
30
  @queue = @jobs.dup
30
31
  @sink = sink
@@ -32,16 +33,16 @@ module Flatware
32
33
  end
33
34
 
34
35
  def start
35
- @signal = Signal.listen(&method(:summarize_remaining))
36
+ Signal.listen(formatter, &method(:on_interrupt))
36
37
  formatter.jobs jobs
37
38
  DRb.start_service(sink, self, verbose: Flatware.verbose?)
38
39
  DRb.thread.join
39
- !failures?
40
+ !(failures? || interrupted?)
40
41
  end
41
42
 
42
43
  def ready(worker)
43
44
  job = queue.shift
44
- if job && !(remaining_work.empty? || interruped?)
45
+ if job && !(remaining_work.empty? || interrupted?)
45
46
  workers << worker
46
47
  job
47
48
  else
@@ -73,8 +74,13 @@ module Flatware
73
74
 
74
75
  private
75
76
 
76
- def interruped?
77
- @signal&.interruped?
77
+ def on_interrupt
78
+ @interrupted = true
79
+ summarize_remaining
80
+ end
81
+
82
+ def interrupted?
83
+ @interrupted
78
84
  end
79
85
 
80
86
  def check_finished!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Flatware
4
- VERSION = '2.3.1'
4
+ VERSION = '2.3.3'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flatware
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-20 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: drb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: thor
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
84
  - !ruby/object:Gem::Version
71
85
  version: '0'
72
86
  requirements: []
73
- rubygems_version: 3.4.1
87
+ rubygems_version: 3.5.17
74
88
  signing_key:
75
89
  specification_version: 4
76
90
  summary: A distributed rspec and cucumber runner