Module: SimpleCov::ParallelAdapters
- Extended by:
- ParallelAdapters
- Included in:
- ParallelAdapters
- Defined in:
- lib/simplecov/parallel_adapters.rb,
lib/simplecov/parallel_adapters/base.rb,
lib/simplecov/parallel_adapters/generic.rb,
lib/simplecov/parallel_adapters/parallel_tests.rb,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs,
sig/simplecov.rbs
Overview
Registry and selection for parallel-test-runner adapters. An adapter
answers a small fixed set of questions on SimpleCov's behalf: active?,
first_worker?, wait_for_siblings, and expected_worker_count.
Base provides safe no-op defaults. ParallelTestsAdapter wraps the
grosser/parallel_tests gem; GenericAdapter is env-var-only detection for
runners that follow the TEST_ENV_NUMBER convention without shipping a
Ruby API (#1065, #1156).
Users register their own with ParallelAdapters.register MyAdapter.
Subclass Base to inherit the no-op defaults: the contract methods are
class methods, so plain inheritance is what carries them through and
extend Base won't pick them up.
Defined Under Namespace
Modules: _Adapter Classes: Base, GenericAdapter, ParallelTestsAdapter
Instance Method Summary collapse
-
#adapters ⇒ Object
ParallelTestsAdapter first (most specific: it uses the gem's own API when the gem is loaded), then GenericAdapter as the env-var fallback.
-
#current ⇒ Object
The first registered adapter whose
active?answers true, or nil when none is, in which case the caller treats the process as single-worker. -
#register(adapter) ⇒ Object
Newly registered adapters are inserted at the front of the selection list, so a custom adapter for a specific runner takes precedence over the built-ins.
-
#reset_current! ⇒ Object
Primarily for tests that mutate env vars between examples; production runs are single-shot.
- #self?.adapters ⇒ Array[_Adapter]
- #self?.current ⇒ _Adapter?
- #self?.register ⇒ _Adapter
- #self?.reset_current! ⇒ void
Instance Method Details
#adapters ⇒ Object
ParallelTestsAdapter first (most specific: it uses the gem's own API when the gem is loaded), then GenericAdapter as the env-var fallback. User-registered adapters are prepended.
27 28 29 |
# File 'lib/simplecov/parallel_adapters.rb', line 27 def adapters @adapters ||= [ParallelTestsAdapter, GenericAdapter] end |
#current ⇒ Object
The first registered adapter whose active? answers true, or nil when
none is, in which case the caller treats the process as single-worker.
42 43 44 45 46 |
# File 'lib/simplecov/parallel_adapters.rb', line 42 def current return @current if instance_variable_defined?(:@current) @current = adapters.find(&:active?) end |
#register(adapter) ⇒ Object
Newly registered adapters are inserted at the front of the selection list, so a custom adapter for a specific runner takes precedence over the built-ins.
34 35 36 37 38 |
# File 'lib/simplecov/parallel_adapters.rb', line 34 def register(adapter) reset_current! adapters.unshift(adapter) unless adapters.include?(adapter) adapter end |
#reset_current! ⇒ Object
Primarily for tests that mutate env vars between examples; production runs are single-shot.
50 51 52 |
# File 'lib/simplecov/parallel_adapters.rb', line 50 def reset_current! remove_instance_variable(:@current) if instance_variable_defined?(:@current) end |
#self?.adapters ⇒ Array[_Adapter]
1618 |
# File 'sig/simplecov.rbs', line 1618 def self?.adapters: () -> Array[_Adapter] |
#self?.current ⇒ _Adapter?
1622 |
# File 'sig/simplecov.rbs', line 1622 def self?.current: () -> _Adapter? |
#self?.register ⇒ _Adapter
1620 |
# File 'sig/simplecov.rbs', line 1620 def self?.register: (_Adapter adapter) -> _Adapter |
#self?.reset_current! ⇒ void
This method returns an undefined value.
1624 |
# File 'sig/simplecov.rbs', line 1624 def self?.reset_current!: () -> void |