rspec-multiprocess_runner 1.3.0 → 1.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f561425e9f9c62eba1610b84278f1f3d86a5448d0c671324125bb88c0150f81
4
- data.tar.gz: 3b79c2b0e07224cc2fe64204b0adf5e7ca90099846e84cc2078ad771c617c05d
3
+ metadata.gz: 2ee952287e85072086a4feab9909db4e61d6cafcc3bc6b574795f368e9b4010c
4
+ data.tar.gz: 65a2d11400a0604631eed4cb6dc7df62307b5bd9914a3d768a3bff3316960a11
5
5
  SHA512:
6
- metadata.gz: ea71c613e8309da1d384f2c04778dce6871131bfa623ab4edabd4df6226d3393b39b6a1d3f688146881827650c56490a5b688139ba5c8bbcb76a199bced318d5
7
- data.tar.gz: 0db27a58d409e7485c4c4ae934f59f53ea86d63fa2125194813fbbefdd28f39db90ea59355cf205e6b39610f344b99447d112d72adc293a12b303f29b2df1f1c
6
+ metadata.gz: 52295ede507181b2b4f6a738131b3f279845076010421364e22aec501660a7e9ad442fda17723ec9f39f6247ee6f6d371ba0a32cafd8589404d8ce074ec40b1a
7
+ data.tar.gz: 86e482ce416b01185b3e4eed3bd3edaac850155c9d3353d0108cf5a14429329847ff1d741a3319faebcfd9fca22830569bafb87de7031c59b58fd01e2d97bb40
@@ -1,9 +1,30 @@
1
+ # 1.4.2
2
+
3
+ * Add better logging for errors that occur outside of tests
4
+ * Add docker tests for all current ruby versions and more ruby versions to test in
5
+ * Fix some minor bugs that caused incorrect error codes (still failure codes)
6
+ * Fixed the error code spec file
7
+
8
+ # 1.4.1
9
+
10
+ * Fix file coordinator helpers failing due to unknown method on command line args
11
+
12
+ # 1.4.0
13
+
14
+ * Fix issue catching spec files failing outside of tests (it will now die loudly instead of passing silently).
15
+
16
+ # 1.3.3
17
+
18
+ * File output bug fix
19
+
20
+ # 1.3.1
21
+
22
+ * Or use an environment variable for summary file.
23
+
1
24
  # 1.3.0
2
25
 
3
26
  * Add file output option
4
27
 
5
- # 1.2.4
6
-
7
28
  # 1.2.3
8
29
 
9
30
  * Fix time library sporadic failure
@@ -1,36 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-multiprocess_runner (1.3.0)
4
+ rspec-multiprocess_runner (1.4.2)
5
5
  rspec (>= 3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- byebug (11.0.1)
10
+ byebug (11.1.3)
11
11
  coderay (1.1.2)
12
12
  diff-lcs (1.3)
13
- method_source (0.9.2)
14
- pry (0.12.2)
15
- coderay (~> 1.1.0)
16
- method_source (~> 0.9.0)
17
- pry-byebug (3.7.0)
13
+ method_source (1.0.0)
14
+ pry (0.13.1)
15
+ coderay (~> 1.1)
16
+ method_source (~> 1.0)
17
+ pry-byebug (3.9.0)
18
18
  byebug (~> 11.0)
19
- pry (~> 0.10)
20
- rake (10.5.0)
21
- rspec (3.8.0)
22
- rspec-core (~> 3.8.0)
23
- rspec-expectations (~> 3.8.0)
24
- rspec-mocks (~> 3.8.0)
25
- rspec-core (3.8.2)
26
- rspec-support (~> 3.8.0)
27
- rspec-expectations (3.8.5)
19
+ pry (~> 0.13.0)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.2)
26
+ rspec-support (~> 3.9.3)
27
+ rspec-expectations (3.9.2)
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.8.0)
30
- rspec-mocks (3.8.2)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
31
  diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.8.0)
33
- rspec-support (3.8.3)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.3)
34
34
  stub_env (1.0.4)
35
35
  rspec (>= 2.0, < 4.0)
36
36
 
@@ -40,9 +40,9 @@ PLATFORMS
40
40
  DEPENDENCIES
41
41
  bundler (>= 1.10)
42
42
  pry-byebug
