Created
September 13, 2022 15:16
-
-
Save miyucy/137f703b47b18a882db9878f11aaac96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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