DEV: improve the plugin:spec rake task

Allow the plugin:spec to receive the test file path, rather than always run all tests of the plugin.
This commit is contained in:
nvh0412 2024-10-02 12:54:29 +10:00
parent ed4791d0b0
commit ead1a3be39
1 changed files with 13 additions and 9 deletions

View File

@ -184,7 +184,7 @@ task "plugin:install_gems", :plugin do |t, args|
puts "Done" puts "Done"
end end
def spec(plugin, parallel: false, argv: nil) def spec(plugin, files, parallel: false, argv: nil)
params = [] params = []
params << "--profile" if !parallel params << "--profile" if !parallel
params << "--fail-fast" if ENV["RSPEC_FAILFAST"] params << "--fail-fast" if ENV["RSPEC_FAILFAST"]
@ -192,8 +192,12 @@ def spec(plugin, parallel: false, argv: nil)
params << argv if argv params << argv if argv
# reject system specs as they are slow and need dedicated setup # reject system specs as they are slow and need dedicated setup
files = if files.empty?
Dir.glob("plugins/#{plugin}/spec/**/*_spec.rb").reject { |f| f.include?("spec/system/") }.sort files =
Dir.glob("plugins/#{plugin}/spec/**/*_spec.rb").reject { |f| f.include?("spec/system/") }.sort
else
files = files.split(" ")
end
if files.length > 0 if files.length > 0
cmd = parallel ? "bin/turbo_rspec" : "bin/rspec" cmd = parallel ? "bin/turbo_rspec" : "bin/rspec"
@ -209,15 +213,15 @@ def spec(plugin, parallel: false, argv: nil)
end end
desc "run plugin specs" desc "run plugin specs"
task "plugin:spec", %i[plugin argv] do |_, args| task "plugin:spec", %i[plugin argv files] do |_, args|
args.with_defaults(plugin: "*") args.with_defaults(plugin: "*", files: "")
spec(args[:plugin], argv: args[:argv]) spec(args[:plugin], args[:files], argv: args[:argv])
end end
desc "run plugin specs in parallel" desc "run plugin specs in parallel"
task "plugin:turbo_spec", %i[plugin argv] do |_, args| task "plugin:turbo_spec", %i[plugin argv files] do |_, args|
args.with_defaults(plugin: "*") args.with_defaults(plugin: "*", files: "")
spec(args[:plugin], parallel: true, argv: args[:argv]) spec(args[:plugin], args[:files], parallel: true, argv: args[:argv])
end end
desc "run plugin qunit tests" desc "run plugin qunit tests"