Class: SimpleCov::ParallelAdapters::ParallelTestsAdapter
- Defined in:
- lib/simplecov/parallel_adapters/parallel_tests.rb,
sig/simplecov.rbs
Overview
Adapter for grosser/parallel_tests, the historical default and still the
most precise option for projects on it. Detection requires the full native
coordination contract: the ParallelTests constant loaded,
TEST_ENV_NUMBER set, and PARALLEL_PID_FILE set, because the native
wait API reads the pid-file path with ENV.fetch. A runner that only
provides the env-var convention belongs to GenericAdapter.
Class Method Summary collapse
- .active? ⇒ Boolean
-
.ensure_loaded ⇒ void
parallel_tests is an optional dependency, and
TEST_ENV_NUMBER/PARALLEL_TEST_GROUPSare commonly set for other reasons, so a missing gem is treated as "user isn't using parallel_tests": stay quiet and let GenericAdapter handle it. - .env_suggests_parallel_tests? ⇒ Boolean
- .expected_worker_count ⇒ Integer
-
.first_worker? ⇒ Boolean
The first started process, not the last.
- .native_parallel_tests_environment? ⇒ Boolean
- .native_wait? ⇒ Boolean
- .wait_for_siblings ⇒ void
Methods inherited from Base
forced_off?, parallel_test_groups_count
Class Method Details
.active? ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 15 def active? return false if forced_off? ensure_loaded !!(defined?(::ParallelTests) && native_parallel_tests_environment?) end |
.ensure_loaded ⇒ void
This method returns an undefined value.
parallel_tests is an optional dependency, and TEST_ENV_NUMBER /
PARALLEL_TEST_GROUPS are commonly set for other reasons, so a missing
gem is treated as "user isn't using parallel_tests": stay quiet and let
GenericAdapter handle it. Warning here regressed users who use those env
vars for their own subprocess coordination (#1018).
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 51 def ensure_loaded return if defined?(::ParallelTests) return if forced_off? return unless SimpleCov.parallel_tests || env_suggests_parallel_tests? # simplecov:disable — only fires under a real parallel_tests setup require "parallel_tests" rescue LoadError # simplecov:enable end |
.env_suggests_parallel_tests? ⇒ Boolean
62 63 64 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 62 def env_suggests_parallel_tests? ENV.key?("TEST_ENV_NUMBER") && ENV.key?("PARALLEL_TEST_GROUPS") end |
.expected_worker_count ⇒ Integer
42 43 44 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 42 def expected_worker_count parallel_test_groups_count end |
.first_worker? ⇒ Boolean
The first started process, not the last. The parallel_tests README
recommends first_process? for "do something once after every worker
finishes" hooks, so user code with its own
wait_for_other_processes_to_finish overwhelmingly waits in the first
process, and picking the same side avoids the cross-process deadlock #922
reported.
28 29 30 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 28 def first_worker? ParallelTests.first_process? end |
.native_parallel_tests_environment? ⇒ Boolean
66 67 68 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 66 def native_parallel_tests_environment? ENV.key?("TEST_ENV_NUMBER") && ENV.key?("PARALLEL_PID_FILE") end |
.native_wait? ⇒ Boolean
38 39 40 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 38 def native_wait? native_parallel_tests_environment? end |
.wait_for_siblings ⇒ void
This method returns an undefined value.
32 33 34 35 36 |
# File 'lib/simplecov/parallel_adapters/parallel_tests.rb', line 32 def wait_for_siblings return unless native_parallel_tests_environment? ParallelTests.wait_for_other_processes_to_finish end |