flatware-rspec 2.0.0.rc1 → 2.0.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: e6a0aaa1271e9e220195b1198be4374e2a3e0a40fbe0dbdb61fad0c4735ab4e0
4
- data.tar.gz: 2e16cb3d10ac6a990a393b84e0a3ae04ea4ccccfdbb9de3d1b264d4729a2d32f
3
+ metadata.gz: 436149ce293c8e877b3c81d196dc5af1f74f697b8d10e12d0f29952f615c55ac
4
+ data.tar.gz: 0e888d9cf1b1a6a267a57670769c42dcd5af22982fa788524999a24f83914169
5
5
  SHA512:
6
- metadata.gz: 2b133ea289d7abe6828bf0c7188bb389c113126ea8e79866aed5b973d4213b473f79e219c4f3d151f6c1bbf175fd48790140c531c6ce4eeb488837c4bd1ed618
7
- data.tar.gz: 26d0a1a2a322ee2ad2cb4ac9b5d33c42aefdbe15a80d1c108d8e7d8b11a4f50e8bfb36e8003496c3215c939c74c3797f1eca7dad0c11843d96d1e9e1f3f85c3c
6
+ metadata.gz: af1b7330e2622dc1a43980870672fa020d4c1e49f36fa628a2ca28adac65cf0f5c4bbc86e5fe7fa0bb896b9c7c54215f0d6562c15fe428d0ee0b9a88330b2e9c
7
+ data.tar.gz: 21462ec96b948ec20853db6f34512e48fb8e757de345be832391114a45d70c63f01fba02ba9e0141d559407fae9c9d738c687a13a9d22925bef56e495eeddebf
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
- # Flatware [![Build Status][travis-badge]][travis] [![Code Climate][code-climate-badge]][code-climate]
1
+ # Flatware [![Code Climate][code-climate-badge]][code-climate]
2
2
 
3
- [travis-badge]: https://travis-ci.org/briandunn/flatware.svg?branch=master
4
- [travis]: http://travis-ci.org/briandunn/flatware
5
3
  [code-climate-badge]: https://codeclimate.com/github/briandunn/flatware.png
6
4
  [code-climate]: https://codeclimate.com/github/briandunn/flatware
7
5
 
@@ -116,7 +114,7 @@ Flatware.configure do |conf|
116
114
  end
117
115
 
118
116
  conf.after_fork do |test_env_number|
119
- config = ActiveRecord::Base.connection_config
117
+ config = ActiveRecord::Base.connection_db_config.configuration_hash
120
118
 
