Sha256: 7ce22d9db141076f5f8ed63bb7f3d4eca889b35af4679f17ce5277d0944169e7

Contents?: true

Size: 1.99 KB

Versions: 6891

Compression:

Stored size: 1.99 KB

Contents

require 'open3'
RSpec::Support.require_rspec_core "bisect/server"

module RSpec
  module Core
    module Bisect
      # Provides an API to run the suite for a set of locations, using
      # the given bisect server to capture the results.
      #
      # Sets of specs are run by shelling out.
      # @private
      class ShellRunner
        def self.start(shell_command, _spec_runner)
          Server.run do |server|
            yield new(server, shell_command)
          end
        end

        def self.name
          :shell
        end

        def initialize(server, shell_command)
          @server        = server
          @shell_command = shell_command
        end

        def run(locations)
          run_locations(locations, original_results.failed_example_ids)
        end

        def original_results
          @original_results ||= run_locations(@shell_command.original_locations)
        end

      private

        def run_locations(*capture_args)
          @server.capture_run_results(*capture_args) do
            run_command @shell_command.command_for([], @server)
          end
        end

        # `Open3.capture2e` does not work on JRuby:
        # https://github.com/jruby/jruby/issues/2766
        if Open3.respond_to?(:capture2e) && !RSpec::Support::Ruby.jruby?
          def run_command(cmd)
            Open3.capture2e(@shell_command.bisect_environment_hash, cmd).first
          end
        else # for 1.8.7
          # :nocov:
          def run_command(cmd)
            out = err = nil

            original_spec_opts = ENV['SPEC_OPTS']
            ENV['SPEC_OPTS'] = @shell_command.spec_opts_without_bisect

            Open3.popen3(cmd) do |_, stdout, stderr|
              # Reading the streams blocks until the process is complete
              out = stdout.read
              err = stderr.read
            end

            "Stdout:\n#{out}\n\nStderr:\n#{err}"
          ensure
            ENV['SPEC_OPTS'] = original_spec_opts
          end
          # :nocov:
        end
      end
    end
  end
end

Version data entries

6,891 entries across 6,827 versions & 85 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/rspec-core-3.11.0/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb
cybrid_api_id_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/bisect/shell_runner.rb