Sha256: 55b03dea2f22151316b81f9a41a9c6ff19d37475ba32a773f34cd076f1a88df0

Contents?: true

Size: 1.96 KB

Versions: 7

Compression:

Stored size: 1.96 KB

Contents

# Encoding: utf-8

require 'parallel_tests/rspec/runner'
require 'parallel_tests/test/runner'

module ParallelTests
  module RSpec
    # Monkey Patching the ParallelTest RSpec Runner class to work with CKit's config and binary
    # TODO: we could probably make this its own typed runner versus extinding the rspec
    # one if this continues to get used
    class Runner < ParallelTests::Test::Runner
      class << self

        def run_tests(test_files, process_number, num_processes, options)
          exe = executable # expensive, so we cache
          version = (exe =~ /\brspec\b/ ? 2 : 1)

        # // Beginning of method modifications //
        # cmd = [exe, options[:test_options], (rspec_2_color if version == 2), spec_opts, *test_files].compact.join(" ")
        # NOTE: The above line was modified to conform to ckit's command line constraints

          # Passes the process number into so that any generated assets can be identified.
          cmd = [exe, "--parallel=#{process_number}", options[:test_options]].compact.join(' ')
          cmd << test_files.join(' ')

        # This concatenates the command into `bundle exec ckit brew --beakers=beaker1 beaker2 beaker3 etc`
        # Which enables each test group to be run in its own command
        # --beakers= is set in lib/chemkistrykit/cli/cli.rb when parallel_tests is executed using its -o option flag

        # // End of method modifications //

          options = options.merge(env: rspec_1_color) if version == 1
          execute_command(cmd, process_number, num_processes, options)
        end

        def determine_executable
          'bundle exec ckit brew'
        end

        def test_file_name
          'beaker'
        end

        def test_suffix
          '_beaker.rb'
        end

        def runtime_log
          # TODO: This needs to do something.
          File.join(Dir.getwd, 'evidence', 'parallel_runtime_rspec.log')
        end

      end # self
    end # Runner
  end # RSpec
end # ParallelTests

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
chemistrykit-3.10.1 lib/chemistrykit/parallel_tests/rspec/runner.rb
chemistrykit-3.10.0 lib/chemistrykit/parallel_tests/rspec/runner.rb
chemistrykit-3.9.1 lib/chemistrykit/parallel_tests/rspec/runner.rb
chemistrykit-3.9.0 lib/chemistrykit/parallel_tests/rspec/runner.rb
chemistrykit-3.9.0.rc3 lib/chemistrykit/parallel_tests/rspec/runner.rb
chemistrykit-3.9.0.rc2 lib/chemistrykit/parallel_tests/rspec/runner.rb
chemistrykit-3.9.0.rc1 lib/chemistrykit/parallel_tests/rspec/runner.rb