Module: RSpecTurbo::Config

Defined in:
lib/rspec_turbo/config.rb

Overview

Central place for environment-driven settings and derived log paths.

All tuning happens through environment variables so the runner stays a single zero-config binary:

RSPEC_TURBO_MAX               number of parallel workers (default: nproc)
RSPEC_TURBO_LOG_DIR           where per-worker logs live
RSPEC_TURBO_FORCE_SETUP=1     recreate test DBs even if cached
RSPEC_TURBO_PROGRESS_INTERVAL seconds between CI progress lines
COVERAGE=1                    merge SimpleCov results after the run
JUNIT_DIR=path                emit JUnit XML per worker into this dir

Slow-test profiling is opt-in and feeds the “Slowest folders/files” report (see slow_profile.rb): RSPEC_PROFILE_SLOW=1, RSPEC_PROFILE_GROUP_BY, etc.

Constant Summary collapse

TTY =
$stdout.tty? && !ENV["CI"]

Class Method Summary collapse

Class Method Details

.coverage?Boolean

Returns:

  • (Boolean)


39
# File 'lib/rspec_turbo/config.rb', line 39

def coverage? = %w[1 true].include?(ENV.fetch("COVERAGE", "0").downcase)

.coverage_merge_logObject



61
# File 'lib/rspec_turbo/config.rb', line 61

def coverage_merge_log = File.join(log_dir, "coverage_merge.log")

.dry_run_logObject



59
# File 'lib/rspec_turbo/config.rb', line 59

def dry_run_log = File.join(log_dir, "dry_run_stderr.log")

.force_setup?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/rspec_turbo/config.rb', line 31

def force_setup?
  flag = ENV["RSPEC_TURBO_FORCE_SETUP"] || ENV["RSPEC_PARALLEL_FORCE_SETUP"]

  %w[1 true yes].include?(flag.to_s.downcase)
end

.junit_dirObject



41
# File 'lib/rspec_turbo/config.rb', line 41

def junit_dir = ENV["JUNIT_DIR"]

.log_dirObject

── Derived paths ──────────────────────────────────────────────────────



49
# File 'lib/rspec_turbo/config.rb', line 49

def log_dir = ENV.fetch("RSPEC_TURBO_LOG_DIR") { ENV.fetch("RSPEC_LOG_DIR", "tmp/rspec-turbo") }

.log_path(label) ⇒ Object



53
# File 'lib/rspec_turbo/config.rb', line 53

def log_path(label) = File.join(log_dir, "#{label.tr("/", "_")}.log")

.profile?Boolean

Slow-test profiling is on by default; RSPEC_TURBO_NO_PROFILE=1 is the master kill switch. See slow_profile.rb and Worker.profile_env.

Returns:

  • (Boolean)


45
# File 'lib/rspec_turbo/config.rb', line 45

def profile? = !%w[1 true yes].include?(ENV["RSPEC_TURBO_NO_PROFILE"].to_s.downcase)

.progress_intervalObject



37
# File 'lib/rspec_turbo/config.rb', line 37

def progress_interval = Integer(ENV.fetch("RSPEC_TURBO_PROGRESS_INTERVAL", "30"))

.progress_path(slot) ⇒ Object



55
# File 'lib/rspec_turbo/config.rb', line 55

def progress_path(slot) = File.join(log_dir, "progress_#{slot}.txt")

.setup_log_path(slot) ⇒ Object



57
# File 'lib/rspec_turbo/config.rb', line 57

def setup_log_path(slot) = File.join(log_dir, "setup_slot#{slot}.log")

.setup_marker_dirObject



51
# File 'lib/rspec_turbo/config.rb', line 51

def setup_marker_dir = File.join(log_dir, "setup")

.tty?Boolean

Returns:

  • (Boolean)


25
# File 'lib/rspec_turbo/config.rb', line 25

def tty? = TTY

.workersObject



27
28
29
# File 'lib/rspec_turbo/config.rb', line 27

def workers
  Integer(ENV.fetch("RSPEC_TURBO_MAX") { ENV.fetch("RSPEC_PARALLEL_MAX", Etc.nprocessors) })
end