DEV: Split out multisite tests in bin/turbo_rspec
* A new process is started that just runs the multisite tests * The other processes are instructed to exclude the multisite tests
This commit is contained in:
parent
0bf3316aec
commit
15c02c03c7
|
@ -44,8 +44,10 @@ module TurboTests
|
|||
|
||||
setup_tmp_dir
|
||||
|
||||
tests_in_groups.each_with_index do |tests, process_num|
|
||||
start_subprocess(tests, process_num + 1)
|
||||
start_multisite_subprocess(@files)
|
||||
|
||||
tests_in_groups.each_with_index do |tests, process_id|
|
||||
start_regular_subprocess(tests, process_id + 1)
|
||||
end
|
||||
|
||||
handle_messages
|
||||
|
@ -83,23 +85,45 @@ module TurboTests
|
|||
FileUtils.mkdir_p('tmp/test-pipes/')
|
||||
end
|
||||
|
||||
def start_subprocess(tests, process_num)
|
||||
def start_multisite_subprocess(tests)
|
||||
start_subprocess(
|
||||
{},
|
||||
["--tag", "type:multisite"],
|
||||
tests,
|
||||
"multisite"
|
||||
)
|
||||
end
|
||||
|
||||
def start_regular_subprocess(tests, process_id)
|
||||
start_subprocess(
|
||||
{ 'TEST_ENV_NUMBER' => process_id.to_s },
|
||||
["--tag", "~type:multisite"],
|
||||
tests,
|
||||
process_id
|
||||
)
|
||||
end
|
||||
|
||||
def start_subprocess(env, extra_args, tests, process_id)
|
||||
if tests.empty?
|
||||
@messages << {
|
||||
type: 'exit',
|
||||
process_num: process_num
|
||||
process_id: process_id
|
||||
}
|
||||
else
|
||||
tmp_filename = "tmp/test-pipes/subprocess-#{process_id}"
|
||||
|
||||
begin
|
||||
File.mkfifo("tmp/test-pipes/subprocess-#{process_num}")
|
||||
File.mkfifo(tmp_filename)
|
||||
rescue Errno::EEXIST
|
||||
end
|
||||
|
||||
env = { 'TEST_ENV_NUMBER' => process_num.to_s }
|
||||
env['RSPEC_SILENCE_FILTER_ANNOUNCEMENTS'] = '1'
|
||||
|
||||
command = [
|
||||
"bundle", "exec", "rspec",
|
||||
"-f", "TurboTests::JsonRowsFormatter",
|
||||
"-o", "tmp/test-pipes/subprocess-#{process_num}",
|
||||
*extra_args,
|
||||
"--format", "TurboTests::JsonRowsFormatter",
|
||||
"--out", tmp_filename,
|
||||
*tests
|
||||
]
|
||||
|
||||
|
@ -107,25 +131,25 @@ module TurboTests
|
|||
command_str = [
|
||||
env.map { |k, v| "#{k}=#{v}" }.join(' '),
|
||||
command.join(' ')
|
||||
].join(' ')
|
||||
].select { |x| x.size > 0 }.join(' ')
|
||||
|
||||
STDERR.puts "Process #{process_num}: #{command_str}"
|
||||
STDERR.puts "Process #{process_id}: #{command_str}"
|
||||
end
|
||||
|
||||
_stdin, stdout, stderr, _wait_thr = Open3.popen3(env, *command)
|
||||
|
||||
@threads <<
|
||||
Thread.new do
|
||||
File.open("tmp/test-pipes/subprocess-#{process_num}") do |fd|
|
||||
File.open(tmp_filename) do |fd|
|
||||
fd.each_line do |line|
|
||||
message = JSON.parse(line)
|
||||
message = message.symbolize_keys
|
||||
message[:process_num] = process_num
|
||||
message[:process_id] = process_id
|
||||
@messages << message
|
||||
end
|
||||
end
|
||||
|
||||
@messages << { type: 'exit', process_num: process_num }
|
||||
@messages << { type: 'exit', process_id: process_id }
|
||||
end
|
||||
|
||||
@threads << start_copy_thread(stdout, STDOUT)
|
||||
|
@ -167,7 +191,7 @@ module TurboTests
|
|||
when 'close'
|
||||
when 'exit'
|
||||
exited += 1
|
||||
if exited == @num_processes
|
||||
if exited == @num_processes + 1
|
||||
break
|
||||
end
|
||||
else
|
||||
|
|
|
@ -155,6 +155,7 @@ end
|
|||
|
||||
RSpec.configure do |config|
|
||||
config.fail_fast = ENV['RSPEC_FAIL_FAST'] == "1"
|
||||
config.silence_filter_announcements = ENV['RSPEC_SILENCE_FILTER_ANNOUNCEMENTS'] == "1"
|
||||
config.include Helpers
|
||||
config.include MessageBus
|
||||
config.include RSpecHtmlMatchers
|
||||
|
|
Loading…
Reference in New Issue