Class: RSpec::Signal::Report
- Inherits:
-
Object
- Object
- RSpec::Signal::Report
- Defined in:
- lib/rspec/signal/report.rb
Overview
The complete, renderer-independent result of a run.
Instance Attribute Summary collapse
-
#clusters ⇒ Object
readonly
Returns the value of attribute clusters.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#errors_outside_examples ⇒ Object
readonly
Returns the value of attribute errors_outside_examples.
-
#example_count ⇒ Object
readonly
Returns the value of attribute example_count.
-
#failure_count ⇒ Object
readonly
Returns the value of attribute failure_count.
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#pending_count ⇒ Object
readonly
Returns the value of attribute pending_count.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
-
#seed_used ⇒ Object
readonly
Returns the value of attribute seed_used.
Instance Method Summary collapse
- #any_failures? ⇒ Boolean
- #cluster_count ⇒ Object
- #group_count ⇒ Object
-
#initialize(failures:, example_count: 0, failure_count: nil, pending_count: 0, duration: nil, seed: nil, seed_used: false, environment: {}, errors_outside_examples: 0, relate_failures: true) ⇒ Report
constructor
A new instance of Report.
- #kept_frames ⇒ Object
-
#omitted_frames ⇒ Object
Backtrace frames dropped across the whole run.
-
#safely ⇒ Object
Clustering is the newest and least essential stage; a report without it is still worth having, so it is never allowed to take the run down.
- #seed_used? ⇒ Boolean
- #to_h ⇒ Object
- #total_frames ⇒ Object
-
#worker_h(write_full: false) ⇒ Object
Worker interchange data.
Constructor Details
#initialize(failures:, example_count: 0, failure_count: nil, pending_count: 0, duration: nil, seed: nil, seed_used: false, environment: {}, errors_outside_examples: 0, relate_failures: true) ⇒ Report
Returns a new instance of Report.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rspec/signal/report.rb', line 10 def initialize(failures:, example_count: 0, failure_count: nil, pending_count: 0, duration: nil, seed: nil, seed_used: false, environment: {}, errors_outside_examples: 0, relate_failures: true) @failures = failures @groups = Grouper.call(failures) @clusters = relate_failures ? safely { Clusterer.call(failures) } : [] @example_count = example_count @failure_count = failure_count || failures.size @pending_count = pending_count @duration = duration @seed = seed @seed_used = seed_used @environment = environment @errors_outside_examples = errors_outside_examples end |
Instance Attribute Details
#clusters ⇒ Object (readonly)
Returns the value of attribute clusters.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def clusters @clusters end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def duration @duration end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def environment @environment end |
#errors_outside_examples ⇒ Object (readonly)
Returns the value of attribute errors_outside_examples.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def errors_outside_examples @errors_outside_examples end |
#example_count ⇒ Object (readonly)
Returns the value of attribute example_count.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def example_count @example_count end |
#failure_count ⇒ Object (readonly)
Returns the value of attribute failure_count.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def failure_count @failure_count end |
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def failures @failures end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def groups @groups end |
#pending_count ⇒ Object (readonly)
Returns the value of attribute pending_count.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def pending_count @pending_count end |
#seed ⇒ Object (readonly)
Returns the value of attribute seed.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def seed @seed end |
#seed_used ⇒ Object (readonly)
Returns the value of attribute seed_used.
7 8 9 |
# File 'lib/rspec/signal/report.rb', line 7 def seed_used @seed_used end |
Instance Method Details
#any_failures? ⇒ Boolean
36 |
# File 'lib/rspec/signal/report.rb', line 36 def any_failures? = !failures.empty? |
#cluster_count ⇒ Object
35 |
# File 'lib/rspec/signal/report.rb', line 35 def cluster_count = clusters.size |
#group_count ⇒ Object
34 |
# File 'lib/rspec/signal/report.rb', line 34 def group_count = groups.size |
#kept_frames ⇒ Object
49 |
# File 'lib/rspec/signal/report.rb', line 49 def kept_frames = total_frames - omitted_frames |
#omitted_frames ⇒ Object
Backtrace frames dropped across the whole run. This is the number that makes the reduction visible.
41 42 43 |
# File 'lib/rspec/signal/report.rb', line 41 def omitted_frames @omitted_frames ||= failures.sum { |failure| failure.reduced.omitted_count } end |
#safely ⇒ Object
Clustering is the newest and least essential stage; a report without it is still worth having, so it is never allowed to take the run down.
28 29 30 31 32 |
# File 'lib/rspec/signal/report.rb', line 28 def safely yield rescue StandardError [] end |
#seed_used? ⇒ Boolean
37 |
# File 'lib/rspec/signal/report.rb', line 37 def seed_used? = !!@seed_used |
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rspec/signal/report.rb', line 51 def to_h { schema: 1, generated_by: "rspec-signal #{VERSION}", summary: { examples: example_count, failures: failure_count, pending: pending_count, signatures: group_count, related_clusters: cluster_count.positive? ? cluster_count : nil, duration_seconds: duration&.round(3), seed: seed_used? ? seed : nil, errors_outside_examples: errors_outside_examples.positive? ? errors_outside_examples : nil }.compact, environment: environment, backtrace_reduction: { total_frames: total_frames, kept_frames: kept_frames, omitted_frames: omitted_frames }, signatures: groups.map(&:to_h), related: clusters.map(&:to_h) } end |
#total_frames ⇒ Object
45 46 47 |
# File 'lib/rspec/signal/report.rb', line 45 def total_frames @total_frames ||= failures.sum { |failure| failure.reduced.total } end |
#worker_h(write_full: false) ⇒ Object
Worker interchange data. Unlike the public report summary this retains every reduced failure so grouping can be repeated across all workers.
raw -- the unreduced formatter output -- is included only when
write_full is on, since it is otherwise discarded on merge and would
just bloat every worker payload for no reason.
78 79 80 81 82 83 84 85 |
# File 'lib/rspec/signal/report.rb', line 78 def worker_h(write_full: false) serialized = failures.map do |failure| attributes = failure.to_h.merge(fingerprint: failure.fingerprint.to_h) attributes[:raw] = failure.raw if write_full attributes end to_h.merge(schema: 2, failures: serialized) end |