Class: RSpec::Conductor::Server
- Inherits:
-
Object
- Object
- RSpec::Conductor::Server
- Defined in:
- lib/rspec/conductor/server.rb
Constant Summary collapse
- MAX_SEED =
2**16
Instance Method Summary collapse
-
#initialize(worker_count:, rspec_args:, **opts) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
Constructor Details
#initialize(worker_count:, rspec_args:, **opts) ⇒ Server
Returns a new instance of Server.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rspec/conductor/server.rb', line 20 def initialize(worker_count:, rspec_args:, **opts) @worker_count = worker_count @worker_number_offset = opts.fetch(:worker_number_offset, 0) @prefork_require = opts.fetch(:prefork_require, nil) @postfork_require = opts.fetch(:postfork_require, nil) @first_is_1 = opts.fetch(:first_is_1, Conductor.default_first_is_1?) @seed = opts[:seed] || (Random.new_seed % MAX_SEED) @fail_fast_after = opts.fetch(:fail_fast_after, nil) @display_retry_backtraces = opts.fetch(:display_retry_backtraces, false) @print_slowest_count = opts.fetch(:print_slowest_count, nil) @example_status_persistence_path = opts.fetch(:example_status_persistence_path, nil) @verbose = opts.fetch(:verbose, false) @rspec_args = rspec_args @worker_processes = [] @spec_queue = [] @formatter_class = case opts[:formatter] when "ci" Formatters::CI when "fancy" Formatters::Fancy when "plain" Formatters::Plain else (!@verbose && Formatters::Fancy.recommended?) ? Formatters::Fancy : Formatters::Plain end @formatter = @formatter_class.new(worker_count: @worker_count) @suite_run = SuiteRun.new $stdout.sync = true $stdin.echo = false if $stdin.tty? Dir.chdir(Conductor.root) ENV["PARALLEL_TEST_GROUPS"] = worker_count.to_s # parallel_tests backward-compatibility end |
Instance Method Details
#run ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rspec/conductor/server.rb', line 55 def run setup_signal_handlers build_spec_queue preload_application @formatter.(worker_count: @worker_count, seed: @seed, spec_files_count: @spec_queue.size) start_workers run_event_loop wait_for_workers_to_exit @suite_run.suite_complete @formatter.print_summary(@suite_run, seed: @seed, success: success?) @formatter.print_slowest(@suite_run, @print_slowest_count) if @print_slowest_count Conductor::ExampleStatusPersister.persist(@suite_run.example_stats, @example_status_persistence_path) if @example_status_persistence_path exit_with_status end |