123456789_123456789_123456789_123456789_123456789_

Class: SimpleCov::ParallelAdapters::GenericAdapter

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: SimpleCov::ParallelAdapters::Base
Defined in: lib/simplecov/parallel_adapters/generic.rb

Overview

Catch-all adapter for parallel test runners that follow the TEST_ENV_NUMBER / PARALLEL_TEST_GROUPS env-var convention but don't ship a Ruby API for ::SimpleCov to hook (parallel_rspec, knapsack-style splitters, custom CI sharding scripts). Activates when TEST_ENV_NUMBER is set; doesn't require any specific gem to be loaded.

Heuristic for .first_worker?: the worker whose TEST_ENV_NUMBER is "" (parallel_tests/parallel_rspec convention) or "1" (zero-based runners that start at 1). Any other value is treated as a non-first worker.

wait_for_siblings is inherited from Base as a no-op — without a runner-provided API the only synchronization available is polling the resultset cache, which SimpleCov.wait_for_parallel_results does after the no-op returns.

Class Attribute Summary

Base - Inherited

.active?

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

.first_worker?

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.

Class Method Summary

Base - Inherited

.expected_worker_count

How many parallel workers are participating in this run.

.wait_for_siblings

Optional: block until sibling workers have finished writing their resultsets.

Class Attribute Details

.active?Boolean (readonly)

[ GitHub ]

  
# File 'lib/simplecov/parallel_adapters/generic.rb', line 25

def active?
  ENV.key?("TEST_ENV_NUMBER")
end

.first_worker?Boolean (readonly)

parallel_tests sets the first worker's TEST_ENV_NUMBER to ""; parallel_rspec inherits that. Runners that number from 1 use "1" for the first worker. Both shapes match.

[ GitHub ]

  
# File 'lib/simplecov/parallel_adapters/generic.rb', line 32

def first_worker?
  ["", "1"].include?(ENV.fetch("TEST_ENV_NUMBER", nil))
end

Class Method Details

.expected_worker_count

[ GitHub ]

  
# File 'lib/simplecov/parallel_adapters/generic.rb', line 36

def expected_worker_count
  ENV["PARALLEL_TEST_GROUPS"]&.to_i || 1
end