Class: SimpleCov::ParallelAdapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/parallel_adapters/base.rb

Overview

Default no-op implementations for a parallel-test-runner adapter. Real adapters subclass and override what they need; everything else falls back to “behave like a single-process run.”

Adapters are classes (used as singletons, never instantiated) — they answer a small fixed set of questions about whether THIS worker process is the one that should do final-result work, and provide an optional hook for waiting on sibling workers.

Direct Known Subclasses

GenericAdapter, ParallelTestsAdapter

Class Method Summary collapse

Class Method Details

.active?Boolean

Should this adapter be selected for the current process? Adapters are tried in registration order; the first one whose ‘active?` returns true is chosen. Inactive adapters return `false`.

Returns:

  • (Boolean)


20
21
22
# File 'lib/simplecov/parallel_adapters/base.rb', line 20

def active?
  false
end

.expected_worker_countObject

How many parallel workers are participating in this run. Used by the polling fallback to know how many resultset entries to expect. Defaults to 1 (single-process).



45
46
47
# File 'lib/simplecov/parallel_adapters/base.rb', line 45

def expected_worker_count
  1
end

.first_worker?Boolean

Among the parallel workers in this run, should THIS worker do the final-result work (wait for siblings, merge resultsets, run threshold checks, format the report)? Default is ‘true` for the single-process case.

Returns:

  • (Boolean)


28
29
30
# File 'lib/simplecov/parallel_adapters/base.rb', line 28

def first_worker?
  true
end

.wait_for_siblingsObject

Optional: block until sibling workers have finished writing their resultsets. An adapter that wraps a parallel-test runner with a native synchronization primitive (e.g., ‘parallel_tests`’s ‘wait_for_other_processes_to_finish`) implements this for lower latency; otherwise SimpleCov polls the resultset cache as a fallback (see `SimpleCov.wait_for_parallel_results`).



38
39
40
# File 'lib/simplecov/parallel_adapters/base.rb', line 38

def wait_for_siblings
  # No-op default; polling fallback handles correctness.
end