class ParallelTests::RSpec::Runner

def color

def color
  '--color --tty' if $stdout.tty?
end

def command_with_seed(cmd, seed)

--order random:1234
--order rand:1234
--order rand
--seed 1234
remove old seed and add new seed
def command_with_seed(cmd, seed)
  clean = cmd.sub(/\s--(seed\s+\d+|order\s+rand(om)?(:\d+)?)\b/, '')
  "#{clean} --seed #{seed}"
end

def default_test_folder

def default_test_folder
  "spec"
end

def determine_executable

def determine_executable
  if File.exist?("bin/rspec")
    ParallelTests.with_ruby_binary("bin/rspec")
  elsif ParallelTests.bundler_enabled?
    "bundle exec rspec"
  else
    "rspec"
  end
end

def line_is_result?(line)

def line_is_result?(line)
  line =~ /\d+ examples?, \d+ failures?/
end

def run(cmd)

so it can be stubbed....
def run(cmd)
  `#{cmd}`
end

def run_tests(test_files, process_number, num_processes, options)

def run_tests(test_files, process_number, num_processes, options)
  exe = executable # expensive, so we cache
  cmd = [exe, options[:test_options], color, spec_opts, *test_files].compact.join(" ")
  execute_command(cmd, process_number, num_processes, options)
end

def runtime_log

def runtime_log
  "tmp/parallel_runtime_rspec.log"
end

def spec_opts

def spec_opts
  options_file = ['.rspec_parallel', 'spec/parallel_spec.opts', 'spec/spec.opts'].detect { |f| File.file?(f) }
  return unless options_file
  "-O #{options_file}"
end

def summarize_results(results)


Summarize results from threads and colorize results based on failure and pending counts.
def summarize_results(results)
  text = super
  return text unless $stdout.tty?
  sums = sum_up_results(results)
  color =
    if sums['failure'] > 0
      31 # red
    elsif sums['pending'] > 0
      33 # yellow
    else
      32 # green
    end
  "\e[#{color}m#{text}\e[0m"
end

def test_file_name

def test_file_name
  "spec"
end

def test_suffix

def test_suffix
  /_spec\.rb$/
end