121
119
  ActiveRecord::Base.establish_connection(
122
120
  config.merge(
@@ -15,34 +15,48 @@ module Flatware
15
15
  def_delegators :failures_notification, :fully_formatted_failed_examples, :failure_notifications
16
16
  def_delegators :pending_notification, :fully_formatted_pending_examples, :pending_examples
17
17
 
18
- EVENTS = %i[dump_profile dump_summary dump_pending dump_failures].freeze
18
+ EVENTS = %i[
19
+ deprecation
20
+ dump_failures
21
+ dump_pending
22
+ dump_profile
23
+ dump_summary
24
+ ].freeze
19
25
 
20
26
  attr_reader :events
21
27
 
22
28
  def initialize(events = {})
23
- @events = events
29
+ @events = { deprecation: [] }.merge(events)
24
30
  end
25
31
 
26
- EVENTS.each do |event|
32
+ def self.listen_for(event, &block)
27
33
  define_method(event) do |notification|
28
- events[event] = Marshalable.for_event(event).from_notification(notification)
34
+ instance_exec(Marshalable.for_event(event).from_rspec(notification), &block)
29
35
  end
30
36
  end
31
37
 
32
- def +(other)
33
- self.class.new(
34
- events.merge(other.events) { |_, event, other_event| event + other_event }
35
- )
38
+ (EVENTS - %i[deprecation]).each do |event|
39
+ listen_for(event) do |notification|
40
+ events[event] = notification
41
+ end
36
42
  end
37
43
 
38
- def failures?
39
- summary.failures?
44
+ listen_for(:deprecation) do |deprecation|
45
+ events[:deprecation] << deprecation
46
+ end
47
+
48
+ def +(other)
49
+ self.class.new(events.merge(other.events) { |_, event, other_event| event + other_event })
40
50
  end
41
51
 
42
52
  def summary
43
53
  events.fetch(:dump_summary)
44
54
  end
45
55
 
56
+ def deprecations
57
+ events.fetch(:deprecation)
58
+ end
59
+
46
60
  def profile
47
61
  events[:dump_profile]
48
62
  end
@@ -11,17 +11,20 @@ module Flatware
11
11
  method_option(
12
12
  'sink-endpoint',
13
13
  type: :string,
14
- default: 'drbunix:sink'
14
+ default: 'drbunix:flatware-sink'
15
15
  )
16
16
  desc 'rspec [FLATWARE_OPTS]', 'parallelizes rspec'
17
17
  def rspec(*rspec_args)
18
18
  jobs = RSpec.extract_jobs_from_args rspec_args, workers: workers
19
- formatter = Flatware::RSpec::Formatters::Console.new($stdout, $stderr)
19
+
20
+ formatter = Flatware::RSpec::Formatters::Console.new(
21
+ ::RSpec.configuration.output_stream,
22
+ deprecation_stream: ::RSpec.configuration.deprecation_stream
23
+ )
24
+
20
25
  Flatware.verbose = options[:log]
21
26
  Worker.spawn count: workers, runner: RSpec, sink: options['sink-endpoint']
22
- start_sink(jobs: jobs,
23
- workers: workers,
24
- formatter: formatter)
27
+ start_sink(jobs: jobs, workers: workers, formatter: formatter)
25
28
  end
26
29
  end
27
30
  end
@@ -9,7 +9,7 @@ module Flatware
9
9
  class Formatter
10
10
  extend Forwardable
11
11
 
12
- def_delegators :@checkpoint, *Checkpoint::EVENTS
12
+ def_delegators :checkpoint, *Checkpoint::EVENTS
13
13
 
14
14
  attr_reader :output
15
15
 
@@ -29,12 +29,12 @@ module Flatware
29
29
  send_progress :pending
30
30
  end
31
31
 
32
- def start_dump(*)
33
- @checkpoint = Checkpoint.new
32
+ def message(message)
33
+ Sink.client.message message
34
34
  end
35
35
 
36
36
  def close(*)
37
- Sink.client.checkpoint @checkpoint
37
+ Sink.client.checkpoint checkpoint
38
38
  @checkpoint = nil
39
39
  end
40
40
 
@@ -43,16 +43,20 @@ module Flatware
43
43
  def send_progress(status)
44
44
  Sink.client.progress ProgressMessage.new status
45
45
  end
46
- end
47
46
 
48
- ::RSpec::Core::Formatters.register(
49
- Formatter,
50
- *Checkpoint::EVENTS,
51
- :example_passed,
52
- :example_failed,
53
- :example_pending,
54
- :start_dump,
55
- :close
56
- )
47
+ def checkpoint
48
+ @checkpoint ||= Checkpoint.new
49
+ end
50
+
51
+ ::RSpec::Core::Formatters.register(
52
+ self,
53
+ *Checkpoint::EVENTS,
54
+ :example_passed,
55
+ :example_failed,
56
+ :example_pending,
57
+ :message,
58
+ :close
59
+ )
60
+ end
57
61
  end
58
62
  end
@@ -4,28 +4,33 @@ module Flatware
4
4
  module RSpec
5
5
  module Formatters
6
6
  class Console
7
- attr_reader :progress_formatter, :profile_formatter
7
+ attr_reader :progress_formatter, :out, :deprecation_stream
8
8
 
9
- def initialize(out, _err)
10
- ::RSpec.configuration.tty = true
11
- ::RSpec.configuration.color = true
9
+ def initialize(out, deprecation_stream: StringIO.new)
10
+ @out = out
11
+ @deprecation_stream = deprecation_stream
12
+ ::RSpec.configuration.backtrace_exclusion_patterns += [%r{/lib/flatware/worker}, %r{/lib/flatware/rspec}]
12
13
  @progress_formatter = ::RSpec::Core::Formatters::ProgressFormatter.new(out)
13
- @profile_formatter = ::RSpec::Core::Formatters::ProfileFormatter.new(out)
14
14
  end
15
15
 
16
16
  def progress(result)
17
17
  progress_formatter.public_send(message_for(result), nil)
18
18
  end
19
19
 
20
+ def message(message)
21
+ out.puts(message.message)
22
+ end
23
+
20
24
  def summarize(checkpoints)
21
25
  return if checkpoints.empty?
22
26
 
23
27
  result = checkpoints.reduce :+
24
28
 
29
+ progress_formatter.dump_pending(result) if result.pending_examples.any?
25
30
  progress_formatter.dump_failures(result)
31
+ dump_deprecations(result.deprecations)
32
+ dump_profile(result.profile) if result.profile
26
33
  progress_formatter.dump_summary(result.summary)
27
- profile_formatter.dump_profile(result.profile) if result.profile
28
- progress_formatter.dump_pending(result) if result.pending_examples.any?
29
34
  end
30
35
 
31
36
  def summarize_remaining(remaining)
@@ -40,6 +45,20 @@ module Flatware
40
45
 
41
46
  private
42
47
 
48
+ def dump_deprecations(deprecations)
49
+ formatter = ::RSpec::Core::Formatters::DeprecationFormatter.new(
50
+ deprecation_stream,
51
+ out
52
+ )
53
+
54
+ deprecations.each(&formatter.method(:deprecation))
55
+ formatter.deprecation_summary(nil)
56
+ end
57
+
58
+ def dump_profile(profile)
59
+ ::RSpec::Core::Formatters::ProfileFormatter.new(out).dump_profile(profile)
60
+ end
61
+
43
62
  def spec_list(remaining)
44
63
  remaining
45
64
  .flat_map(&:id).sort.each_with_index
@@ -0,0 +1,11 @@
1
+ module Flatware
2
+ module RSpec
3
+ module Marshalable
4
+ class DeprecationNotification < ::RSpec::Core::Notifications::SeedNotification
5
+ def self.from_rspec(notification)
6
+ notification
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,9 @@
1
1
  module Flatware
2
2
  module RSpec
3
3
  module Marshalable
4
+ require 'flatware/rspec/marshalable/execution_result'
5
+ require 'flatware/rspec/marshalable/shared_group_inclusion_backtrace'
6
+
4
7
  ##
5
8
  # a subset of the rspec example interface that can traverse drb
6
9
  Example = Struct.new(
@@ -12,14 +15,29 @@ module Flatware
12
15
  ]
13
16
  ) do
14
17
  def initialize(rspec_example)
15
- super(*members.map do |attribute|
18
+ super(marshalable_execution_result(rspec_example.execution_result), *members[1..].map do |attribute|
16
19
  rspec_example.public_send(attribute)
17
20
  end)
18
21
 
19
- @metadata = rspec_example.metadata.slice(:extra_failure_lines, :shared_group_inclusion_backtrace)
22
+ @metadata = marshalable_metadata(rspec_example.metadata)
20
23
  end
21
24
 
22
25
  attr_reader :metadata
26
+
27
+ private
28
+
29
+ def marshalable_execution_result(execution_result)
30
+ ExecutionResult.from_rspec(execution_result)
31
+ end
32
+
33
+ def marshalable_metadata(rspec_metadata)
34
+ rspec_metadata.slice(:extra_failure_lines).tap do |metadata|
35
+ if (backtraces = rspec_metadata[:shared_group_inclusion_backtrace])
36
+ metadata[:shared_group_inclusion_backtrace] =
37
+ backtraces.map(&SharedGroupInclusionBacktrace.method(:from_rspec))
38
+ end
39
+ end
40
+ end
23
41
  end
24
42
  end
25
43
  end
@@ -17,7 +17,7 @@ module Flatware
17
17
 
18
18
  attr_reader :reporter
19
19
 
20
- def self.from_notification(rspec_notification)
20
+ def self.from_rspec(rspec_notification)
21
21
  new Reporter.from_rspec(rspec_notification.instance_variable_get(:@reporter))
22
22
  end
23
23
 
@@ -0,0 +1,18 @@
1
+ module Flatware
2
+ module RSpec
3
+ module Marshalable
4
+ require 'flatware/serialized_exception'
5
+ class ExecutionResult < ::RSpec::Core::Example::ExecutionResult
6
+ def self.from_rspec(result)
7
+ new.tap do |marshalable|
8
+ marshalable.exception = result.exception && SerializedException.from(result.exception)
9
+
10
+ %i[finished_at run_time started_at status].each do |member|
11
+ marshalable.public_send(:"#{member}=", result.public_send(member))
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -16,7 +16,7 @@ module Flatware
16
16
  )
17
17
  end
18
18
 
19
- def self.from_notification(rspec_notification)
19
+ def self.from_rspec(rspec_notification)
20
20
  new(
21
21
  rspec_notification.duration,
22
22
  rspec_notification.examples.map(&Example.method(:new)),
@@ -0,0 +1,11 @@
1
+ module Flatware
2
+ module RSpec
3
+ module Marshalable
4
+ class SharedGroupInclusionBacktrace < ::RSpec::Core::SharedExampleGroupInclusionStackFrame
5
+ def self.from_rspec(backtrace)
6
+ new(backtrace.shared_group_name.to_s, backtrace.inclusion_location)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -13,7 +13,7 @@ module Flatware
13
13
  [failure_count, errors_outside_of_examples_count].any?(&:positive?)
14
14
  end
15
15
 
16
- def self.from_notification(summary)
16
+ def self.from_rspec(summary)
17
17
  serialized_examples = [
18
18
  summary.examples,
19
19
  summary.failed_examples,
@@ -1,6 +1,7 @@
1
1
  module Flatware
2
2
  module RSpec
3
3
  module Marshalable
4
+ require 'flatware/rspec/marshalable/deprecation_notification'
4
5
  require 'flatware/rspec/marshalable/examples_notification'
5
6
  require 'flatware/rspec/marshalable/profile_notification'
6
7
  require 'flatware/rspec/marshalable/summary_notification'
@@ -12,7 +13,8 @@ module Flatware
12
13
  dump_pending: ExamplesNotification,
13
14
  dump_failures: ExamplesNotification,
14
15
  dump_profile: ProfileNotification,
15
- dump_summary: SummaryNotification
16
+ dump_summary: SummaryNotification,
17
+ deprecation: DeprecationNotification
16
18
  }.fetch(event)
17
19
  end
18
20
  end
@@ -15,15 +15,27 @@ module Flatware
15
15
  JobBuilder.new(args, workers: workers).jobs
16
16
  end
17
17
 
18
- def run(job, _options = {})
19
- runner = ::RSpec::Core::Runner
20
- def runner.trap_interrupt() end
18
+ def runner
19
+ ::RSpec::Core::Runner.tap do |runner|
20
+ def runner.trap_interrupt() end
21
+ end
22
+ end
23
+
24
+ def output_stream
25
+ StringIO.new.tap do |output|
26
+ output.define_singleton_method(:tty?) do
27
+ $stdout.tty?
28
+ end
29
+ end
30
+ end
21
31
 
22
- args = %w[
23
- --format Flatware::RSpec::Formatter
24
- ] + Array(job)
32
+ def run(job, _options = [])
33
+ ::RSpec.configuration.deprecation_stream = StringIO.new
34
+ ::RSpec.configuration.output_stream = output_stream
35
+ ::RSpec.configuration.add_formatter(Flatware::RSpec::Formatter)
25
36
 
26
- runner.run(args, $stderr, $stdout)
37
+ runner.run(Array(job), $stderr, $stdout)
38
+ ::RSpec.reset # prevents duplicate runs
27
39
  end
28
40
  end
29
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flatware-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dunn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-02 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flatware
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.rc1
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0.rc1
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.4'
33
+ version: '3.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.4'
40
+ version: '3.6'
41
41
  description: A distributed rspec runner
42
42
  email: brian@hashrocket.com
43
43
  executables: []
@@ -56,10 +56,13 @@ files:
56
56
  - lib/flatware/rspec/formatters/console.rb
57
57
  - lib/flatware/rspec/job_builder.rb
58
58
  - lib/flatware/rspec/marshalable.rb
59
+ - lib/flatware/rspec/marshalable/deprecation_notification.rb
59
60
  - lib/flatware/rspec/marshalable/example.rb
60
61
  - lib/flatware/rspec/marshalable/example_group.rb
61
62
  - lib/flatware/rspec/marshalable/examples_notification.rb
63
+ - lib/flatware/rspec/marshalable/execution_result.rb
62
64
  - lib/flatware/rspec/marshalable/profile_notification.rb
65
+ - lib/flatware/rspec/marshalable/shared_group_inclusion_backtrace.rb
63
66
  - lib/flatware/rspec/marshalable/summary_notification.rb
64
67
  homepage: http://github.com/briandunn/flatware
65
68
  licenses:
@@ -76,14 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
79
  version: '2.6'
77
80
  - - "<"
78
81
  - !ruby/object:Gem::Version
79
- version: '3.1'
82
+ version: '3.2'
80
83
  required_rubygems_version: !ruby/object:Gem::Requirement
81
84
  requirements:
82
- - - ">"
85
+ - - ">="
83
86
  - !ruby/object:Gem::Version
84
- version: 1.3.1
87
+ version: '0'
85
88
  requirements: []
86
- rubygems_version: 3.2.3
89
+ rubygems_version: 3.3.7
87
90
  signing_key:
88
91
  specification_version: 4
89
92
  summary: A distributed rspec runner