43
- rake (~> 10.0)
43
+ rake (>= 12.3.3)
44
44
  rspec-multiprocess_runner!
45
45
  stub_env
46
46
 
47
47
  BUNDLED WITH
48
- 2.0.2
48
+ 2.1.4
@@ -24,7 +24,7 @@ module RSpec::MultiprocessRunner
24
24
  self.hostname = "localhost"
25
25
  self.head_node = true
26
26
  self.max_nodes = 5
27
- self.summary_filename = nil
27
+ self.summary_filename = ENV['SUMMARY_FILE']
28
28
  end
29
29
 
30
30
  def parse(command_line_args, error_stream=$stderr)
@@ -41,7 +41,7 @@ module RSpec::MultiprocessRunner
41
41
  def exit_code
42
42
  exit_code = 0
43
43
  exit_code |= 1 if any_example_failed?
44
- exit_code |= 2 if !failed_workers.empty?
44
+ exit_code |= 2 if failed_workers.any? || error_messages.any?
45
45
  exit_code |= 4 if work_left_to_do? || @file_coordinator.missing_files.any?
46
46
  exit_code
47
47
  end
@@ -52,10 +52,10 @@ module RSpec::MultiprocessRunner
52
52
  end_workers_in_parallel(@workers.dup, :kill_now)
53
53
  else
54
54
  @shutting_down = true
55
- print "Shutting down #{pluralize(@workers.size, "worker")} …" if options.print_summary
55
+ print "Shutting down #{pluralize(@workers.size, "worker")} …" if options[:print_summary]
56
56
  # end_workers_in_parallel modifies @workers, so dup before sending in
57
57
  end_workers_in_parallel(@workers.dup, :shutdown_now)
58
- if options.print_summary
58
+ if options[:print_summary]
59
59
  puts " done"
60
60
  print_summary
61
61
  end
@@ -203,25 +203,30 @@ module RSpec::MultiprocessRunner
203
203
  end
204
204
  end
205
205
 
206
+ def summary_file
207
+ File.new(options.summary_filename, 'w') if (options.summary_filename)
208
+ end
209
+
206
210
  def print_summary
207
211
  elapsed = Time.now - @start_time
208
212
  by_status_and_time = combine_example_results.each_with_object(Hash.new { |h, k| h[k] = [] }) do |result, idx|
209
213
  idx[result.status] << result
210
214
  end
211
215
 
212
- outputs = [STDOUT]
213
- outputs << File.new(options.summary_filename, 'w') if (options.summary_filename)
216
+ outputs = [$stdout, summary_file].compact
214
217
  outputs.each do |output|
215
218
  print_skipped_files_details(output)
216
219
  print_pending_example_details(output, by_status_and_time["pending"])
217
220
  print_failed_example_details(output, by_status_and_time["failed"])
218
221
  print_missing_files(output)
219
- log_failed_files(by_status_and_time["failed"].map(&:filename).uniq + @file_coordinator.missing_files.to_a) if options.log_failing_files
222
+ log_failed_files(output, by_status_and_time["failed"].map(&:filename).uniq + @file_coordinator.missing_files.to_a) if options.log_failing_files
220
223
  print_failed_process_details(output)
224
+ print_error_messages(output)
221
225
  output.puts
222
226
  print_elapsed_time(output, elapsed)
223
227
  output.puts failed? ? "FAILURE" : "SUCCESS"
224
228
  print_example_counts(output, by_status_and_time)
229
+ output.close unless output == $stdout
225
230
  end
226
231
  end
227
232
 
@@ -229,6 +234,10 @@ module RSpec::MultiprocessRunner
229
234
  @file_coordinator.results.select { |r| r.run_status == "example_complete" }.sort_by { |r| r.time_finished }
230
235
  end
231
236
 
237
+ def error_messages
238
+ @file_coordinator.results.select { |r| r.run_status == "error_running" }.sort_by { |r| r.time_finished }
239
+ end
240
+
232
241
  def any_example_failed?
233
242
  @file_coordinator.results.detect { |r| r.status == "failed" }
234
243
  end
@@ -263,7 +272,7 @@ module RSpec::MultiprocessRunner
263
272
  end
264
273
  end
265
274
 
266
- def log_failed_files(failed_files)
275
+ def log_failed_files(output, failed_files)
267
276
  return if failed_files.nil?
