8
9
10
11
12
13
14
15
16
17
18
19
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
|
# File 'lib/rspec_queue/server_runner.rb', line 8
def run_specs(example_groups)
worker_pids = []
example_group_hash = example_groups.map { |example_group|
[example_group.id, example_group]
}.to_h
server = RSpecQueue::Server.new
RSpecQueue::Configuration.instance.worker_count.times do |i|
env = {
"RSPEC_QUEUE_WORKER_ID" => i.to_s,
"RSPEC_QUEUE_SERVER_ADDRESS" => server.socket_path,
}
worker_pids << spawn(env, "rspec-queue-worker", *ARGV)
end
reporter = @configuration.reporter
reporter.report(0) do |report|
@configuration.with_suite_hooks do
server.dispatch(example_group_hash, report)
if @configuration.world.non_example_failure
1
else
[report.failed_examples.count, 1].min
end
end
end
ensure
server.close if server
worker_pids.each do |pid|
Process.kill("TERM", pid)
Process.wait(pid)
end
end
|