flatware-rspec 2.0.0.rc2 → 2.0.0.rc3

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: b0c080b0bb6d068e3d65c19230aacd62d811e0e151358ffebec9f83b0e1ab0ba
4
- data.tar.gz: '079c5ecaea4b3aa461bd7ffa6c6ee7e6ed1e592d990e4d76af5f0dcf3fa4863f'
3
+ metadata.gz: 8c7ed50452251f91a122a1870cf0034e737bd9e245a2effca63876d352b6dfaa
4
+ data.tar.gz: 204dc1af97debe14947500af0bf54da88f5b5d6a8e95eda320b94ef81315be7f
5
5
  SHA512:
6
- metadata.gz: '0692ddafa90238adf85ffb8648b9b64d5971a0a4047e932063226e88391344953f847fc90093c65a37d8e233426f3f53e6f1f53fc0bb056dc2705de1704283bd'
7
- data.tar.gz: 4ccd74df9c6954319baa3c79da326d55dcb816ef0661439cf7be3a5c4bffa1fe29c9c51c3ffbe613aabd336e0c1a22fe4bcc1ca3463f8c8111c7a4d74e4eabaf
6
+ metadata.gz: 19970bba746199d0514531e83ceacdfd48a89ef3f0531ff6a9d42c5b89927e107fd429c11594f9a3e784c03014ee12911be9217188150609582e78091c4e578d
7
+ data.tar.gz: 8b1284ae49367edfa7ba0e5e06f95fe7df5523f9091340f0f5e08fba3e9a6332dcb6a342d075990ed78ed5fe723ae25b4604336a5cb60e16fc95918d8807cd45
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
 
@@ -15,15 +15,19 @@ 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
21
23
 
22
- args = %w[
23
- --format Flatware::RSpec::Formatter
24
- ] + Array(job)
24
+ def run(job, _options = [])
25
+ ::RSpec.configuration.deprecation_stream = StringIO.new
26
+ ::RSpec.configuration.output_stream = StringIO.new
27
+ ::RSpec.configuration.add_formatter(Flatware::RSpec::Formatter)
25
28
 
26
- runner.run(args, $stderr, $stdout)
29
+ runner.run(Array(job), $stderr, $stdout)
30
+ ::RSpec.reset # prevents duplicate runs
27
31
  end
28
32
  end
29
33
  end
@@ -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_rspec(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,8 @@ module Flatware
29
29
  send_progress :pending
30
30
  end
31
31
 
32
- def start_dump(*)
33
- @checkpoint = Checkpoint.new
34
- end
35
-
36
32
  def close(*)
37
- Sink.client.checkpoint @checkpoint
33
+ Sink.client.checkpoint checkpoint
38
34
  @checkpoint = nil
39
35
  end
40
36
 
@@ -43,16 +39,19 @@ module Flatware
43
39
  def send_progress(status)
44
40
  Sink.client.progress ProgressMessage.new status
45
41
  end
46
- end
47
42
 
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
- )
43
+ def checkpoint
44
+ @checkpoint ||= Checkpoint.new
45
+ end
46
+
47
+ ::RSpec::Core::Formatters.register(
48
+ self,
49
+ *Checkpoint::EVENTS,
50
+ :example_passed,
51
+ :example_failed,
52
+ :example_pending,
53
+ :close
54
+ )
55
+ end
57
56
  end
58
57
  end
@@ -4,13 +4,13 @@ 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)
@@ -22,10 +22,11 @@ module Flatware
22
22
 
23
23
  result = checkpoints.reduce :+
24
24
 
25
+ progress_formatter.dump_pending(result) if result.pending_examples.any?
25
26
  progress_formatter.dump_failures(result)
27
+ dump_deprecations(result.deprecations)
28
+ dump_profile(result.profile) if result.profile
26
29
  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
30
  end
30
31
 
31
32
  def summarize_remaining(remaining)
@@ -40,6 +41,20 @@ module Flatware
40
41
 
41
42
  private
42
43
 
44
+ def dump_deprecations(deprecations)
45
+ formatter = ::RSpec::Core::Formatters::DeprecationFormatter.new(
46
+ deprecation_stream,
47
+ out
48
+ )
49
+
50
+ deprecations.each(&formatter.method(:deprecation))
51
+ formatter.deprecation_summary(nil)
52
+ end
53
+
54
+ def dump_profile(profile)
55
+ ::RSpec::Core::Formatters::ProfileFormatter.new(out).dump_profile(profile)
56
+ end
57
+
43
58
  def spec_list(remaining)
44
59
  remaining
45
60
  .flat_map(&:id).sort.each_with_index
@@ -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
@@ -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,7 @@
1
1
  module Flatware
2
2
  module RSpec
3
3
  module Marshalable
4
+ require 'flatware/rspec/marshalable/execution_result'
4
5
  require 'flatware/rspec/marshalable/shared_group_inclusion_backtrace'
5
6
 
6
7
  ##
@@ -14,7 +15,7 @@ module Flatware
14
15
  ]
15
16
  ) do
16
17
  def initialize(rspec_example)
17
- super(*members.map do |attribute|
18
+ super(marshalable_execution_result(rspec_example.execution_result), *members[1..].map do |attribute|
18
19
  rspec_example.public_send(attribute)
19
20
  end)
20
21
 
@@ -25,6 +26,10 @@ module Flatware
25
26
 
26
27
  private
27
28
 
29
+ def marshalable_execution_result(execution_result)
30
+ ExecutionResult.from_rspec(execution_result)
31
+ end
32
+
28
33
  def marshalable_metadata(rspec_metadata)
29
34
  rspec_metadata.slice(:extra_failure_lines).tap do |metadata|
30
35
  if (backtraces = rspec_metadata[:shared_group_inclusion_backtrace])
@@ -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
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.rc2
4
+ version: 2.0.0.rc3
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: 2021-03-15 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.rc2
19
+ version: 2.0.0.rc3
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.rc2
26
+ version: 2.0.0.rc3
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,9 +56,11 @@ 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
63
65
  - lib/flatware/rspec/marshalable/shared_group_inclusion_backtrace.rb
64
66
  - lib/flatware/rspec/marshalable/summary_notification.rb