268
277
  output.puts
269
278
  output.puts "Writing failures to file: #{options.log_failing_files}"
@@ -286,6 +295,7 @@ module RSpec::MultiprocessRunner
286
295
  pending_count = by_status_and_time["pending"] ? by_status_and_time["pending"].size : 0
287
296
  missing_count = @file_coordinator.missing_files.size
288
297
  process_failure_count = failed_workers.size
298
+ error_count = error_messages.size
289
299
  skipped_count = @file_coordinator.remaining_files.size
290
300
 
291
301
  # Copied from RSpec
@@ -293,6 +303,7 @@ module RSpec::MultiprocessRunner
293
303
  summary << ", " << pluralize(failure_count, "failure")
294
304
  summary << ", #{pending_count} pending" if pending_count > 0
295
305
  summary << ", " << pluralize(process_failure_count, "failed proc") if process_failure_count > 0
306
+ summary << ", " << pluralize(error_count, "error") if error_count > 0
296
307
  summary << ", " << pluralize(skipped_count, "skipped file") if skipped_count > 0
297
308
  summary << ", " << pluralize(missing_count, "missing file") if missing_count > 0
298
309
  output.puts summary
@@ -307,6 +318,17 @@ module RSpec::MultiprocessRunner
307
318
  end
308
319
  end
309
320
 
321
+ def print_error_messages(output)
322
+ return if error_messages.nil?
323
+ output.puts
324
+ output.puts "Errors:"
325
+ error_messages.each_with_index do |error, i|
326
+ output.puts
327
+ output.puts " #{i.next}) #{error.filename}"
328
+ output.print error.message
329
+ end
330
+ end
331
+
310
332
  def print_missing_files(output)
311
333
  return if @file_coordinator.missing_files.empty?
312
334
  output.puts
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'rspec/multiprocess_runner'
3
3
  require 'socket'
4
+ require 'json'
4
5
  require 'set'
5
6
 
6
7
  module RSpec::MultiprocessRunner
@@ -14,7 +15,7 @@ module RSpec::MultiprocessRunner
14
15
  COMMAND_FINISHED = "finished"
15
16
  COMMAND_START = "start"
16
17
 
17
- def initialize(files, options={})
18
+ def initialize(files, options=RSpec::MultiprocessRunner::CommandLineOptions.new)
18
19
  @spec_files = []
19
20
  @results = Set.new
20
21
  @threads = []
@@ -69,7 +70,8 @@ module RSpec::MultiprocessRunner
69
70
  else
70
71
  return nil # Malformed response, assume done, cease function
71
72
  end
72
- rescue
73
+ rescue StandardError => e
74
+ puts("Got exception #{e} in get_file")
73
75
  return nil # If Error, assume done, cease function
74
76
  end
75
77
  end
@@ -122,7 +124,7 @@ module RSpec::MultiprocessRunner
122
124
  break unless raw_response
123
125
  command, results, node = JSON.parse(raw_response)
124
126
  if command == COMMAND_START
125
- if results == options.start_string
127
+ if results == options.run_identifier
126
128
  socket.puts COMMAND_START
127
129
  else
128
130
  socket.puts COMMAND_FINISHED
@@ -143,7 +145,7 @@ module RSpec::MultiprocessRunner
143
145
 
144
146
  def start?
145
147
  begin
146
- @node_socket.puts [COMMAND_START, options.start_string].to_json
148
+ @node_socket.puts [COMMAND_START, options.run_identifier].to_json
147
149
  response = @node_socket.gets
148
150
  response = response.chomp if response
149
151
  raise BadStartStringError if response == COMMAND_FINISHED
@@ -59,6 +59,13 @@ module RSpec::MultiprocessRunner
59
59
  )
60
60
  end
61
61
 
62
+ def message(struct)
63
+ message = struct.message
64
+ return if message =~ /^No examples found./
65
+
66
+ worker.report_error(message)
67
+ end
68
+
62
69
  private
63
70
 
64
71
  def capture_output
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module MultiprocessRunner
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.2"
4
4
  end
5
5
  end
@@ -29,6 +29,7 @@ module RSpec::MultiprocessRunner
29
29
 
30
30
  STATUS_EXAMPLE_COMPLETE = "example_complete"
