Class: RSpec::Core::Bisect::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb

Overview

A DRb server that receives run results from a separate RSpec process started by the bisect process.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expected_failuresObject

Fetched via DRb by the BisectDRbFormatter to determine when to abort.



51
52
53
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 51

def expected_failures
  @expected_failures
end

#files_or_directories_to_runObject

Fetched via DRb to tell clients which files to run



57
58
59
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 57

def files_or_directories_to_run
  @files_or_directories_to_run
end

#latest_run_resultsObject

Set via DRb by the BisectDRbFormatter with the results of the run.



54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 54

def latest_run_results
  @latest_run_results
end

Class Method Details

.runObject



13
14
15
16
17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 13

def self.run
  server = new
  server.start
  yield server
ensure
  server.stop
end

Instance Method Details

#capture_run_results(files_or_directories_to_run = [], expected_failures = []) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 21

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 BisectFailedError.for_failed_spec_run(run_output)
  end

  latest_run_results
end

#drb_portObject



46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 46

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

#startObject



34
35
36
37
38
39
40
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 34

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 allow ::1 ])

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

#stopObject



42
43
44
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/bisect/server.rb', line 42

def stop
  @drb.stop_service
end