Class: SimpleCov::ParallelAdapters::GenericAdapter

Inherits:
Base
  • Object
show all
Defined in:
lib/simplecov/parallel_adapters/generic.rb,
sig/simplecov.rbs

Overview

Catch-all adapter for runners that follow the TEST_ENV_NUMBER / PARALLEL_TEST_GROUPS env-var convention without shipping a Ruby API (parallel_rspec, knapsack-style splitters, custom CI sharding). Activates when TEST_ENV_NUMBER is set, unless SimpleCov.parallel_tests false opted out.

Class Method Summary collapse

Methods inherited from Base

native_wait?, wait_for_siblings

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/simplecov/parallel_adapters/generic.rb', line 25

def active?
  return false if SimpleCov.parallel_tests == false

  ENV.key?("TEST_ENV_NUMBER")
end

.expected_worker_countInteger

Returns:

  • (Integer)


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

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

.first_worker?Boolean

First worker is TEST_ENV_NUMBER "" (parallel_tests convention) or "1" (runners that number from 1).

Returns:

  • (Boolean)


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

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