Skip to content

Commit

Permalink
Merge pull request #4 from conversation/self-testable
Browse files Browse the repository at this point in the history
Make rspec-queue self testable
  • Loading branch information
RohanM authored May 24, 2019
2 parents bf1cee3 + 6d86b0e commit 8e34047
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/rspec_queue/server.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
require 'socket'
require 'securerandom'

module RSpecQueue
class Server

Expand Down
5 changes: 3 additions & 2 deletions lib/rspec_queue/server_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
module RSpecQueue
class ServerRunner < RSpec::Core::Runner
def run_specs(example_groups)
worker_pids = []

example_group_hash = example_groups.map { |example_group|
[example_group.id, example_group]
}.to_h

# start the server, so we are ready to accept connections from workers
server = RSpecQueue::Server.new
worker_pids = []

RSpecQueue::Configuration.instance.worker_count.times do |i|
env = {
Expand All @@ -38,7 +39,7 @@ def run_specs(example_groups)
end
end
ensure
server.close
server.close if server

worker_pids.each do |pid|
Process.kill("TERM", pid)
Expand Down
1 change: 1 addition & 0 deletions lib/rspec_queue/worker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'json'
require 'socket'

module RSpecQueue
class Worker
Expand Down

0 comments on commit 8e34047

Please sign in to comment.