Skip to content

Instantly share code, notes, and snippets.

@miyucy
Created September 13, 2022 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miyucy/137f703b47b18a882db9878f11aaac96 to your computer and use it in GitHub Desktop.
Save miyucy/137f703b47b18a882db9878f11aaac96 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "bundler/setup"
require "rspec/core"
RSpec::Core::Runner.disable_autorun!
RSpec::Core::Runner.trap_interrupt
options = RSpec::Core::ConfigurationOptions.new(ARGV)
runner = RSpec::Core::Runner.new(options)
runner.setup STDOUT, STDERR
examples = [[], [], []]
RSpec.world.ordered_example_groups.each_slice(3) do |(a, b, c)|
examples[0] << a if a
examples[1] << b if b
examples[2] << c if c
break
end
# before fork
pids = examples.map do |example_group|
pid = Process.fork do
exit 0 if example_group.empty?
# assign env vars
# after fork
status = runner.run_specs(example_group)
p status
if status.to_i == 0
exit 0
else
exit status
end
end
exit 0 unless pid
pid
end
pids.each do |pid|
Process.waitpid(pid)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment