Class: ParallelTests::RSpec::Runner

Inherits:
Test::Runner show all
Defined in:
lib/parallel_tests/rspec/runner.rb

Constant Summary collapse

DEV_NULL =
(WINDOWS ? "NUL" : "/dev/null")

Constants inherited from Test::Runner

Test::Runner::RuntimeLogTooSmallError

Class Method Summary collapse

Methods inherited from Test::Runner

execute_command, execute_command_and_capture_output, find_results, print_command, test_env_number, tests_in_groups, tests_with_size

Class Method Details

.command_with_seed(cmd, seed) ⇒ Object

remove old seed and add new seed –seed 1234 –order rand –order rand:1234 –order random:1234



51
52
53
54
# File 'lib/parallel_tests/rspec/runner.rb', line 51

def command_with_seed(cmd, seed)
  clean = remove_command_arguments(cmd, '--seed', '--order')
  [*clean, '--seed', seed]
end

.default_test_folderObject



28
29
30
# File 'lib/parallel_tests/rspec/runner.rb', line 28

def default_test_folder
  "spec"
end

.determine_executableObject



14
15
16
17
18
19
20
21
22
# File 'lib/parallel_tests/rspec/runner.rb', line 14

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

.line_is_result?(line) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/parallel_tests/rspec/runner.rb', line 42

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

.run_tests(test_files, process_number, num_processes, options) ⇒ Object



9
10
11
12
# File 'lib/parallel_tests/rspec/runner.rb', line 9

def run_tests(test_files, process_number, num_processes, options)
  cmd = [*executable, *options[:test_options], *color, *spec_opts, *test_files]
  execute_command(cmd, process_number, num_processes, options)
end

.runtime_logObject



24
25
26
# File 'lib/parallel_tests/rspec/runner.rb', line 24

def runtime_log
  "tmp/parallel_runtime_rspec.log"
end

.summarize_results(results) ⇒ Object

Summarize results from threads and colorize results based on failure and pending counts.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/parallel_tests/rspec/runner.rb', line 58

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

.test_file_nameObject



32
33
34
# File 'lib/parallel_tests/rspec/runner.rb', line 32

def test_file_name
  "spec"
end

.test_suffixObject

used to find all _spec.rb files supports also feature files used by rspec turnip extension



38
39
40
# File 'lib/parallel_tests/rspec/runner.rb', line 38

def test_suffix
  /(_spec\.rb|\.feature)$/
end