Class: SimpleCov::ContextMap::Union
- Inherits:
-
Object
- Object
- SimpleCov::ContextMap::Union
- Defined in:
- lib/simplecov/context_map/union.rb
Overview
Accumulates the context maps of every result a merge absorbs, under the all-or-nothing rule the resultset format needs: the merged result carries the union of the maps when every merged result recorded one, and no map at all otherwise. Keeping a partial union would present one worker's map as the whole run's, silently omitting the tests of the results that didn't record.
Instance Attribute Summary collapse
-
#carrying ⇒ Object
readonly
Returns the value of attribute carrying.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
- #absorb_entry(data) ⇒ Object
- #absorb_resultset(resultset) ⇒ Object
-
#absorb_union(other) ⇒ Object
The parallel merge builds one union per worker over its slice and ships it back, so the parent combines unions rather than re-reading entries.
- #collector ⇒ Object
- #complete? ⇒ Boolean
-
#initialize ⇒ Union
constructor
A new instance of Union.
-
#map ⇒ Object
The union when every absorbed result carried a map, nil otherwise.
Constructor Details
#initialize ⇒ Union
Returns a new instance of Union.
14 15 16 17 18 19 |
# File 'lib/simplecov/context_map/union.rb', line 14 def initialize @map = ContextMap.new @complete = true @carrying = 0 @entries = 0 end |
Instance Attribute Details
#carrying ⇒ Object (readonly)
Returns the value of attribute carrying.
12 13 14 |
# File 'lib/simplecov/context_map/union.rb', line 12 def @carrying end |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
12 13 14 |
# File 'lib/simplecov/context_map/union.rb', line 12 def entries @entries end |
Instance Method Details
#absorb_entry(data) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/simplecov/context_map/union.rb', line 29 def absorb_entry(data) @entries += 1 map = ContextMap.from_hash(data["contexts"]) return @complete = false unless map @carrying += 1 @map.absorb(map) end |
#absorb_resultset(resultset) ⇒ Object
25 26 27 |
# File 'lib/simplecov/context_map/union.rb', line 25 def absorb_resultset(resultset) resultset.each_value { |data| absorb_entry(data) } end |
#absorb_union(other) ⇒ Object
The parallel merge builds one union per worker over its slice and ships it back, so the parent combines unions rather than re-reading entries.
40 41 42 43 44 45 46 |
# File 'lib/simplecov/context_map/union.rb', line 40 def absorb_union(other) @entries += other.entries @carrying += other. @complete &&= other.complete? @map.absorb(other.partial_map) self end |
#collector ⇒ Object
21 22 23 |
# File 'lib/simplecov/context_map/union.rb', line 21 def collector ->(surviving) { absorb_resultset(surviving) } end |
#complete? ⇒ Boolean
48 49 50 |
# File 'lib/simplecov/context_map/union.rb', line 48 def complete? @complete end |
#map ⇒ Object
The union when every absorbed result carried a map, nil otherwise. Dropping
warns when the merge mixed results with and without maps, since that
usually means track_tests is on in some workers and not others; a merge
where nothing recorded stays quiet.
56 57 58 59 60 |
# File 'lib/simplecov/context_map/union.rb', line 56 def map return @map if @complete warn_about_partial_maps end |