Sha256: d5abef490e33a7690b761febd1cfa0fdf10bff1a29e23ee6df596d6d327e0a9f

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

require "parallel_tests/test/runner"

module ParallelTests
  module RSpec
    class Runner < ParallelTests::Test::Runner
      DEV_NULL = (WINDOWS ? "NUL" : "/dev/null")
      class << self
        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 determine_executable
          case
          when File.exist?("bin/rspec")
            ParallelTests.with_ruby_binary("bin/rspec")
          when ParallelTests.bundler_enabled?
            "bundle exec rspec"
          else
            "rspec"
          end
        end

        def runtime_log
          'tmp/parallel_runtime_rspec.log'
        end

        def test_file_name
          "spec"
        end

        def test_suffix
          /_spec\.rb$/
        end

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

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


        private

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

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

        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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
parallel_tests-3.3.0 lib/parallel_tests/rspec/runner.rb
parallel_tests-3.2.0 lib/parallel_tests/rspec/runner.rb
parallel_tests-3.1.0 lib/parallel_tests/rspec/runner.rb
parallel_tests-3.0.0 lib/parallel_tests/rspec/runner.rb