DEV: Add rake plugins:turbo_spec task (#18289)

This leans on our existing `turbo_rspec` implementation to run plugin specs in parallel on all available cores
This commit is contained in:
David Taylor
2022-09-20 15:42:54 +01:00
committed by GitHub
parent 59071a13f4
commit ef39193a06
3 changed files with 21 additions and 10 deletions

View File

@ -167,23 +167,34 @@ task 'plugin:install_gems', :plugin do |t, args|
puts "Done"
end
desc 'run plugin specs'
task 'plugin:spec', :plugin do |t, args|
args.with_defaults(plugin: "*")
params = ['--profile']
def spec(plugin, parallel: false)
params = []
params << '--profile' if !parallel
params << '--fail-fast' if ENV['RSPEC_FAILFAST']
params << "--seed #{ENV['RSPEC_SEED']}" if Integer(ENV['RSPEC_SEED'], exception: false)
ruby = `which ruby`.strip
files = Dir.glob("./plugins/#{args[:plugin]}/spec/**/*_spec.rb").sort
files = Dir.glob("./plugins/#{plugin}/spec/**/*_spec.rb").sort
if files.length > 0
sh "LOAD_PLUGINS=1 #{ruby} -S rspec #{files.join(' ')} #{params.join(' ')}"
cmd = parallel ? "bin/turbo_rspec" : "bin/rspec"
sh "LOAD_PLUGINS=1 #{cmd} #{files.join(' ')} #{params.join(' ')}"
else
abort "No specs found."
end
end
desc 'run plugin specs'
task 'plugin:spec', :plugin do |t, args|
args.with_defaults(plugin: "*")
spec(args[:plugin])
end
desc 'run plugin specs in parallel'
task 'plugin:turbo_spec', :plugin do |t, args|
args.with_defaults(plugin: "*")
spec(args[:plugin], parallel: true)
end
desc 'run plugin qunit tests'
task 'plugin:qunit', [:plugin, :timeout] do |t, args|
args.with_defaults(plugin: "*")