Class: SimpleCov::CurrentRun
- Inherits:
-
Object
- Object
- SimpleCov::CurrentRun
- Defined in:
- lib/simplecov/current_run.rb
Overview
The state one measured run accumulates in one process: the pid and start time that identify it, the result it computes, the flags the merge coordination reads, and the serial the parent hands each forked subprocess. A new run is a new object, which is what lets anything needing a clean slate begin one instead of unsetting state by hand.
Instance Attribute Summary collapse
-
#collating_result ⇒ Object
writeonly
Sets the attribute collating_result.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#process_start_time ⇒ Object
Returns the value of attribute process_start_time.
-
#result ⇒ Object
Returns the value of attribute result.
-
#subprocess_serial ⇒ Object
readonly
A monotonically increasing serial the parent assigns to each forked subprocess.
Instance Method Summary collapse
- #collating_result? ⇒ Boolean
-
#forked_subprocess? ⇒ Boolean
Reading a mark that was never set answers nil, which is the answer wanted.
- #mark_forked_subprocess! ⇒ Object
- #next_subprocess_serial! ⇒ Object
-
#result? ⇒ Boolean
Answers exactly false while no result was ever stored, which is how "never computed" stays distinct from "cleared to nil".
-
#successor ⇒ Object
The result, the coordination flags and the identity belong to the run that ends; the fork genealogy belongs to the process and carries over.
Instance Attribute Details
#collating_result=(value) ⇒ Object (writeonly)
Sets the attribute collating_result
11 12 13 |
# File 'lib/simplecov/current_run.rb', line 11 def collating_result=(value) @collating_result = value end |
#pid ⇒ Object
Returns the value of attribute pid.
10 11 12 |
# File 'lib/simplecov/current_run.rb', line 10 def pid @pid end |
#process_start_time ⇒ Object
Returns the value of attribute process_start_time.
10 11 12 |
# File 'lib/simplecov/current_run.rb', line 10 def process_start_time @process_start_time end |
#result ⇒ Object
Returns the value of attribute result.
10 11 12 |
# File 'lib/simplecov/current_run.rb', line 10 def result @result end |
#subprocess_serial ⇒ Object
A monotonically increasing serial the parent assigns to each forked
subprocess. The default at_fork builds the worker's command_name from
this rather than the OS pid: the serial sequence is the same from one run
to the next, so a re-run overwrites the previous run's resultset entries
instead of writing uniquely-named ones that pile up (#1171).
49 50 51 |
# File 'lib/simplecov/current_run.rb', line 49 def subprocess_serial @subprocess_serial ||= 0 end |
Instance Method Details
#collating_result? ⇒ Boolean
31 32 33 |
# File 'lib/simplecov/current_run.rb', line 31 def collating_result? !!@collating_result end |
#forked_subprocess? ⇒ Boolean
Reading a mark that was never set answers nil, which is the answer wanted.
36 37 38 |
# File 'lib/simplecov/current_run.rb', line 36 def forked_subprocess? !!@forked_subprocess end |
#mark_forked_subprocess! ⇒ Object
40 41 42 |
# File 'lib/simplecov/current_run.rb', line 40 def mark_forked_subprocess! @forked_subprocess = true end |
#next_subprocess_serial! ⇒ Object
53 54 55 |
# File 'lib/simplecov/current_run.rb', line 53 def next_subprocess_serial! @subprocess_serial = subprocess_serial + 1 end |
#result? ⇒ Boolean
Answers exactly false while no result was ever stored, which is how "never computed" stays distinct from "cleared to nil".
27 28 29 |
# File 'lib/simplecov/current_run.rb', line 27 def result? instance_variable_defined?(:@result) && (_ = @result) end |
#successor ⇒ Object
The result, the coordination flags and the identity belong to the run that ends; the fork genealogy belongs to the process and carries over. A child that restarts tracking must not forget it was forked, or it would produce the final report itself, and a parent must not recount from zero, or its next children's names would collide with its first ones (#1171).
18 19 20 21 22 23 |
# File 'lib/simplecov/current_run.rb', line 18 def successor following = self.class.new following.subprocess_serial = @subprocess_serial following.mark_forked_subprocess! if forked_subprocess? following end |