31
31
  STATUS_RUN_COMPLETE = "run_complete"
32
+ ERROR_RUNNING = "error_running"
32
33
 
33
34
  def initialize(environment_number, options)
34
35
  @environment_number = environment_number
@@ -196,6 +197,10 @@ module RSpec::MultiprocessRunner
196
197
  end
197
198
  $stdout.puts "#{environment_number} (#{pid}): #{message_hash["description"]} (#{location})#{suffix}"
198
199
  @current_example_started_at = Time.now
200
+ when ERROR_RUNNING
201
+ example_results << Result.new(message_hash)
202
+ $stdout.puts "Error in file: #{message_hash["filename"]}"
203
+ $stdout.print message_hash["message"]
199
204
  else
200
205
  $stderr.puts "Received unsupported status #{message_hash["status"].inspect} in worker #{pid}"
201
206
  end
@@ -219,7 +224,15 @@ module RSpec::MultiprocessRunner
219
224
  description: description,
220
225
  line_number: line_number,
221
226
  details: details,
222
- filename: @current_file
227
+ filename: @current_file,
228
+ )
229
+ end
230
+
231
+ def report_error(message)
232
+ send_message_to_coordinator(
233
+ status: ERROR_RUNNING,
234
+ message: message,
235
+ filename: @current_file,
223
236
  )
224
237
  end
225
238
 
@@ -263,9 +276,9 @@ module RSpec::MultiprocessRunner
263
276
  def act_on_message_from_coordinator(message_hash)
264
277
  return handle_closed_coordinator_socket unless message_hash # EOF
265
278
  case message_hash["command"]
266
- when "quit"
279
+ when COMMAND_QUIT
267
280
  exit
268
- when "run_file"
281
+ when COMMAND_RUN_FILE
269
282
  execute_spec(message_hash["filename"])
270
283
  else
271
284
  $stderr.puts "Received unsupported command #{message_hash["command"].inspect} in worker #{pid}"
@@ -281,7 +294,9 @@ module RSpec::MultiprocessRunner
281
294
  RSpec.world.example_groups.clear
282
295
 
283
296
  ReportingFormatter.worker = self
284
- RSpec::Core::Runner.run(@rspec_arguments + [spec_file])
297
+ error_stream = StringIO.new
298
+ output_stream = StringIO.new
299
+ RSpec::Core::Runner.run(@rspec_arguments + [spec_file], error_stream, output_stream)
285
300
  send_message_to_coordinator(status: STATUS_RUN_COMPLETE, filename: spec_file)
286
301
  ensure
287
302
  @current_file = nil
@@ -322,7 +337,7 @@ module RSpec::MultiprocessRunner
322
337
 
323
338
  # @private
324
339
  class Result
325
- attr_reader :run_status, :status, :description, :details, :filename, :time_finished
340
+ attr_reader :description, :details, :filename, :message, :run_status, :status, :time_finished
326
341
 
327
342
  def initialize(complete_message, time = Time.now)
328
343
  @hash = complete_message
@@ -331,6 +346,7 @@ module RSpec::MultiprocessRunner
331
346
  @description = complete_message["description"]
332
347
  @details = complete_message["details"]
333
348
  @filename = complete_message["filename"]
349
+ @message = complete_message["message"]
334
350
  @time_finished = time
335
351
  end
336
352
 
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", ">= 1.10"
24
24
  spec.add_development_dependency "pry-byebug"
25
- spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "byebug", "<11" if RUBY_VERSION.to_f < 2.4
26
+ spec.add_development_dependency "rake", ">= 12.3.3"
26
27
  spec.add_development_dependency "stub_env"
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-multiprocess_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rhett Sutphin
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2019-10-02 00:00:00.000000000 Z
14
+ date: 2020-05-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -59,16 +59,16 @@ dependencies:
59
59
  name: rake
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - "~>"
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '10.0'
64
+ version: 12.3.3
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "~>"
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '10.0'
71
+ version: 12.3.3
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: stub_env
74
74
  requirement: !ruby/object:Gem::Requirement
@@ -131,8 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.7.6.2
134
+ rubygems_version: 3.0.3
136
135
  signing_key:
137
136
  specification_version: 4
138
137
  summary: A runner for RSpec 3 that uses multiple processes to execute specs in parallel