Sha256: e8b3cb4e5aa6ddbac76438a3528748302b355c579ff80ad7e6e161b93b699073

Contents?: true

Size: 1.9 KB

Versions: 47

Compression:

Stored size: 1.9 KB

Contents

require 'drb/drb'
require 'drb/acl'

module RSpec
  module Core
    # @private
    module Bisect
      # @private
      BisectFailedError = Class.new(StandardError)

      # @private
      # A DRb server that receives run results from a separate RSpec process
      # started by the bisect process.
      class Server
        def self.run
          server = new
          server.start
          yield server
        ensure
          server.stop
        end

        def capture_run_results(files_or_directories_to_run=[], expected_failures=[])
          self.expected_failures  = expected_failures
          self.files_or_directories_to_run = files_or_directories_to_run
          self.latest_run_results = nil
          run_output = yield

          if latest_run_results.nil? || latest_run_results.all_example_ids.empty?
            raise_bisect_failed(run_output)
          end

          latest_run_results
        end

        def start
          # Only allow remote DRb requests from this machine.
          DRb.install_acl ACL.new(%w[ deny all allow localhost allow 127.0.0.1 ])

          # We pass `nil` as the first arg to allow it to pick a DRb port.
          @drb = DRb.start_service(nil, self)
        end

        def stop
          @drb.stop_service
        end

        def drb_port
          @drb_port ||= Integer(@drb.uri[/\d+$/])
        end

        # Fetched via DRb by the BisectFormatter to determine when to abort.
        attr_accessor :expected_failures

        # Set via DRb by the BisectFormatter with the results of the run.
        attr_accessor :latest_run_results

        # Fetched via DRb to tell clients which files to run
        attr_accessor :files_or_directories_to_run

      private

        def raise_bisect_failed(run_output)
          raise BisectFailedError, "Failed to get results from the spec " \
                "run. Spec run output:\n\n#{run_output}"
        end
      end
    end
  end
end

Version data entries

47 entries across 42 versions & 19 rubygems

Version Path
dirwatch-0.0.9 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.7.0/lib/rspec/core/bisect/server.rb
dirwatch-0.0.8 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.7.0/lib/rspec/core/bisect/server.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
logstash-filter-device_detection-1.0.7-java vendor/bundle/jruby/1.9/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/server.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
tdiary-5.0.9 vendor/bundle/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
mrcooper-logstash-output-azuresearch-0.2.2 vendor/jruby/2.5.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
monero_wallet_gen-0.1.0 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
sb_prime_table-0.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
sb_prime_table-0.1.0 vendor/bundle/ruby/2.4.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/rspec-core-3.7.0/lib/rspec/core/bisect/server.rb
tdiary-5.0.8 vendor/bundle/gems/rspec-core-3.7.1/lib/rspec/core/bisect/server.rb
rspec-core-3.7.1 lib/rspec/core/bisect/server.rb
tdiary-5.0.7 vendor/bundle/gems/rspec-core-3.7.0/lib/rspec/core/bisect/server.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.7.0/lib/rspec/core/bisect/server.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.7.0/lib/rspec/core/bisect/server.rb